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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 if (request1->creation_time() > request2->creation_time()) | 122 if (request1->creation_time() > request2->creation_time()) |
123 return false; | 123 return false; |
124 // If requests were created at the same time, sort by ID. Mostly matters for | 124 // If requests were created at the same time, sort by ID. Mostly matters for |
125 // testing purposes. | 125 // testing purposes. |
126 return request1->identifier() < request2->identifier(); | 126 return request1->identifier() < request2->identifier(); |
127 } | 127 } |
128 | 128 |
129 // Returns a Value representing the state of a pre-existing URLRequest when | 129 // Returns a Value representing the state of a pre-existing URLRequest when |
130 // net-internals was opened. | 130 // net-internals was opened. |
131 base::Value* GetRequestStateAsValue(const net::URLRequest* request, | 131 base::Value* GetRequestStateAsValue(const net::URLRequest* request, |
132 net::NetLog::LogLevel log_level) { | 132 net::NetLogCaptureMode capture_mode) { |
133 return request->GetStateAsValue(); | 133 return request->GetStateAsValue(); |
134 } | 134 } |
135 | 135 |
136 } // namespace | 136 } // namespace |
137 | 137 |
138 scoped_ptr<base::DictionaryValue> GetNetConstants() { | 138 scoped_ptr<base::DictionaryValue> GetNetConstants() { |
139 scoped_ptr<base::DictionaryValue> constants_dict(new base::DictionaryValue()); | 139 scoped_ptr<base::DictionaryValue> constants_dict(new base::DictionaryValue()); |
140 | 140 |
141 // Version of the file format. | 141 // Version of the file format. |
142 constants_dict->SetInteger("logFormatVersion", kLogFormatVersion); | 142 constants_dict->SetInteger("logFormatVersion", kLogFormatVersion); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 dict->SetInteger("PHASE_END", net::NetLog::PHASE_END); | 248 dict->SetInteger("PHASE_END", net::NetLog::PHASE_END); |
249 dict->SetInteger("PHASE_NONE", net::NetLog::PHASE_NONE); | 249 dict->SetInteger("PHASE_NONE", net::NetLog::PHASE_NONE); |
250 | 250 |
251 constants_dict->Set("logEventPhase", dict); | 251 constants_dict->Set("logEventPhase", dict); |
252 } | 252 } |
253 | 253 |
254 // Information about the relationship between source type enums and | 254 // Information about the relationship between source type enums and |
255 // their symbolic names. | 255 // their symbolic names. |
256 constants_dict->Set("logSourceType", net::NetLog::GetSourceTypesAsValue()); | 256 constants_dict->Set("logSourceType", net::NetLog::GetSourceTypesAsValue()); |
257 | 257 |
258 // Information about the relationship between LogLevel enums and their | 258 // TODO(eroman): This is here for compatibility in loading new log files with |
259 // symbolic names. | 259 // older builds of Chrome. Safe to remove this once M45 is on the stable |
260 { | 260 // channel. |
261 base::DictionaryValue* dict = new base::DictionaryValue(); | 261 constants_dict->Set("logLevelType", new base::DictionaryValue()); |
262 | |
263 dict->SetInteger("LOG_ALL", net::NetLog::LOG_ALL); | |
264 dict->SetInteger("LOG_ALL_BUT_BYTES", net::NetLog::LOG_ALL_BUT_BYTES); | |
265 dict->SetInteger("LOG_STRIP_PRIVATE_DATA", | |
266 net::NetLog::LOG_STRIP_PRIVATE_DATA); | |
267 | |
268 constants_dict->Set("logLevelType", dict); | |
269 } | |
270 | 262 |
271 // Information about the relationship between address family enums and | 263 // Information about the relationship between address family enums and |
272 // their symbolic names. | 264 // their symbolic names. |
273 { | 265 { |
274 base::DictionaryValue* dict = new base::DictionaryValue(); | 266 base::DictionaryValue* dict = new base::DictionaryValue(); |
275 | 267 |
276 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED", | 268 dict->SetInteger("ADDRESS_FAMILY_UNSPECIFIED", |
277 net::ADDRESS_FAMILY_UNSPECIFIED); | 269 net::ADDRESS_FAMILY_UNSPECIFIED); |
278 dict->SetInteger("ADDRESS_FAMILY_IPV4", net::ADDRESS_FAMILY_IPV4); | 270 dict->SetInteger("ADDRESS_FAMILY_IPV4", net::ADDRESS_FAMILY_IPV4); |
279 dict->SetInteger("ADDRESS_FAMILY_IPV6", net::ADDRESS_FAMILY_IPV6); | 271 dict->SetInteger("ADDRESS_FAMILY_IPV6", net::ADDRESS_FAMILY_IPV6); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 | 523 |
532 // Create fake events. | 524 // Create fake events. |
533 ScopedVector<NetLog::Entry> entries; | 525 ScopedVector<NetLog::Entry> entries; |
534 for (const auto& request : requests) { | 526 for (const auto& request : requests) { |
535 net::NetLog::ParametersCallback callback = | 527 net::NetLog::ParametersCallback callback = |
536 base::Bind(&GetRequestStateAsValue, base::Unretained(request)); | 528 base::Bind(&GetRequestStateAsValue, base::Unretained(request)); |
537 | 529 |
538 net::NetLog::EntryData entry_data( | 530 net::NetLog::EntryData entry_data( |
539 net::NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), | 531 net::NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), |
540 net::NetLog::PHASE_BEGIN, request->creation_time(), &callback); | 532 net::NetLog::PHASE_BEGIN, request->creation_time(), &callback); |
541 NetLog::Entry entry(&entry_data, request->net_log().GetLogLevel()); | 533 NetLog::Entry entry(&entry_data, request->net_log().GetCaptureMode()); |
542 observer->OnAddEntry(entry); | 534 observer->OnAddEntry(entry); |
543 } | 535 } |
544 } | 536 } |
545 | 537 |
546 } // namespace net | 538 } // namespace net |
OLD | NEW |