• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2012 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef NET_DISK_CACHE_NET_LOG_PARAMETERS_H_
6 #define NET_DISK_CACHE_NET_LOG_PARAMETERS_H_
7 
8 #include <stdint.h>
9 
10 #include "base/values.h"
11 #include "net/disk_cache/disk_cache.h"
12 #include "net/log/net_log_with_source.h"
13 
14 namespace net {
15 struct NetLogSource;
16 }
17 
18 // This file contains a set of functions to create NetLogParametersCallbacks
19 // shared by EntryImpls and MemEntryImpls.
20 namespace disk_cache {
21 
22 class Entry;
23 
24 // Creates NetLog parameters for the creation of an Entry.  Contains the Entry's
25 // key and whether it was created or opened. |entry| can't be nullptr, must
26 // support GetKey().
27 base::Value::Dict CreateNetLogParametersEntryCreationParams(const Entry* entry,
28                                                             bool created);
29 
30 // Logs an event for the start of a non-sparse read or write of an Entry. For
31 // reads, |truncate| must be false.
32 void NetLogReadWriteData(const net::NetLogWithSource& net_log,
33                          net::NetLogEventType type,
34                          net::NetLogEventPhase phase,
35                          int index,
36                          int offset,
37                          int buf_len,
38                          bool truncate);
39 
40 // Logs an event for when a non-sparse read or write completes.  For reads,
41 // |truncate| must be false. |bytes_copied| is either the number of bytes copied
42 // or a network error code.  |bytes_copied| must not be ERR_IO_PENDING, as it's
43 // not a valid result for an operation.
44 void NetLogReadWriteComplete(const net::NetLogWithSource& net_log,
45                              net::NetLogEventType type,
46                              net::NetLogEventPhase phase,
47                              int bytes_copied);
48 
49 // Logs an event for when a sparse operation is started.
50 void NetLogSparseOperation(const net::NetLogWithSource& net_log,
51                            net::NetLogEventType type,
52                            net::NetLogEventPhase phase,
53                            int64_t offset,
54                            int buf_len);
55 
56 // Logs an event for when a read or write for a sparse entry's child is started.
57 void NetLogSparseReadWrite(const net::NetLogWithSource& net_log,
58                            net::NetLogEventType type,
59                            net::NetLogEventPhase phase,
60                            const net::NetLogSource& source,
61                            int child_len);
62 
63 // Creates NetLog parameters for when a call to GetAvailableRange returns.
64 base::Value::Dict CreateNetLogGetAvailableRangeResultParams(
65     const disk_cache::RangeResult result);
66 
67 }  // namespace disk_cache
68 
69 #endif  // NET_DISK_CACHE_NET_LOG_PARAMETERS_H_
70