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 <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
14 #include "net/disk_cache/disk_cache.h" | 14 #include "net/disk_cache/disk_cache.h" |
| 15 #include "net/log/net_log_capture_mode.h" |
| 16 #include "net/log/net_log_source.h" |
15 | 17 |
16 namespace { | 18 namespace { |
17 | 19 |
18 std::unique_ptr<base::Value> NetLogEntryCreationCallback( | 20 std::unique_ptr<base::Value> NetLogEntryCreationCallback( |
19 const disk_cache::Entry* entry, | 21 const disk_cache::Entry* entry, |
20 bool created, | 22 bool created, |
21 net::NetLogCaptureMode /* capture_mode */) { | 23 net::NetLogCaptureMode /* capture_mode */) { |
22 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 24 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
23 dict->SetString("key", entry->GetKey()); | 25 dict->SetString("key", entry->GetKey()); |
24 dict->SetBoolean("created", created); | 26 dict->SetBoolean("created", created); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 net::NetLogCaptureMode /* capture_mode */) { | 61 net::NetLogCaptureMode /* capture_mode */) { |
60 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 62 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
61 // Values can only be created with at most 32-bit integers. Using a string | 63 // Values can only be created with at most 32-bit integers. Using a string |
62 // instead circumvents that restriction. | 64 // instead circumvents that restriction. |
63 dict->SetString("offset", base::Int64ToString(offset)); | 65 dict->SetString("offset", base::Int64ToString(offset)); |
64 dict->SetInteger("buf_len", buf_len); | 66 dict->SetInteger("buf_len", buf_len); |
65 return std::move(dict); | 67 return std::move(dict); |
66 } | 68 } |
67 | 69 |
68 std::unique_ptr<base::Value> NetLogSparseReadWriteCallback( | 70 std::unique_ptr<base::Value> NetLogSparseReadWriteCallback( |
69 const net::NetLog::Source& source, | 71 const net::NetLogSource& source, |
70 int child_len, | 72 int child_len, |
71 net::NetLogCaptureMode /* capture_mode */) { | 73 net::NetLogCaptureMode /* capture_mode */) { |
72 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 74 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
73 source.AddToEventParameters(dict.get()); | 75 source.AddToEventParameters(dict.get()); |
74 dict->SetInteger("child_len", child_len); | 76 dict->SetInteger("child_len", child_len); |
75 return std::move(dict); | 77 return std::move(dict); |
76 } | 78 } |
77 | 79 |
78 std::unique_ptr<base::Value> NetLogGetAvailableRangeResultCallback( | 80 std::unique_ptr<base::Value> NetLogGetAvailableRangeResultCallback( |
79 int64_t start, | 81 int64_t start, |
80 int result, | 82 int result, |
81 net::NetLogCaptureMode /* capture_mode */) { | 83 net::NetLogCaptureMode /* capture_mode */) { |
82 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 84 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
83 if (result > 0) { | 85 if (result > 0) { |
84 dict->SetInteger("length", result); | 86 dict->SetInteger("length", result); |
85 dict->SetString("start", base::Int64ToString(start)); | 87 dict->SetString("start", base::Int64ToString(start)); |
86 } else { | 88 } else { |
87 dict->SetInteger("net_error", result); | 89 dict->SetInteger("net_error", result); |
88 } | 90 } |
89 return std::move(dict); | 91 return std::move(dict); |
90 } | 92 } |
91 | 93 |
92 } // namespace | 94 } // namespace |
93 | 95 |
94 namespace disk_cache { | 96 namespace disk_cache { |
95 | 97 |
96 net::NetLog::ParametersCallback CreateNetLogEntryCreationCallback( | 98 net::NetLogParametersCallback CreateNetLogEntryCreationCallback( |
97 const Entry* entry, | 99 const Entry* entry, |
98 bool created) { | 100 bool created) { |
99 DCHECK(entry); | 101 DCHECK(entry); |
100 return base::Bind(&NetLogEntryCreationCallback, entry, created); | 102 return base::Bind(&NetLogEntryCreationCallback, entry, created); |
101 } | 103 } |
102 | 104 |
103 net::NetLog::ParametersCallback CreateNetLogReadWriteDataCallback( | 105 net::NetLogParametersCallback CreateNetLogReadWriteDataCallback(int index, |
104 int index, | 106 int offset, |
105 int offset, | 107 int buf_len, |
106 int buf_len, | 108 bool truncate) { |
107 bool truncate) { | |
108 return base::Bind(&NetLogReadWriteDataCallback, | 109 return base::Bind(&NetLogReadWriteDataCallback, |
109 index, offset, buf_len, truncate); | 110 index, offset, buf_len, truncate); |
110 } | 111 } |
111 | 112 |
112 net::NetLog::ParametersCallback CreateNetLogReadWriteCompleteCallback( | 113 net::NetLogParametersCallback CreateNetLogReadWriteCompleteCallback( |
113 int bytes_copied) { | 114 int bytes_copied) { |
114 return base::Bind(&NetLogReadWriteCompleteCallback, bytes_copied); | 115 return base::Bind(&NetLogReadWriteCompleteCallback, bytes_copied); |
115 } | 116 } |
116 | 117 |
117 net::NetLog::ParametersCallback CreateNetLogSparseOperationCallback( | 118 net::NetLogParametersCallback CreateNetLogSparseOperationCallback( |
118 int64_t offset, | 119 int64_t offset, |
119 int buf_len) { | 120 int buf_len) { |
120 return base::Bind(&NetLogSparseOperationCallback, offset, buf_len); | 121 return base::Bind(&NetLogSparseOperationCallback, offset, buf_len); |
121 } | 122 } |
122 | 123 |
123 net::NetLog::ParametersCallback CreateNetLogSparseReadWriteCallback( | 124 net::NetLogParametersCallback CreateNetLogSparseReadWriteCallback( |
124 const net::NetLog::Source& source, | 125 const net::NetLogSource& source, |
125 int child_len) { | 126 int child_len) { |
126 return base::Bind(&NetLogSparseReadWriteCallback, source, child_len); | 127 return base::Bind(&NetLogSparseReadWriteCallback, source, child_len); |
127 } | 128 } |
128 | 129 |
129 net::NetLog::ParametersCallback CreateNetLogGetAvailableRangeResultCallback( | 130 net::NetLogParametersCallback CreateNetLogGetAvailableRangeResultCallback( |
130 int64_t start, | 131 int64_t start, |
131 int result) { | 132 int result) { |
132 return base::Bind(&NetLogGetAvailableRangeResultCallback, start, result); | 133 return base::Bind(&NetLogGetAvailableRangeResultCallback, start, result); |
133 } | 134 } |
134 | 135 |
135 } // namespace disk_cache | 136 } // namespace disk_cache |
OLD | NEW |