Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1185)

Side by Side Diff: content/browser/download/download_net_log_parameters.cc

Issue 1059843002: Refactor NetLog::LogLevel --> NetLogCaptureMode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again to fix a merge conflict Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" 7 #include "base/basictypes.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 23 matching lines...) Expand all
34 "POTENTIALLY_UNWANTED" 34 "POTENTIALLY_UNWANTED"
35 }; 35 };
36 36
37 static_assert(arraysize(download_type_names) == SRC_SAVE_PAGE_AS + 1, 37 static_assert(arraysize(download_type_names) == SRC_SAVE_PAGE_AS + 1,
38 "download type enum has changed"); 38 "download type enum has changed");
39 static_assert(arraysize(download_danger_names) == DOWNLOAD_DANGER_TYPE_MAX, 39 static_assert(arraysize(download_danger_names) == DOWNLOAD_DANGER_TYPE_MAX,
40 "download danger enum has changed"); 40 "download danger enum has changed");
41 41
42 } // namespace 42 } // namespace
43 43
44 base::Value* ItemActivatedNetLogCallback( 44 base::Value* ItemActivatedNetLogCallback(const DownloadItem* download_item,
45 const DownloadItem* download_item, 45 DownloadType download_type,
46 DownloadType download_type, 46 const std::string* file_name,
47 const std::string* file_name, 47 net::NetLogCaptureMode capture_mode) {
48 net::NetLog::LogLevel log_level) {
49 base::DictionaryValue* dict = new base::DictionaryValue(); 48 base::DictionaryValue* dict = new base::DictionaryValue();
50 49
51 dict->SetString("type", download_type_names[download_type]); 50 dict->SetString("type", download_type_names[download_type]);
52 dict->SetString("id", base::Int64ToString(download_item->GetId())); 51 dict->SetString("id", base::Int64ToString(download_item->GetId()));
53 dict->SetString("original_url", download_item->GetOriginalUrl().spec()); 52 dict->SetString("original_url", download_item->GetOriginalUrl().spec());
54 dict->SetString("final_url", download_item->GetURL().spec()); 53 dict->SetString("final_url", download_item->GetURL().spec());
55 dict->SetString("file_name", *file_name); 54 dict->SetString("file_name", *file_name);
56 dict->SetString("danger_type", 55 dict->SetString("danger_type",
57 download_danger_names[download_item->GetDangerType()]); 56 download_danger_names[download_item->GetDangerType()]);
58 dict->SetString("start_offset", 57 dict->SetString("start_offset",
59 base::Int64ToString(download_item->GetReceivedBytes())); 58 base::Int64ToString(download_item->GetReceivedBytes()));
60 dict->SetBoolean("has_user_gesture", download_item->HasUserGesture()); 59 dict->SetBoolean("has_user_gesture", download_item->HasUserGesture());
61 60
62 return dict; 61 return dict;
63 } 62 }
64 63
65 base::Value* ItemCheckedNetLogCallback( 64 base::Value* ItemCheckedNetLogCallback(DownloadDangerType danger_type,
66 DownloadDangerType danger_type, 65 net::NetLogCaptureMode capture_mode) {
67 net::NetLog::LogLevel log_level) {
68 base::DictionaryValue* dict = new base::DictionaryValue(); 66 base::DictionaryValue* dict = new base::DictionaryValue();
69 67
70 dict->SetString("danger_type", download_danger_names[danger_type]); 68 dict->SetString("danger_type", download_danger_names[danger_type]);
71 69
72 return dict; 70 return dict;
73 } 71 }
74 72
75 base::Value* ItemRenamedNetLogCallback(const base::FilePath* old_filename, 73 base::Value* ItemRenamedNetLogCallback(const base::FilePath* old_filename,
76 const base::FilePath* new_filename, 74 const base::FilePath* new_filename,
77 net::NetLog::LogLevel log_level) { 75 net::NetLogCaptureMode capture_mode) {
78 base::DictionaryValue* dict = new base::DictionaryValue(); 76 base::DictionaryValue* dict = new base::DictionaryValue();
79 77
80 dict->SetString("old_filename", old_filename->AsUTF8Unsafe()); 78 dict->SetString("old_filename", old_filename->AsUTF8Unsafe());
81 dict->SetString("new_filename", new_filename->AsUTF8Unsafe()); 79 dict->SetString("new_filename", new_filename->AsUTF8Unsafe());
82 80
83 return dict; 81 return dict;
84 } 82 }
85 83
86 base::Value* ItemInterruptedNetLogCallback(DownloadInterruptReason reason, 84 base::Value* ItemInterruptedNetLogCallback(
87 int64 bytes_so_far, 85 DownloadInterruptReason reason,
88 const std::string* hash_state, 86 int64 bytes_so_far,
89 net::NetLog::LogLevel log_level) { 87 const std::string* hash_state,
88 net::NetLogCaptureMode capture_mode) {
90 base::DictionaryValue* dict = new base::DictionaryValue(); 89 base::DictionaryValue* dict = new base::DictionaryValue();
91 90
92 dict->SetString("interrupt_reason", DownloadInterruptReasonToString(reason)); 91 dict->SetString("interrupt_reason", DownloadInterruptReasonToString(reason));
93 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far)); 92 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far));
94 dict->SetString("hash_state", 93 dict->SetString("hash_state",
95 base::HexEncode(hash_state->data(), hash_state->size())); 94 base::HexEncode(hash_state->data(), hash_state->size()));
96 95
97 return dict; 96 return dict;
98 } 97 }
99 98
100 base::Value* ItemResumingNetLogCallback(bool user_initiated, 99 base::Value* ItemResumingNetLogCallback(bool user_initiated,
101 DownloadInterruptReason reason, 100 DownloadInterruptReason reason,
102 int64 bytes_so_far, 101 int64 bytes_so_far,
103 const std::string* hash_state, 102 const std::string* hash_state,
104 net::NetLog::LogLevel log_level) { 103 net::NetLogCaptureMode capture_mode) {
105 base::DictionaryValue* dict = new base::DictionaryValue(); 104 base::DictionaryValue* dict = new base::DictionaryValue();
106 105
107 dict->SetString("user_initiated", user_initiated ? "true" : "false"); 106 dict->SetString("user_initiated", user_initiated ? "true" : "false");
108 dict->SetString("interrupt_reason", DownloadInterruptReasonToString(reason)); 107 dict->SetString("interrupt_reason", DownloadInterruptReasonToString(reason));
109 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far)); 108 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far));
110 dict->SetString("hash_state", 109 dict->SetString("hash_state",
111 base::HexEncode(hash_state->data(), hash_state->size())); 110 base::HexEncode(hash_state->data(), hash_state->size()));
112 111
113 return dict; 112 return dict;
114 } 113 }
115 114
116 base::Value* ItemCompletingNetLogCallback(int64 bytes_so_far, 115 base::Value* ItemCompletingNetLogCallback(int64 bytes_so_far,
117 const std::string* final_hash, 116 const std::string* final_hash,
118 net::NetLog::LogLevel log_level) { 117 net::NetLogCaptureMode capture_mode) {
119 base::DictionaryValue* dict = new base::DictionaryValue(); 118 base::DictionaryValue* dict = new base::DictionaryValue();
120 119
121 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far)); 120 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far));
122 dict->SetString("final_hash", 121 dict->SetString("final_hash",
123 base::HexEncode(final_hash->data(), final_hash->size())); 122 base::HexEncode(final_hash->data(), final_hash->size()));
124 123
125 return dict; 124 return dict;
126 } 125 }
127 126
128 base::Value* ItemFinishedNetLogCallback(bool auto_opened, 127 base::Value* ItemFinishedNetLogCallback(bool auto_opened,
129 net::NetLog::LogLevel log_level) { 128 net::NetLogCaptureMode capture_mode) {
130 base::DictionaryValue* dict = new base::DictionaryValue(); 129 base::DictionaryValue* dict = new base::DictionaryValue();
131 130
132 dict->SetString("auto_opened", auto_opened ? "yes" : "no"); 131 dict->SetString("auto_opened", auto_opened ? "yes" : "no");
133 132
134 return dict; 133 return dict;
135 } 134 }
136 135
137 base::Value* ItemCanceledNetLogCallback(int64 bytes_so_far, 136 base::Value* ItemCanceledNetLogCallback(int64 bytes_so_far,
138 const std::string* hash_state, 137 const std::string* hash_state,
139 net::NetLog::LogLevel log_level) { 138 net::NetLogCaptureMode capture_mode) {
140 base::DictionaryValue* dict = new base::DictionaryValue(); 139 base::DictionaryValue* dict = new base::DictionaryValue();
141 140
142 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far)); 141 dict->SetString("bytes_so_far", base::Int64ToString(bytes_so_far));
143 dict->SetString("hash_state", 142 dict->SetString("hash_state",
144 base::HexEncode(hash_state->data(), hash_state->size())); 143 base::HexEncode(hash_state->data(), hash_state->size()));
145 144
146 return dict; 145 return dict;
147 } 146 }
148 147
149 base::Value* FileOpenedNetLogCallback(const base::FilePath* file_name, 148 base::Value* FileOpenedNetLogCallback(const base::FilePath* file_name,
150 int64 start_offset, 149 int64 start_offset,
151 net::NetLog::LogLevel log_level) { 150 net::NetLogCaptureMode capture_mode) {
152 base::DictionaryValue* dict = new base::DictionaryValue(); 151 base::DictionaryValue* dict = new base::DictionaryValue();
153 152
154 dict->SetString("file_name", file_name->AsUTF8Unsafe()); 153 dict->SetString("file_name", file_name->AsUTF8Unsafe());
155 dict->SetString("start_offset", base::Int64ToString(start_offset)); 154 dict->SetString("start_offset", base::Int64ToString(start_offset));
156 155
157 return dict; 156 return dict;
158 } 157 }
159 158
160 base::Value* FileStreamDrainedNetLogCallback(size_t stream_size, 159 base::Value* FileStreamDrainedNetLogCallback(
161 size_t num_buffers, 160 size_t stream_size,
162 net::NetLog::LogLevel log_level) { 161 size_t num_buffers,
162 net::NetLogCaptureMode capture_mode) {
163 base::DictionaryValue* dict = new base::DictionaryValue(); 163 base::DictionaryValue* dict = new base::DictionaryValue();
164 164
165 dict->SetInteger("stream_size", static_cast<int>(stream_size)); 165 dict->SetInteger("stream_size", static_cast<int>(stream_size));
166 dict->SetInteger("num_buffers", static_cast<int>(num_buffers)); 166 dict->SetInteger("num_buffers", static_cast<int>(num_buffers));
167 167
168 return dict; 168 return dict;
169 } 169 }
170 170
171 base::Value* FileRenamedNetLogCallback(const base::FilePath* old_filename, 171 base::Value* FileRenamedNetLogCallback(const base::FilePath* old_filename,
172 const base::FilePath* new_filename, 172 const base::FilePath* new_filename,
173 net::NetLog::LogLevel log_level) { 173 net::NetLogCaptureMode capture_mode) {
174 base::DictionaryValue* dict = new base::DictionaryValue(); 174 base::DictionaryValue* dict = new base::DictionaryValue();
175 175
176 dict->SetString("old_filename", old_filename->AsUTF8Unsafe()); 176 dict->SetString("old_filename", old_filename->AsUTF8Unsafe());
177 dict->SetString("new_filename", new_filename->AsUTF8Unsafe()); 177 dict->SetString("new_filename", new_filename->AsUTF8Unsafe());
178 178
179 return dict; 179 return dict;
180 } 180 }
181 181
182 base::Value* FileErrorNetLogCallback(const char* operation, 182 base::Value* FileErrorNetLogCallback(const char* operation,
183 net::Error net_error, 183 net::Error net_error,
184 net::NetLog::LogLevel log_level) { 184 net::NetLogCaptureMode capture_mode) {
185 base::DictionaryValue* dict = new base::DictionaryValue(); 185 base::DictionaryValue* dict = new base::DictionaryValue();
186 186
187 dict->SetString("operation", operation); 187 dict->SetString("operation", operation);
188 dict->SetInteger("net_error", net_error); 188 dict->SetInteger("net_error", net_error);
189 189
190 return dict; 190 return dict;
191 } 191 }
192 192
193 base::Value* FileInterruptedNetLogCallback(const char* operation, 193 base::Value* FileInterruptedNetLogCallback(
194 int os_error, 194 const char* operation,
195 DownloadInterruptReason reason, 195 int os_error,
196 net::NetLog::LogLevel log_level) { 196 DownloadInterruptReason reason,
197 net::NetLogCaptureMode capture_mode) {
197 base::DictionaryValue* dict = new base::DictionaryValue(); 198 base::DictionaryValue* dict = new base::DictionaryValue();
198 199
199 dict->SetString("operation", operation); 200 dict->SetString("operation", operation);
200 if (os_error != 0) 201 if (os_error != 0)
201 dict->SetInteger("os_error", os_error); 202 dict->SetInteger("os_error", os_error);
202 dict->SetString("interrupt_reason", DownloadInterruptReasonToString(reason)); 203 dict->SetString("interrupt_reason", DownloadInterruptReasonToString(reason));
203 204
204 return dict; 205 return dict;
205 } 206 }
206 207
207 } // namespace content 208 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/download_net_log_parameters.h ('k') | content/browser/media/media_internals_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698