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 "content/browser/download/download_net_log_parameters.h" | 5 #include "content/browser/download/download_net_log_parameters.h" |
6 | 6 |
7 #include "base/basictypes.h" | |
8 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
9 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/macros.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "content/public/browser/download_interrupt_reasons.h" | 12 #include "content/public/browser/download_interrupt_reasons.h" |
13 #include "net/base/net_errors.h" | 13 #include "net/base/net_errors.h" |
14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 79 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
80 | 80 |
81 dict->SetString("old_filename", old_filename->AsUTF8Unsafe()); | 81 dict->SetString("old_filename", old_filename->AsUTF8Unsafe()); |
82 dict->SetString("new_filename", new_filename->AsUTF8Unsafe()); | 82 dict->SetString("new_filename", new_filename->AsUTF8Unsafe()); |
83 | 83 |
84 return dict.Pass(); | 84 return dict.Pass(); |
85 } | 85 } |
86 | 86 |
87 scoped_ptr<base::Value> ItemInterruptedNetLogCallback( | 87 scoped_ptr<base::Value> ItemInterruptedNetLogCallback( |
88 DownloadInterruptReason reason, | 88 DownloadInterruptReason reason, |
89 int64 bytes_so_far, | 89 int64_t bytes_so_far, |
90 const std::string* hash_state, | 90 const std::string* hash_state, |
91 net::NetLogCaptureMode capture_mode) { | 91 net::NetLogCaptureMode capture_mode) { |
92 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 92 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
93 | 93 |
94 dict->SetString("interrupt_reason", DownloadInterruptReasonToString(reason)); | 94 dict->SetString("interrupt_reason", DownloadInterruptReasonToString(reason)); |
95 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far)); | 95 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far)); |
96 dict->SetString("hash_state", | 96 dict->SetString("hash_state", |
97 base::HexEncode(hash_state->data(), hash_state->size())); | 97 base::HexEncode(hash_state->data(), hash_state->size())); |
98 | 98 |
99 return dict.Pass(); | 99 return dict.Pass(); |
100 } | 100 } |
101 | 101 |
102 scoped_ptr<base::Value> ItemResumingNetLogCallback( | 102 scoped_ptr<base::Value> ItemResumingNetLogCallback( |
103 bool user_initiated, | 103 bool user_initiated, |
104 DownloadInterruptReason reason, | 104 DownloadInterruptReason reason, |
105 int64 bytes_so_far, | 105 int64_t bytes_so_far, |
106 const std::string* hash_state, | 106 const std::string* hash_state, |
107 net::NetLogCaptureMode capture_mode) { | 107 net::NetLogCaptureMode capture_mode) { |
108 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 108 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
109 | 109 |
110 dict->SetString("user_initiated", user_initiated ? "true" : "false"); | 110 dict->SetString("user_initiated", user_initiated ? "true" : "false"); |
111 dict->SetString("interrupt_reason", DownloadInterruptReasonToString(reason)); | 111 dict->SetString("interrupt_reason", DownloadInterruptReasonToString(reason)); |
112 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far)); | 112 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far)); |
113 dict->SetString("hash_state", | 113 dict->SetString("hash_state", |
114 base::HexEncode(hash_state->data(), hash_state->size())); | 114 base::HexEncode(hash_state->data(), hash_state->size())); |
115 | 115 |
116 return dict.Pass(); | 116 return dict.Pass(); |
117 } | 117 } |
118 | 118 |
119 scoped_ptr<base::Value> ItemCompletingNetLogCallback( | 119 scoped_ptr<base::Value> ItemCompletingNetLogCallback( |
120 int64 bytes_so_far, | 120 int64_t bytes_so_far, |
121 const std::string* final_hash, | 121 const std::string* final_hash, |
122 net::NetLogCaptureMode capture_mode) { | 122 net::NetLogCaptureMode capture_mode) { |
123 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 123 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
124 | 124 |
125 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far)); | 125 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far)); |
126 dict->SetString("final_hash", | 126 dict->SetString("final_hash", |
127 base::HexEncode(final_hash->data(), final_hash->size())); | 127 base::HexEncode(final_hash->data(), final_hash->size())); |
128 | 128 |
129 return dict.Pass(); | 129 return dict.Pass(); |
130 } | 130 } |
131 | 131 |
132 scoped_ptr<base::Value> ItemFinishedNetLogCallback( | 132 scoped_ptr<base::Value> ItemFinishedNetLogCallback( |
133 bool auto_opened, | 133 bool auto_opened, |
134 net::NetLogCaptureMode capture_mode) { | 134 net::NetLogCaptureMode capture_mode) { |
135 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 135 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
136 | 136 |
137 dict->SetString("auto_opened", auto_opened ? "yes" : "no"); | 137 dict->SetString("auto_opened", auto_opened ? "yes" : "no"); |
138 | 138 |
139 return dict.Pass(); | 139 return dict.Pass(); |
140 } | 140 } |
141 | 141 |
142 scoped_ptr<base::Value> ItemCanceledNetLogCallback( | 142 scoped_ptr<base::Value> ItemCanceledNetLogCallback( |
143 int64 bytes_so_far, | 143 int64_t bytes_so_far, |
144 const std::string* hash_state, | 144 const std::string* hash_state, |
145 net::NetLogCaptureMode capture_mode) { | 145 net::NetLogCaptureMode capture_mode) { |
146 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 146 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
147 | 147 |
148 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far)); | 148 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far)); |
149 dict->SetString("hash_state", | 149 dict->SetString("hash_state", |
150 base::HexEncode(hash_state->data(), hash_state->size())); | 150 base::HexEncode(hash_state->data(), hash_state->size())); |
151 | 151 |
152 return dict.Pass(); | 152 return dict.Pass(); |
153 } | 153 } |
154 | 154 |
155 scoped_ptr<base::Value> FileOpenedNetLogCallback( | 155 scoped_ptr<base::Value> FileOpenedNetLogCallback( |
156 const base::FilePath* file_name, | 156 const base::FilePath* file_name, |
157 int64 start_offset, | 157 int64_t start_offset, |
158 net::NetLogCaptureMode capture_mode) { | 158 net::NetLogCaptureMode capture_mode) { |
159 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 159 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
160 | 160 |
161 dict->SetString("file_name", file_name->AsUTF8Unsafe()); | 161 dict->SetString("file_name", file_name->AsUTF8Unsafe()); |
162 dict->SetString("start_offset", base::Int64ToString(start_offset)); | 162 dict->SetString("start_offset", base::Int64ToString(start_offset)); |
163 | 163 |
164 return dict.Pass(); | 164 return dict.Pass(); |
165 } | 165 } |
166 | 166 |
167 scoped_ptr<base::Value> FileStreamDrainedNetLogCallback( | 167 scoped_ptr<base::Value> FileStreamDrainedNetLogCallback( |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 209 |
210 dict->SetString("operation", operation); | 210 dict->SetString("operation", operation); |
211 if (os_error != 0) | 211 if (os_error != 0) |
212 dict->SetInteger("os_error", os_error); | 212 dict->SetInteger("os_error", os_error); |
213 dict->SetString("interrupt_reason", DownloadInterruptReasonToString(reason)); | 213 dict->SetString("interrupt_reason", DownloadInterruptReasonToString(reason)); |
214 | 214 |
215 return dict.Pass(); | 215 return dict.Pass(); |
216 } | 216 } |
217 | 217 |
218 } // namespace content | 218 } // namespace content |
OLD | NEW |