| 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> |
| 8 |
| 7 #include "base/bind.h" | 9 #include "base/bind.h" |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/values.h" | 12 #include "base/values.h" |
| 11 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
| 12 #include "net/disk_cache/disk_cache.h" | 14 #include "net/disk_cache/disk_cache.h" |
| 13 | 15 |
| 14 namespace { | 16 namespace { |
| 15 | 17 |
| 16 scoped_ptr<base::Value> NetLogEntryCreationCallback( | 18 scoped_ptr<base::Value> NetLogEntryCreationCallback( |
| 17 const disk_cache::Entry* entry, | 19 const disk_cache::Entry* entry, |
| 18 bool created, | 20 bool created, |
| 19 net::NetLogCaptureMode /* capture_mode */) { | 21 net::NetLogCaptureMode /* capture_mode */) { |
| 20 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 22 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 21 dict->SetString("key", entry->GetKey()); | 23 dict->SetString("key", entry->GetKey()); |
| 22 dict->SetBoolean("created", created); | 24 dict->SetBoolean("created", created); |
| 23 return dict.Pass(); | 25 return std::move(dict); |
| 24 } | 26 } |
| 25 | 27 |
| 26 scoped_ptr<base::Value> NetLogReadWriteDataCallback( | 28 scoped_ptr<base::Value> NetLogReadWriteDataCallback( |
| 27 int index, | 29 int index, |
| 28 int offset, | 30 int offset, |
| 29 int buf_len, | 31 int buf_len, |
| 30 bool truncate, | 32 bool truncate, |
| 31 net::NetLogCaptureMode /* capture_mode */) { | 33 net::NetLogCaptureMode /* capture_mode */) { |
| 32 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 34 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 33 dict->SetInteger("index", index); | 35 dict->SetInteger("index", index); |
| 34 dict->SetInteger("offset", offset); | 36 dict->SetInteger("offset", offset); |
| 35 dict->SetInteger("buf_len", buf_len); | 37 dict->SetInteger("buf_len", buf_len); |
| 36 if (truncate) | 38 if (truncate) |
| 37 dict->SetBoolean("truncate", truncate); | 39 dict->SetBoolean("truncate", truncate); |
| 38 return dict.Pass(); | 40 return std::move(dict); |
| 39 } | 41 } |
| 40 | 42 |
| 41 scoped_ptr<base::Value> NetLogReadWriteCompleteCallback( | 43 scoped_ptr<base::Value> NetLogReadWriteCompleteCallback( |
| 42 int bytes_copied, | 44 int bytes_copied, |
| 43 net::NetLogCaptureMode /* capture_mode */) { | 45 net::NetLogCaptureMode /* capture_mode */) { |
| 44 DCHECK_NE(bytes_copied, net::ERR_IO_PENDING); | 46 DCHECK_NE(bytes_copied, net::ERR_IO_PENDING); |
| 45 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 47 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 46 if (bytes_copied < 0) { | 48 if (bytes_copied < 0) { |
| 47 dict->SetInteger("net_error", bytes_copied); | 49 dict->SetInteger("net_error", bytes_copied); |
| 48 } else { | 50 } else { |
| 49 dict->SetInteger("bytes_copied", bytes_copied); | 51 dict->SetInteger("bytes_copied", bytes_copied); |
| 50 } | 52 } |
| 51 return dict.Pass(); | 53 return std::move(dict); |
| 52 } | 54 } |
| 53 | 55 |
| 54 scoped_ptr<base::Value> NetLogSparseOperationCallback( | 56 scoped_ptr<base::Value> NetLogSparseOperationCallback( |
| 55 int64_t offset, | 57 int64_t offset, |
| 56 int buf_len, | 58 int buf_len, |
| 57 net::NetLogCaptureMode /* capture_mode */) { | 59 net::NetLogCaptureMode /* capture_mode */) { |
| 58 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 60 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 59 // Values can only be created with at most 32-bit integers. Using a string | 61 // Values can only be created with at most 32-bit integers. Using a string |
| 60 // instead circumvents that restriction. | 62 // instead circumvents that restriction. |
| 61 dict->SetString("offset", base::Int64ToString(offset)); | 63 dict->SetString("offset", base::Int64ToString(offset)); |
| 62 dict->SetInteger("buf_len", buf_len); | 64 dict->SetInteger("buf_len", buf_len); |
| 63 return dict.Pass(); | 65 return std::move(dict); |
| 64 } | 66 } |
| 65 | 67 |
| 66 scoped_ptr<base::Value> NetLogSparseReadWriteCallback( | 68 scoped_ptr<base::Value> NetLogSparseReadWriteCallback( |
| 67 const net::NetLog::Source& source, | 69 const net::NetLog::Source& source, |
| 68 int child_len, | 70 int child_len, |
| 69 net::NetLogCaptureMode /* capture_mode */) { | 71 net::NetLogCaptureMode /* capture_mode */) { |
| 70 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 72 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 71 source.AddToEventParameters(dict.get()); | 73 source.AddToEventParameters(dict.get()); |
| 72 dict->SetInteger("child_len", child_len); | 74 dict->SetInteger("child_len", child_len); |
| 73 return dict.Pass(); | 75 return std::move(dict); |
| 74 } | 76 } |
| 75 | 77 |
| 76 scoped_ptr<base::Value> NetLogGetAvailableRangeResultCallback( | 78 scoped_ptr<base::Value> NetLogGetAvailableRangeResultCallback( |
| 77 int64_t start, | 79 int64_t start, |
| 78 int result, | 80 int result, |
| 79 net::NetLogCaptureMode /* capture_mode */) { | 81 net::NetLogCaptureMode /* capture_mode */) { |
| 80 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 82 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| 81 if (result > 0) { | 83 if (result > 0) { |
| 82 dict->SetInteger("length", result); | 84 dict->SetInteger("length", result); |
| 83 dict->SetString("start", base::Int64ToString(start)); | 85 dict->SetString("start", base::Int64ToString(start)); |
| 84 } else { | 86 } else { |
| 85 dict->SetInteger("net_error", result); | 87 dict->SetInteger("net_error", result); |
| 86 } | 88 } |
| 87 return dict.Pass(); | 89 return std::move(dict); |
| 88 } | 90 } |
| 89 | 91 |
| 90 } // namespace | 92 } // namespace |
| 91 | 93 |
| 92 namespace disk_cache { | 94 namespace disk_cache { |
| 93 | 95 |
| 94 net::NetLog::ParametersCallback CreateNetLogEntryCreationCallback( | 96 net::NetLog::ParametersCallback CreateNetLogEntryCreationCallback( |
| 95 const Entry* entry, | 97 const Entry* entry, |
| 96 bool created) { | 98 bool created) { |
| 97 DCHECK(entry); | 99 DCHECK(entry); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 124 return base::Bind(&NetLogSparseReadWriteCallback, source, child_len); | 126 return base::Bind(&NetLogSparseReadWriteCallback, source, child_len); |
| 125 } | 127 } |
| 126 | 128 |
| 127 net::NetLog::ParametersCallback CreateNetLogGetAvailableRangeResultCallback( | 129 net::NetLog::ParametersCallback CreateNetLogGetAvailableRangeResultCallback( |
| 128 int64_t start, | 130 int64_t start, |
| 129 int result) { | 131 int result) { |
| 130 return base::Bind(&NetLogGetAvailableRangeResultCallback, start, result); | 132 return base::Bind(&NetLogGetAvailableRangeResultCallback, start, result); |
| 131 } | 133 } |
| 132 | 134 |
| 133 } // namespace disk_cache | 135 } // namespace disk_cache |
| OLD | NEW |