OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/disk_cache/net_log_parameters.h" | 5 #include "net/disk_cache/net_log_parameters.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "net/base/net_errors.h" | 11 #include "net/base/net_errors.h" |
12 #include "net/disk_cache/disk_cache.h" | 12 #include "net/disk_cache/disk_cache.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 Value* NetLogEntryCreationCallback(const disk_cache::Entry* entry, | 16 base::Value* NetLogEntryCreationCallback( |
17 bool created, | 17 const disk_cache::Entry* entry, |
18 net::NetLog::LogLevel /* log_level */) { | 18 bool created, |
19 DictionaryValue* dict = new DictionaryValue(); | 19 net::NetLog::LogLevel /* log_level */) { |
| 20 base::DictionaryValue* dict = new base::DictionaryValue(); |
20 dict->SetString("key", entry->GetKey()); | 21 dict->SetString("key", entry->GetKey()); |
21 dict->SetBoolean("created", created); | 22 dict->SetBoolean("created", created); |
22 return dict; | 23 return dict; |
23 } | 24 } |
24 | 25 |
25 Value* NetLogReadWriteDataCallback(int index, | 26 base::Value* NetLogReadWriteDataCallback( |
26 int offset, | 27 int index, |
27 int buf_len, | 28 int offset, |
28 bool truncate, | 29 int buf_len, |
29 net::NetLog::LogLevel /* log_level */) { | 30 bool truncate, |
30 DictionaryValue* dict = new DictionaryValue(); | 31 net::NetLog::LogLevel /* log_level */) { |
| 32 base::DictionaryValue* dict = new base::DictionaryValue(); |
31 dict->SetInteger("index", index); | 33 dict->SetInteger("index", index); |
32 dict->SetInteger("offset", offset); | 34 dict->SetInteger("offset", offset); |
33 dict->SetInteger("buf_len", buf_len); | 35 dict->SetInteger("buf_len", buf_len); |
34 if (truncate) | 36 if (truncate) |
35 dict->SetBoolean("truncate", truncate); | 37 dict->SetBoolean("truncate", truncate); |
36 return dict; | 38 return dict; |
37 } | 39 } |
38 | 40 |
39 Value* NetLogReadWriteCompleteCallback(int bytes_copied, | 41 base::Value* NetLogReadWriteCompleteCallback( |
40 net::NetLog::LogLevel /* log_level */) { | 42 int bytes_copied, |
| 43 net::NetLog::LogLevel /* log_level */) { |
41 DCHECK_NE(bytes_copied, net::ERR_IO_PENDING); | 44 DCHECK_NE(bytes_copied, net::ERR_IO_PENDING); |
42 DictionaryValue* dict = new DictionaryValue(); | 45 base::DictionaryValue* dict = new base::DictionaryValue(); |
43 if (bytes_copied < 0) { | 46 if (bytes_copied < 0) { |
44 dict->SetInteger("net_error", bytes_copied); | 47 dict->SetInteger("net_error", bytes_copied); |
45 } else { | 48 } else { |
46 dict->SetInteger("bytes_copied", bytes_copied); | 49 dict->SetInteger("bytes_copied", bytes_copied); |
47 } | 50 } |
48 return dict; | 51 return dict; |
49 } | 52 } |
50 | 53 |
51 Value* NetLogSparseOperationCallback(int64 offset, | 54 base::Value* NetLogSparseOperationCallback( |
52 int buff_len, | 55 int64 offset, |
53 net::NetLog::LogLevel /* log_level */) { | 56 int buff_len, |
54 DictionaryValue* dict = new DictionaryValue(); | 57 net::NetLog::LogLevel /* log_level */) { |
| 58 base::DictionaryValue* dict = new base::DictionaryValue(); |
55 // Values can only be created with at most 32-bit integers. Using a string | 59 // Values can only be created with at most 32-bit integers. Using a string |
56 // instead circumvents that restriction. | 60 // instead circumvents that restriction. |
57 dict->SetString("offset", base::Int64ToString(offset)); | 61 dict->SetString("offset", base::Int64ToString(offset)); |
58 dict->SetInteger("buff_len", buff_len); | 62 dict->SetInteger("buff_len", buff_len); |
59 return dict; | 63 return dict; |
60 } | 64 } |
61 | 65 |
62 Value* NetLogSparseReadWriteCallback(const net::NetLog::Source& source, | 66 base::Value* NetLogSparseReadWriteCallback( |
63 int child_len, | 67 const net::NetLog::Source& source, |
64 net::NetLog::LogLevel /* log_level */) { | 68 int child_len, |
65 DictionaryValue* dict = new DictionaryValue(); | 69 net::NetLog::LogLevel /* log_level */) { |
| 70 base::DictionaryValue* dict = new base::DictionaryValue(); |
66 source.AddToEventParameters(dict); | 71 source.AddToEventParameters(dict); |
67 dict->SetInteger("child_len", child_len); | 72 dict->SetInteger("child_len", child_len); |
68 return dict; | 73 return dict; |
69 } | 74 } |
70 | 75 |
71 Value* NetLogGetAvailableRangeResultCallback( | 76 base::Value* NetLogGetAvailableRangeResultCallback( |
72 int64 start, | 77 int64 start, |
73 int result, | 78 int result, |
74 net::NetLog::LogLevel /* log_level */) { | 79 net::NetLog::LogLevel /* log_level */) { |
75 DictionaryValue* dict = new DictionaryValue(); | 80 base::DictionaryValue* dict = new base::DictionaryValue(); |
76 if (result > 0) { | 81 if (result > 0) { |
77 dict->SetInteger("length", result); | 82 dict->SetInteger("length", result); |
78 dict->SetString("start", base::Int64ToString(start)); | 83 dict->SetString("start", base::Int64ToString(start)); |
79 } else { | 84 } else { |
80 dict->SetInteger("net_error", result); | 85 dict->SetInteger("net_error", result); |
81 } | 86 } |
82 return dict; | 87 return dict; |
83 } | 88 } |
84 | 89 |
85 } // namespace | 90 } // namespace |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 return base::Bind(&NetLogSparseReadWriteCallback, source, child_len); | 124 return base::Bind(&NetLogSparseReadWriteCallback, source, child_len); |
120 } | 125 } |
121 | 126 |
122 net::NetLog::ParametersCallback CreateNetLogGetAvailableRangeResultCallback( | 127 net::NetLog::ParametersCallback CreateNetLogGetAvailableRangeResultCallback( |
123 int64 start, | 128 int64 start, |
124 int result) { | 129 int result) { |
125 return base::Bind(&NetLogGetAvailableRangeResultCallback, start, result); | 130 return base::Bind(&NetLogGetAvailableRangeResultCallback, start, result); |
126 } | 131 } |
127 | 132 |
128 } // namespace disk_cache | 133 } // namespace disk_cache |
OLD | NEW |