| 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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 constants_dict->Set("activeFieldTrialGroups", field_trial_groups); | 318 constants_dict->Set("activeFieldTrialGroups", field_trial_groups); |
| 319 } | 319 } |
| 320 | 320 |
| 321 return constants_dict; | 321 return constants_dict; |
| 322 } | 322 } |
| 323 | 323 |
| 324 NET_EXPORT std::unique_ptr<base::DictionaryValue> GetNetInfo( | 324 NET_EXPORT std::unique_ptr<base::DictionaryValue> GetNetInfo( |
| 325 URLRequestContext* context, | 325 URLRequestContext* context, |
| 326 int info_sources) { | 326 int info_sources) { |
| 327 // May only be called on the context's thread. | 327 // May only be called on the context's thread. |
| 328 DCHECK(context->CalledOnValidThread()); | 328 context->AssertCalledOnValidSequence(); |
| 329 | 329 |
| 330 std::unique_ptr<base::DictionaryValue> net_info_dict( | 330 std::unique_ptr<base::DictionaryValue> net_info_dict( |
| 331 new base::DictionaryValue()); | 331 new base::DictionaryValue()); |
| 332 | 332 |
| 333 // TODO(mmenke): The code for most of these sources should probably be moved | 333 // TODO(mmenke): The code for most of these sources should probably be moved |
| 334 // into the sources themselves. | 334 // into the sources themselves. |
| 335 if (info_sources & NET_INFO_PROXY_SETTINGS) { | 335 if (info_sources & NET_INFO_PROXY_SETTINGS) { |
| 336 ProxyService* proxy_service = context->proxy_service(); | 336 ProxyService* proxy_service = context->proxy_service(); |
| 337 | 337 |
| 338 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); | 338 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 return net_info_dict; | 505 return net_info_dict; |
| 506 } | 506 } |
| 507 | 507 |
| 508 NET_EXPORT void CreateNetLogEntriesForActiveObjects( | 508 NET_EXPORT void CreateNetLogEntriesForActiveObjects( |
| 509 const std::set<URLRequestContext*>& contexts, | 509 const std::set<URLRequestContext*>& contexts, |
| 510 NetLog::ThreadSafeObserver* observer) { | 510 NetLog::ThreadSafeObserver* observer) { |
| 511 // Put together the list of all requests. | 511 // Put together the list of all requests. |
| 512 std::vector<const URLRequest*> requests; | 512 std::vector<const URLRequest*> requests; |
| 513 for (auto* context : contexts) { | 513 for (auto* context : contexts) { |
| 514 // May only be called on the context's thread. | 514 // May only be called on the context's thread. |
| 515 DCHECK(context->CalledOnValidThread()); | 515 context->AssertCalledOnValidSequence(); |
| 516 // Contexts should all be using the same NetLog. | 516 // Contexts should all be using the same NetLog. |
| 517 DCHECK_EQ((*contexts.begin())->net_log(), context->net_log()); | 517 DCHECK_EQ((*contexts.begin())->net_log(), context->net_log()); |
| 518 for (auto* request : context->url_requests()) { | 518 for (auto* request : context->url_requests()) { |
| 519 requests.push_back(request); | 519 requests.push_back(request); |
| 520 } | 520 } |
| 521 } | 521 } |
| 522 | 522 |
| 523 // Sort by creation time. | 523 // Sort by creation time. |
| 524 std::sort(requests.begin(), requests.end(), RequestCreatedBefore); | 524 std::sort(requests.begin(), requests.end(), RequestCreatedBefore); |
| 525 | 525 |
| 526 // Create fake events. | 526 // Create fake events. |
| 527 for (auto* request : requests) { | 527 for (auto* request : requests) { |
| 528 NetLogParametersCallback callback = | 528 NetLogParametersCallback callback = |
| 529 base::Bind(&GetRequestStateAsValue, base::Unretained(request)); | 529 base::Bind(&GetRequestStateAsValue, base::Unretained(request)); |
| 530 | 530 |
| 531 // Note that passing the hardcoded NetLogCaptureMode::Default() below is | 531 // Note that passing the hardcoded NetLogCaptureMode::Default() below is |
| 532 // fine, since GetRequestStateAsValue() ignores the capture mode. | 532 // fine, since GetRequestStateAsValue() ignores the capture mode. |
| 533 NetLogEntryData entry_data( | 533 NetLogEntryData entry_data( |
| 534 NetLogEventType::REQUEST_ALIVE, request->net_log().source(), | 534 NetLogEventType::REQUEST_ALIVE, request->net_log().source(), |
| 535 NetLogEventPhase::BEGIN, request->creation_time(), &callback); | 535 NetLogEventPhase::BEGIN, request->creation_time(), &callback); |
| 536 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default()); | 536 NetLogEntry entry(&entry_data, NetLogCaptureMode::Default()); |
| 537 observer->OnAddEntry(entry); | 537 observer->OnAddEntry(entry); |
| 538 } | 538 } |
| 539 } | 539 } |
| 540 | 540 |
| 541 } // namespace net | 541 } // namespace net |
| OLD | NEW |