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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 } | 512 } |
513 | 513 |
514 return net_info_dict; | 514 return net_info_dict; |
515 } | 515 } |
516 | 516 |
517 NET_EXPORT void CreateNetLogEntriesForActiveObjects( | 517 NET_EXPORT void CreateNetLogEntriesForActiveObjects( |
518 const std::set<URLRequestContext*>& contexts, | 518 const std::set<URLRequestContext*>& contexts, |
519 NetLog::ThreadSafeObserver* observer) { | 519 NetLog::ThreadSafeObserver* observer) { |
520 // Put together the list of all requests. | 520 // Put together the list of all requests. |
521 std::vector<const URLRequest*> requests; | 521 std::vector<const URLRequest*> requests; |
522 for (const auto& context : contexts) { | 522 for (auto* context : contexts) { |
523 // May only be called on the context's thread. | 523 // May only be called on the context's thread. |
524 DCHECK(context->CalledOnValidThread()); | 524 DCHECK(context->CalledOnValidThread()); |
525 // Contexts should all be using the same NetLog. | 525 // Contexts should all be using the same NetLog. |
526 DCHECK_EQ((*contexts.begin())->net_log(), context->net_log()); | 526 DCHECK_EQ((*contexts.begin())->net_log(), context->net_log()); |
527 for (const auto& request : *context->url_requests()) { | 527 for (auto* request : *context->url_requests()) { |
528 requests.push_back(request); | 528 requests.push_back(request); |
529 } | 529 } |
530 } | 530 } |
531 | 531 |
532 // Sort by creation time. | 532 // Sort by creation time. |
533 std::sort(requests.begin(), requests.end(), RequestCreatedBefore); | 533 std::sort(requests.begin(), requests.end(), RequestCreatedBefore); |
534 | 534 |
535 // Create fake events. | 535 // Create fake events. |
536 for (const auto& request : requests) { | 536 for (auto* request : requests) { |
537 NetLog::ParametersCallback callback = | 537 NetLog::ParametersCallback callback = |
538 base::Bind(&GetRequestStateAsValue, base::Unretained(request)); | 538 base::Bind(&GetRequestStateAsValue, base::Unretained(request)); |
539 | 539 |
540 // Note that passing the hardcoded NetLogCaptureMode::Default() below is | 540 // Note that passing the hardcoded NetLogCaptureMode::Default() below is |
541 // fine, since GetRequestStateAsValue() ignores the capture mode. | 541 // fine, since GetRequestStateAsValue() ignores the capture mode. |
542 NetLog::EntryData entry_data( | 542 NetLog::EntryData entry_data( |
543 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), | 543 NetLog::TYPE_REQUEST_ALIVE, request->net_log().source(), |
544 NetLog::PHASE_BEGIN, request->creation_time(), &callback); | 544 NetLog::PHASE_BEGIN, request->creation_time(), &callback); |
545 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default()); | 545 NetLog::Entry entry(&entry_data, NetLogCaptureMode::Default()); |
546 observer->OnAddEntry(entry); | 546 observer->OnAddEntry(entry); |
547 } | 547 } |
548 } | 548 } |
549 | 549 |
550 } // namespace net | 550 } // namespace net |
OLD | NEW |