OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_number_conversions.h" | 8 #include "base/string_number_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
11 | 11 |
12 namespace disk_cache { | 12 namespace disk_cache { |
13 | 13 |
14 EntryCreationParameters::EntryCreationParameters( | 14 EntryCreationParameters::EntryCreationParameters( |
15 const std::string& key, bool created) | 15 const std::string& key, |
16 : key_(key), created_(created) { | 16 bool created) |
| 17 : key_(key), |
| 18 created_(created) { |
17 } | 19 } |
18 | 20 |
19 Value* EntryCreationParameters::ToValue() const { | 21 Value* EntryCreationParameters::ToValue() const { |
20 DictionaryValue* dict = new DictionaryValue(); | 22 DictionaryValue* dict = new DictionaryValue(); |
21 dict->SetString("key", key_); | 23 dict->SetString("key", key_); |
22 dict->SetBoolean("created", created_); | 24 dict->SetBoolean("created", created_); |
23 return dict; | 25 return dict; |
24 } | 26 } |
25 | 27 |
| 28 EntryCreationParameters::~EntryCreationParameters() {} |
| 29 |
26 ReadWriteDataParameters::ReadWriteDataParameters( | 30 ReadWriteDataParameters::ReadWriteDataParameters( |
27 int index, int offset, int buf_len, bool truncate) | 31 int index, |
28 : index_(index), offset_(offset), buf_len_(buf_len), truncate_(truncate) { | 32 int offset, |
| 33 int buf_len, |
| 34 bool truncate) |
| 35 : index_(index), |
| 36 offset_(offset), |
| 37 buf_len_(buf_len), |
| 38 truncate_(truncate) { |
29 } | 39 } |
30 | 40 |
31 Value* ReadWriteDataParameters::ToValue() const { | 41 Value* ReadWriteDataParameters::ToValue() const { |
32 DictionaryValue* dict = new DictionaryValue(); | 42 DictionaryValue* dict = new DictionaryValue(); |
33 dict->SetInteger("index", index_); | 43 dict->SetInteger("index", index_); |
34 dict->SetInteger("offset", offset_); | 44 dict->SetInteger("offset", offset_); |
35 dict->SetInteger("buf_len", buf_len_); | 45 dict->SetInteger("buf_len", buf_len_); |
36 if (truncate_) | 46 if (truncate_) |
37 dict->SetBoolean("truncate", truncate_); | 47 dict->SetBoolean("truncate", truncate_); |
38 return dict; | 48 return dict; |
39 } | 49 } |
40 | 50 |
| 51 ReadWriteDataParameters::~ReadWriteDataParameters() {} |
41 | 52 |
42 // NetLog parameters logged when non-sparse reads and writes complete. | 53 // NetLog parameters logged when non-sparse reads and writes complete. |
43 ReadWriteCompleteParameters::ReadWriteCompleteParameters(int bytes_copied) | 54 ReadWriteCompleteParameters::ReadWriteCompleteParameters(int bytes_copied) |
44 : bytes_copied_(bytes_copied) { | 55 : bytes_copied_(bytes_copied) { |
45 } | 56 } |
46 | 57 |
47 Value* ReadWriteCompleteParameters::ToValue() const { | 58 Value* ReadWriteCompleteParameters::ToValue() const { |
48 DCHECK_NE(bytes_copied_, net::ERR_IO_PENDING); | 59 DCHECK_NE(bytes_copied_, net::ERR_IO_PENDING); |
49 DictionaryValue* dict = new DictionaryValue(); | 60 DictionaryValue* dict = new DictionaryValue(); |
50 if (bytes_copied_ < 0) { | 61 if (bytes_copied_ < 0) { |
51 dict->SetInteger("net_error", bytes_copied_); | 62 dict->SetInteger("net_error", bytes_copied_); |
52 } else { | 63 } else { |
53 dict->SetInteger("bytes_copied", bytes_copied_); | 64 dict->SetInteger("bytes_copied", bytes_copied_); |
54 } | 65 } |
55 return dict; | 66 return dict; |
56 } | 67 } |
57 | 68 |
| 69 ReadWriteCompleteParameters::~ReadWriteCompleteParameters() {} |
| 70 |
58 SparseOperationParameters::SparseOperationParameters( | 71 SparseOperationParameters::SparseOperationParameters( |
59 int64 offset, int buff_len) | 72 int64 offset, |
60 : offset_(offset), buff_len_(buff_len) { | 73 int buff_len) |
| 74 : offset_(offset), |
| 75 buff_len_(buff_len) { |
61 } | 76 } |
62 | 77 |
63 Value* SparseOperationParameters::ToValue() const { | 78 Value* SparseOperationParameters::ToValue() const { |
64 DictionaryValue* dict = new DictionaryValue(); | 79 DictionaryValue* dict = new DictionaryValue(); |
65 // Values can only be created with at most 32-bit integers. Using a string | 80 // Values can only be created with at most 32-bit integers. Using a string |
66 // instead circumvents that restriction. | 81 // instead circumvents that restriction. |
67 dict->SetString("offset", base::Int64ToString(offset_)); | 82 dict->SetString("offset", base::Int64ToString(offset_)); |
68 dict->SetInteger("buff_len", buff_len_); | 83 dict->SetInteger("buff_len", buff_len_); |
69 return dict; | 84 return dict; |
70 } | 85 } |
71 | 86 |
| 87 SparseOperationParameters::~SparseOperationParameters() {} |
| 88 |
72 SparseReadWriteParameters::SparseReadWriteParameters( | 89 SparseReadWriteParameters::SparseReadWriteParameters( |
73 const net::NetLog::Source& source, int child_len) | 90 const net::NetLog::Source& source, |
74 : source_(source), child_len_(child_len) { | 91 int child_len) |
| 92 : source_(source), |
| 93 child_len_(child_len) { |
75 } | 94 } |
76 | 95 |
77 Value* SparseReadWriteParameters::ToValue() const { | 96 Value* SparseReadWriteParameters::ToValue() const { |
78 DictionaryValue* dict = new DictionaryValue(); | 97 DictionaryValue* dict = new DictionaryValue(); |
79 dict->Set("source_dependency", source_.ToValue()); | 98 dict->Set("source_dependency", source_.ToValue()); |
80 dict->SetInteger("child_len", child_len_); | 99 dict->SetInteger("child_len", child_len_); |
81 return dict; | 100 return dict; |
82 } | 101 } |
83 | 102 |
| 103 SparseReadWriteParameters::~SparseReadWriteParameters() {} |
| 104 |
84 GetAvailableRangeResultParameters::GetAvailableRangeResultParameters( | 105 GetAvailableRangeResultParameters::GetAvailableRangeResultParameters( |
85 int64 start, int result) | 106 int64 start, |
86 : start_(start), result_(result) { | 107 int result) |
| 108 : start_(start), |
| 109 result_(result) { |
87 } | 110 } |
88 | 111 |
89 Value* GetAvailableRangeResultParameters::ToValue() const { | 112 Value* GetAvailableRangeResultParameters::ToValue() const { |
90 DictionaryValue* dict = new DictionaryValue(); | 113 DictionaryValue* dict = new DictionaryValue(); |
91 if (result_ > 0) { | 114 if (result_ > 0) { |
92 dict->SetInteger("length", result_); | 115 dict->SetInteger("length", result_); |
93 dict->SetString("start", base::Int64ToString(start_)); | 116 dict->SetString("start", base::Int64ToString(start_)); |
94 } else { | 117 } else { |
95 dict->SetInteger("net_error", result_); | 118 dict->SetInteger("net_error", result_); |
96 } | 119 } |
97 return dict; | 120 return dict; |
98 } | 121 } |
99 | 122 |
| 123 GetAvailableRangeResultParameters::~GetAvailableRangeResultParameters() {} |
| 124 |
100 } // namespace disk_cache | 125 } // namespace disk_cache |
OLD | NEW |