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" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 45 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
46 if (bytes_copied < 0) { | 46 if (bytes_copied < 0) { |
47 dict->SetInteger("net_error", bytes_copied); | 47 dict->SetInteger("net_error", bytes_copied); |
48 } else { | 48 } else { |
49 dict->SetInteger("bytes_copied", bytes_copied); | 49 dict->SetInteger("bytes_copied", bytes_copied); |
50 } | 50 } |
51 return dict.Pass(); | 51 return dict.Pass(); |
52 } | 52 } |
53 | 53 |
54 scoped_ptr<base::Value> NetLogSparseOperationCallback( | 54 scoped_ptr<base::Value> NetLogSparseOperationCallback( |
55 int64 offset, | 55 int64_t offset, |
56 int buf_len, | 56 int buf_len, |
57 net::NetLogCaptureMode /* capture_mode */) { | 57 net::NetLogCaptureMode /* capture_mode */) { |
58 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 58 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
59 // 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 |
60 // instead circumvents that restriction. | 60 // instead circumvents that restriction. |
61 dict->SetString("offset", base::Int64ToString(offset)); | 61 dict->SetString("offset", base::Int64ToString(offset)); |
62 dict->SetInteger("buf_len", buf_len); | 62 dict->SetInteger("buf_len", buf_len); |
63 return dict.Pass(); | 63 return dict.Pass(); |
64 } | 64 } |
65 | 65 |
66 scoped_ptr<base::Value> NetLogSparseReadWriteCallback( | 66 scoped_ptr<base::Value> NetLogSparseReadWriteCallback( |
67 const net::NetLog::Source& source, | 67 const net::NetLog::Source& source, |
68 int child_len, | 68 int child_len, |
69 net::NetLogCaptureMode /* capture_mode */) { | 69 net::NetLogCaptureMode /* capture_mode */) { |
70 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 70 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
71 source.AddToEventParameters(dict.get()); | 71 source.AddToEventParameters(dict.get()); |
72 dict->SetInteger("child_len", child_len); | 72 dict->SetInteger("child_len", child_len); |
73 return dict.Pass(); | 73 return dict.Pass(); |
74 } | 74 } |
75 | 75 |
76 scoped_ptr<base::Value> NetLogGetAvailableRangeResultCallback( | 76 scoped_ptr<base::Value> NetLogGetAvailableRangeResultCallback( |
77 int64 start, | 77 int64_t start, |
78 int result, | 78 int result, |
79 net::NetLogCaptureMode /* capture_mode */) { | 79 net::NetLogCaptureMode /* capture_mode */) { |
80 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 80 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
81 if (result > 0) { | 81 if (result > 0) { |
82 dict->SetInteger("length", result); | 82 dict->SetInteger("length", result); |
83 dict->SetString("start", base::Int64ToString(start)); | 83 dict->SetString("start", base::Int64ToString(start)); |
84 } else { | 84 } else { |
85 dict->SetInteger("net_error", result); | 85 dict->SetInteger("net_error", result); |
86 } | 86 } |
87 return dict.Pass(); | 87 return dict.Pass(); |
(...skipping 18 matching lines...) Expand all Loading... |
106 return base::Bind(&NetLogReadWriteDataCallback, | 106 return base::Bind(&NetLogReadWriteDataCallback, |
107 index, offset, buf_len, truncate); | 107 index, offset, buf_len, truncate); |
108 } | 108 } |
109 | 109 |
110 net::NetLog::ParametersCallback CreateNetLogReadWriteCompleteCallback( | 110 net::NetLog::ParametersCallback CreateNetLogReadWriteCompleteCallback( |
111 int bytes_copied) { | 111 int bytes_copied) { |
112 return base::Bind(&NetLogReadWriteCompleteCallback, bytes_copied); | 112 return base::Bind(&NetLogReadWriteCompleteCallback, bytes_copied); |
113 } | 113 } |
114 | 114 |
115 net::NetLog::ParametersCallback CreateNetLogSparseOperationCallback( | 115 net::NetLog::ParametersCallback CreateNetLogSparseOperationCallback( |
116 int64 offset, | 116 int64_t offset, |
117 int buf_len) { | 117 int buf_len) { |
118 return base::Bind(&NetLogSparseOperationCallback, offset, buf_len); | 118 return base::Bind(&NetLogSparseOperationCallback, offset, buf_len); |
119 } | 119 } |
120 | 120 |
121 net::NetLog::ParametersCallback CreateNetLogSparseReadWriteCallback( | 121 net::NetLog::ParametersCallback CreateNetLogSparseReadWriteCallback( |
122 const net::NetLog::Source& source, | 122 const net::NetLog::Source& source, |
123 int child_len) { | 123 int child_len) { |
124 return base::Bind(&NetLogSparseReadWriteCallback, source, child_len); | 124 return base::Bind(&NetLogSparseReadWriteCallback, source, child_len); |
125 } | 125 } |
126 | 126 |
127 net::NetLog::ParametersCallback CreateNetLogGetAvailableRangeResultCallback( | 127 net::NetLog::ParametersCallback CreateNetLogGetAvailableRangeResultCallback( |
128 int64 start, | 128 int64_t start, |
129 int result) { | 129 int result) { |
130 return base::Bind(&NetLogGetAvailableRangeResultCallback, start, result); | 130 return base::Bind(&NetLogGetAvailableRangeResultCallback, start, result); |
131 } | 131 } |
132 | 132 |
133 } // namespace disk_cache | 133 } // namespace disk_cache |
OLD | NEW |