OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/log/net_log_util.h" | 5 #include "net/log/net_log_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return true; | 122 return true; |
123 if (request1->creation_time() > request2->creation_time()) | 123 if (request1->creation_time() > request2->creation_time()) |
124 return false; | 124 return false; |
125 // If requests were created at the same time, sort by ID. Mostly matters for | 125 // If requests were created at the same time, sort by ID. Mostly matters for |
126 // testing purposes. | 126 // testing purposes. |
127 return request1->identifier() < request2->identifier(); | 127 return request1->identifier() < request2->identifier(); |
128 } | 128 } |
129 | 129 |
130 // Returns a Value representing the state of a pre-existing URLRequest when | 130 // Returns a Value representing the state of a pre-existing URLRequest when |
131 // net-internals was opened. | 131 // net-internals was opened. |
132 scoped_ptr<base::Value> GetRequestStateAsValue(const net::URLRequest* request, | 132 std::unique_ptr<base::Value> GetRequestStateAsValue( |
133 NetLogCaptureMode capture_mode) { | 133 const net::URLRequest* request, |
| 134 NetLogCaptureMode capture_mode) { |
134 return request->GetStateAsValue(); | 135 return request->GetStateAsValue(); |
135 } | 136 } |
136 | 137 |
137 } // namespace | 138 } // namespace |
138 | 139 |
139 scoped_ptr<base::DictionaryValue> GetNetConstants() { | 140 std::unique_ptr<base::DictionaryValue> GetNetConstants() { |
140 scoped_ptr<base::DictionaryValue> constants_dict(new base::DictionaryValue()); | 141 std::unique_ptr<base::DictionaryValue> constants_dict( |
| 142 new base::DictionaryValue()); |
141 | 143 |
142 // Version of the file format. | 144 // Version of the file format. |
143 constants_dict->SetInteger("logFormatVersion", kLogFormatVersion); | 145 constants_dict->SetInteger("logFormatVersion", kLogFormatVersion); |
144 | 146 |
145 // Add a dictionary with information on the relationship between event type | 147 // Add a dictionary with information on the relationship between event type |
146 // enums and their symbolic names. | 148 // enums and their symbolic names. |
147 constants_dict->Set("logEventTypes", NetLog::GetEventTypesAsValue()); | 149 constants_dict->Set("logEventTypes", NetLog::GetEventTypesAsValue()); |
148 | 150 |
149 // Add a dictionary with information about the relationship between CertStatus | 151 // Add a dictionary with information about the relationship between CertStatus |
150 // flags and their symbolic names. | 152 // flags and their symbolic names. |
151 { | 153 { |
152 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 154 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
153 | 155 |
154 for (size_t i = 0; i < arraysize(kCertStatusFlags); i++) | 156 for (size_t i = 0; i < arraysize(kCertStatusFlags); i++) |
155 dict->SetInteger(kCertStatusFlags[i].name, kCertStatusFlags[i].constant); | 157 dict->SetInteger(kCertStatusFlags[i].name, kCertStatusFlags[i].constant); |
156 | 158 |
157 constants_dict->Set("certStatusFlag", std::move(dict)); | 159 constants_dict->Set("certStatusFlag", std::move(dict)); |
158 } | 160 } |
159 | 161 |
160 // Add a dictionary with information about the relationship between load flag | 162 // Add a dictionary with information about the relationship between load flag |
161 // enums and their symbolic names. | 163 // enums and their symbolic names. |
162 { | 164 { |
163 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 165 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
164 | 166 |
165 for (size_t i = 0; i < arraysize(kLoadFlags); i++) | 167 for (size_t i = 0; i < arraysize(kLoadFlags); i++) |
166 dict->SetInteger(kLoadFlags[i].name, kLoadFlags[i].constant); | 168 dict->SetInteger(kLoadFlags[i].name, kLoadFlags[i].constant); |
167 | 169 |
168 constants_dict->Set("loadFlag", std::move(dict)); | 170 constants_dict->Set("loadFlag", std::move(dict)); |
169 } | 171 } |
170 | 172 |
171 // Add a dictionary with information about the relationship between load state | 173 // Add a dictionary with information about the relationship between load state |
172 // enums and their symbolic names. | 174 // enums and their symbolic names. |
173 { | 175 { |
174 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 176 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
175 | 177 |
176 for (size_t i = 0; i < arraysize(kLoadStateTable); i++) | 178 for (size_t i = 0; i < arraysize(kLoadStateTable); i++) |
177 dict->SetInteger(kLoadStateTable[i].name, kLoadStateTable[i].constant); | 179 dict->SetInteger(kLoadStateTable[i].name, kLoadStateTable[i].constant); |
178 | 180 |
179 constants_dict->Set("loadState", std::move(dict)); | 181 constants_dict->Set("loadState", std::move(dict)); |
180 } | 182 } |
181 | 183 |
182 { | 184 { |
183 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 185 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
184 #define NET_INFO_SOURCE(label, string, value) \ | 186 #define NET_INFO_SOURCE(label, string, value) \ |
185 dict->SetInteger(string, NET_INFO_##label); | 187 dict->SetInteger(string, NET_INFO_##label); |
186 #include "net/base/net_info_source_list.h" | 188 #include "net/base/net_info_source_list.h" |
187 #undef NET_INFO_SOURCE | 189 #undef NET_INFO_SOURCE |
188 constants_dict->Set("netInfoSources", std::move(dict)); | 190 constants_dict->Set("netInfoSources", std::move(dict)); |
189 } | 191 } |
190 | 192 |
191 // Add information on the relationship between net error codes and their | 193 // Add information on the relationship between net error codes and their |
192 // symbolic names. | 194 // symbolic names. |
193 { | 195 { |
194 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 196 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
195 | 197 |
196 for (size_t i = 0; i < arraysize(kNetErrors); i++) | 198 for (size_t i = 0; i < arraysize(kNetErrors); i++) |
197 dict->SetInteger(ErrorToShortString(kNetErrors[i]), kNetErrors[i]); | 199 dict->SetInteger(ErrorToShortString(kNetErrors[i]), kNetErrors[i]); |
198 | 200 |
199 constants_dict->Set("netError", std::move(dict)); | 201 constants_dict->Set("netError", std::move(dict)); |
200 } | 202 } |
201 | 203 |
202 // Add information on the relationship between QUIC error codes and their | 204 // Add information on the relationship between QUIC error codes and their |
203 // symbolic names. | 205 // symbolic names. |
204 { | 206 { |
205 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 207 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
206 | 208 |
207 for (QuicErrorCode error = QUIC_NO_ERROR; error < QUIC_LAST_ERROR; | 209 for (QuicErrorCode error = QUIC_NO_ERROR; error < QUIC_LAST_ERROR; |
208 error = static_cast<QuicErrorCode>(error + 1)) { | 210 error = static_cast<QuicErrorCode>(error + 1)) { |
209 dict->SetInteger(QuicUtils::ErrorToString(error), | 211 dict->SetInteger(QuicUtils::ErrorToString(error), |
210 static_cast<int>(error)); | 212 static_cast<int>(error)); |
211 } | 213 } |
212 | 214 |
213 constants_dict->Set("quicError", std::move(dict)); | 215 constants_dict->Set("quicError", std::move(dict)); |
214 } | 216 } |
215 | 217 |
216 // Add information on the relationship between QUIC RST_STREAM error codes | 218 // Add information on the relationship between QUIC RST_STREAM error codes |
217 // and their symbolic names. | 219 // and their symbolic names. |
218 { | 220 { |
219 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 221 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
220 | 222 |
221 for (QuicRstStreamErrorCode error = QUIC_STREAM_NO_ERROR; | 223 for (QuicRstStreamErrorCode error = QUIC_STREAM_NO_ERROR; |
222 error < QUIC_STREAM_LAST_ERROR; | 224 error < QUIC_STREAM_LAST_ERROR; |
223 error = static_cast<QuicRstStreamErrorCode>(error + 1)) { | 225 error = static_cast<QuicRstStreamErrorCode>(error + 1)) { |
224 dict->SetInteger(QuicUtils::StreamErrorToString(error), | 226 dict->SetInteger(QuicUtils::StreamErrorToString(error), |
225 static_cast<int>(error)); | 227 static_cast<int>(error)); |
226 } | 228 } |
227 | 229 |
228 constants_dict->Set("quicRstStreamError", std::move(dict)); | 230 constants_dict->Set("quicRstStreamError", std::move(dict)); |
229 } | 231 } |
230 | 232 |
231 // Add information on the relationship between SDCH problem codes and their | 233 // Add information on the relationship between SDCH problem codes and their |
232 // symbolic names. | 234 // symbolic names. |
233 { | 235 { |
234 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 236 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
235 | 237 |
236 for (size_t i = 0; i < arraysize(kSdchProblems); i++) | 238 for (size_t i = 0; i < arraysize(kSdchProblems); i++) |
237 dict->SetInteger(kSdchProblems[i].name, kSdchProblems[i].constant); | 239 dict->SetInteger(kSdchProblems[i].name, kSdchProblems[i].constant); |
238 | 240 |
239 constants_dict->Set("sdchProblemCode", std::move(dict)); | 241 constants_dict->Set("sdchProblemCode", std::move(dict)); |
240 } | 242 } |
241 | 243 |
242 // Information about the relationship between event phase enums and their | 244 // Information about the relationship between event phase enums and their |
243 // symbolic names. | 245 // symbolic names. |
244 { | 246 { |
245 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 247 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
246 | 248 |
247 dict->SetInteger("PHASE_BEGIN", NetLog::PHASE_BEGIN); | 249 dict->SetInteger("PHASE_BEGIN", NetLog::PHASE_BEGIN); |
248 dict->SetInteger("PHASE_END", NetLog::PHASE_END); | 250 dict->SetInteger("PHASE_END", NetLog::PHASE_END); |
249 dict->SetInteger("PHASE_NONE", NetLog::PHASE_NONE); | 251 dict->SetInteger("PHASE_NONE", NetLog::PHASE_NONE); |
250 | 252 |
251 constants_dict->Set("logEventPhase", std::move(dict)); | 253 constants_dict->Set("logEventPhase", std::move(dict)); |
252 } | 254 } |
253 | 255 |
254 // Information about the relationship between source type enums and | 256 // Information about the relationship between source type enums and |
255 // their symbolic names. | 257 // their symbolic names. |
256 constants_dict->Set("logSourceType", NetLog::GetSourceTypesAsValue()); | 258 constants_dict->Set("logSourceType", NetLog::GetSourceTypesAsValue()); |
257 | 259 |
258 // TODO(eroman): This is here for compatibility in loading new log files with | 260 // TODO(eroman): This is here for compatibility in loading new log files with |
259 // older builds of Chrome. Safe to remove this once M45 is on the stable | 261 // older builds of Chrome. Safe to remove this once M45 is on the stable |
260 // channel. | 262 // channel. |
261 constants_dict->Set("logLevelType", new base::DictionaryValue()); | 263 constants_dict->Set("logLevelType", new base::DictionaryValue()); |
262 | 264 |
263 // Information about the relationship between address family enums and | 265 // Information about the relationship between address family enums and |
264 // their symbolic names. | 266 // their symbolic names. |
265 { | 267 { |
266 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 268 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
267 | 269 |
268 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED", ADDRESS_FAMILY_UNSPECIFIED); | 270 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED", ADDRESS_FAMILY_UNSPECIFIED); |
269 dict->SetInteger("ADDRESS_FAMILY_IPV4", ADDRESS_FAMILY_IPV4); | 271 dict->SetInteger("ADDRESS_FAMILY_IPV4", ADDRESS_FAMILY_IPV4); |
270 dict->SetInteger("ADDRESS_FAMILY_IPV6", ADDRESS_FAMILY_IPV6); | 272 dict->SetInteger("ADDRESS_FAMILY_IPV6", ADDRESS_FAMILY_IPV6); |
271 | 273 |
272 constants_dict->Set("addressFamily", std::move(dict)); | 274 constants_dict->Set("addressFamily", std::move(dict)); |
273 } | 275 } |
274 | 276 |
275 // Information about how the "time ticks" values we have given it relate to | 277 // Information about how the "time ticks" values we have given it relate to |
276 // actual system times. Time ticks are used throughout since they are stable | 278 // actual system times. Time ticks are used throughout since they are stable |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 active_groups.begin(); | 310 active_groups.begin(); |
309 it != active_groups.end(); ++it) { | 311 it != active_groups.end(); ++it) { |
310 field_trial_groups->AppendString(it->trial_name + ":" + it->group_name); | 312 field_trial_groups->AppendString(it->trial_name + ":" + it->group_name); |
311 } | 313 } |
312 constants_dict->Set("activeFieldTrialGroups", field_trial_groups); | 314 constants_dict->Set("activeFieldTrialGroups", field_trial_groups); |
313 } | 315 } |
314 | 316 |
315 return constants_dict; | 317 return constants_dict; |
316 } | 318 } |
317 | 319 |
318 NET_EXPORT scoped_ptr<base::DictionaryValue> GetNetInfo( | 320 NET_EXPORT std::unique_ptr<base::DictionaryValue> GetNetInfo( |
319 URLRequestContext* context, | 321 URLRequestContext* context, |
320 int info_sources) { | 322 int info_sources) { |
321 // May only be called on the context's thread. | 323 // May only be called on the context's thread. |
322 DCHECK(context->CalledOnValidThread()); | 324 DCHECK(context->CalledOnValidThread()); |
323 | 325 |
324 scoped_ptr<base::DictionaryValue> net_info_dict(new base::DictionaryValue()); | 326 std::unique_ptr<base::DictionaryValue> net_info_dict( |
| 327 new base::DictionaryValue()); |
325 | 328 |
326 // TODO(mmenke): The code for most of these sources should probably be moved | 329 // TODO(mmenke): The code for most of these sources should probably be moved |
327 // into the sources themselves. | 330 // into the sources themselves. |
328 if (info_sources & NET_INFO_PROXY_SETTINGS) { | 331 if (info_sources & NET_INFO_PROXY_SETTINGS) { |
329 ProxyService* proxy_service = context->proxy_service(); | 332 ProxyService* proxy_service = context->proxy_service(); |
330 | 333 |
331 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 334 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
332 if (proxy_service->fetched_config().is_valid()) | 335 if (proxy_service->fetched_config().is_valid()) |
333 dict->Set("original", proxy_service->fetched_config().ToValue()); | 336 dict->Set("original", proxy_service->fetched_config().ToValue()); |
334 if (proxy_service->config().is_valid()) | 337 if (proxy_service->config().is_valid()) |
335 dict->Set("effective", proxy_service->config().ToValue()); | 338 dict->Set("effective", proxy_service->config().ToValue()); |
336 | 339 |
337 net_info_dict->Set(NetInfoSourceToString(NET_INFO_PROXY_SETTINGS), | 340 net_info_dict->Set(NetInfoSourceToString(NET_INFO_PROXY_SETTINGS), |
338 std::move(dict)); | 341 std::move(dict)); |
339 } | 342 } |
340 | 343 |
341 if (info_sources & NET_INFO_BAD_PROXIES) { | 344 if (info_sources & NET_INFO_BAD_PROXIES) { |
342 const ProxyRetryInfoMap& bad_proxies_map = | 345 const ProxyRetryInfoMap& bad_proxies_map = |
343 context->proxy_service()->proxy_retry_info(); | 346 context->proxy_service()->proxy_retry_info(); |
344 | 347 |
345 base::ListValue* list = new base::ListValue(); | 348 base::ListValue* list = new base::ListValue(); |
346 | 349 |
347 for (ProxyRetryInfoMap::const_iterator it = bad_proxies_map.begin(); | 350 for (ProxyRetryInfoMap::const_iterator it = bad_proxies_map.begin(); |
348 it != bad_proxies_map.end(); ++it) { | 351 it != bad_proxies_map.end(); ++it) { |
349 const std::string& proxy_uri = it->first; | 352 const std::string& proxy_uri = it->first; |
350 const ProxyRetryInfo& retry_info = it->second; | 353 const ProxyRetryInfo& retry_info = it->second; |
351 | 354 |
352 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 355 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
353 dict->SetString("proxy_uri", proxy_uri); | 356 dict->SetString("proxy_uri", proxy_uri); |
354 dict->SetString("bad_until", | 357 dict->SetString("bad_until", |
355 NetLog::TickCountToString(retry_info.bad_until)); | 358 NetLog::TickCountToString(retry_info.bad_until)); |
356 | 359 |
357 list->Append(std::move(dict)); | 360 list->Append(std::move(dict)); |
358 } | 361 } |
359 | 362 |
360 net_info_dict->Set(NetInfoSourceToString(NET_INFO_BAD_PROXIES), list); | 363 net_info_dict->Set(NetInfoSourceToString(NET_INFO_BAD_PROXIES), list); |
361 } | 364 } |
362 | 365 |
363 if (info_sources & NET_INFO_HOST_RESOLVER) { | 366 if (info_sources & NET_INFO_HOST_RESOLVER) { |
364 HostResolver* host_resolver = context->host_resolver(); | 367 HostResolver* host_resolver = context->host_resolver(); |
365 DCHECK(host_resolver); | 368 DCHECK(host_resolver); |
366 HostCache* cache = host_resolver->GetHostCache(); | 369 HostCache* cache = host_resolver->GetHostCache(); |
367 if (cache) { | 370 if (cache) { |
368 scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 371 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
369 scoped_ptr<base::Value> dns_config = host_resolver->GetDnsConfigAsValue(); | 372 std::unique_ptr<base::Value> dns_config = |
| 373 host_resolver->GetDnsConfigAsValue(); |
370 if (dns_config) | 374 if (dns_config) |
371 dict->Set("dns_config", std::move(dns_config)); | 375 dict->Set("dns_config", std::move(dns_config)); |
372 | 376 |
373 base::DictionaryValue* cache_info_dict = new base::DictionaryValue(); | 377 base::DictionaryValue* cache_info_dict = new base::DictionaryValue(); |
374 | 378 |
375 cache_info_dict->SetInteger("capacity", | 379 cache_info_dict->SetInteger("capacity", |
376 static_cast<int>(cache->max_entries())); | 380 static_cast<int>(cache->max_entries())); |
377 | 381 |
378 base::ListValue* entry_list = new base::ListValue(); | 382 base::ListValue* entry_list = new base::ListValue(); |
379 | 383 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 stats_dict->SetStringWithoutPathExpansion(stats[i].first, | 496 stats_dict->SetStringWithoutPathExpansion(stats[i].first, |
493 stats[i].second); | 497 stats[i].second); |
494 } | 498 } |
495 } | 499 } |
496 info_dict->Set("stats", stats_dict); | 500 info_dict->Set("stats", stats_dict); |
497 | 501 |
498 net_info_dict->Set(NetInfoSourceToString(NET_INFO_HTTP_CACHE), info_dict); | 502 net_info_dict->Set(NetInfoSourceToString(NET_INFO_HTTP_CACHE), info_dict); |
499 } | 503 } |
500 | 504 |
501 if (info_sources & NET_INFO_SDCH) { | 505 if (info_sources & NET_INFO_SDCH) { |
502 scoped_ptr<base::Value> info_dict; | 506 std::unique_ptr<base::Value> info_dict; |
503 SdchManager* sdch_manager = context->sdch_manager(); | 507 SdchManager* sdch_manager = context->sdch_manager(); |
504 if (sdch_manager) { | 508 if (sdch_manager) { |
505 info_dict = sdch_manager->SdchInfoToValue(); | 509 info_dict = sdch_manager->SdchInfoToValue(); |
506 } else { | 510 } else { |
507 info_dict.reset(new base::DictionaryValue()); | 511 info_dict.reset(new base::DictionaryValue()); |
508 } | 512 } |
509 net_info_dict->Set(NetInfoSourceToString(NET_INFO_SDCH), | 513 net_info_dict->Set(NetInfoSourceToString(NET_INFO_SDCH), |
510 std::move(info_dict)); | 514 std::move(info_dict)); |
511 } | 515 } |
512 | 516 |
(...skipping 27 matching lines...) Expand all Loading... |
540 // fine, since GetRequestStateAsValue() ignores the capture mode. | 544 // fine, since GetRequestStateAsValue() ignores the capture mode. |
541 NetLog::EntryData entry_data( | 545 NetLog::EntryData entry_data( |
542 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), | 546 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), |
543 NetLog::PHASE_BEGIN, request->creation_time(), &callback); | 547 NetLog::PHASE_BEGIN, request->creation_time(), &callback); |
544 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default()); | 548 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default()); |
545 observer->OnAddEntry(entry); | 549 observer->OnAddEntry(entry); |
546 } | 550 } |
547 } | 551 } |
548 | 552 |
549 } // namespace net | 553 } // namespace net |
OLD | NEW |