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/base/net_log_util.h" | 5 #include "net/base/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 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
530 NetLog::ThreadSafeObserver* observer) { | 530 NetLog::ThreadSafeObserver* observer) { |
531 // Not safe to call this when the observer is watching a NetLog. | 531 // Not safe to call this when the observer is watching a NetLog. |
532 DCHECK(!observer->net_log()); | 532 DCHECK(!observer->net_log()); |
533 | 533 |
534 // Put together the list of all requests. | 534 // Put together the list of all requests. |
535 std::vector<const URLRequest*> requests; | 535 std::vector<const URLRequest*> requests; |
536 for (const auto& context : contexts) { | 536 for (const auto& context : contexts) { |
537 // May only be called on the context's thread. | 537 // May only be called on the context's thread. |
538 DCHECK(context->CalledOnValidThread()); | 538 DCHECK(context->CalledOnValidThread()); |
539 // Contexts should all be using the same NetLog. | 539 // Contexts should all be using the same NetLog. |
540 DCHECK_EQ((*contexts.begin())->net_log(), context->net_log()); | 540 // TODO(mmenke) This DCHECK fails on Android. |
jeremyim
2015/01/28 22:12:04
Alternatively, this could be wrapped with
#if !de
| |
541 // DCHECK_EQ((*contexts.begin())->net_log(), context->net_log()); | |
mmenke
2015/01/30 15:17:14
Outputting requests from two different NetLogs (Or
jeremyim
2015/01/30 15:48:07
Done.
| |
541 for (const auto& request : *context->url_requests()) { | 542 for (const auto& request : *context->url_requests()) { |
542 requests.push_back(request); | 543 requests.push_back(request); |
543 } | 544 } |
544 } | 545 } |
545 | 546 |
546 // Sort by creation time. | 547 // Sort by creation time. |
547 std::sort(requests.begin(), requests.end(), RequestCreatedBefore); | 548 std::sort(requests.begin(), requests.end(), RequestCreatedBefore); |
548 | 549 |
549 // Create fake events. | 550 // Create fake events. |
550 ScopedVector<NetLog::Entry> entries; | 551 ScopedVector<NetLog::Entry> entries; |
551 for (const auto& request : requests) { | 552 for (const auto& request : requests) { |
552 net::NetLog::ParametersCallback callback = | 553 net::NetLog::ParametersCallback callback = |
553 base::Bind(&GetRequestStateAsValue, base::Unretained(request)); | 554 base::Bind(&GetRequestStateAsValue, base::Unretained(request)); |
554 | 555 |
555 net::NetLog::EntryData entry_data(net::NetLog::TYPE_REQUEST_ALIVE, | 556 net::NetLog::EntryData entry_data(net::NetLog::TYPE_REQUEST_ALIVE, |
556 request->net_log().source(), | 557 request->net_log().source(), |
557 net::NetLog::PHASE_BEGIN, | 558 net::NetLog::PHASE_BEGIN, |
558 request->creation_time(), | 559 request->creation_time(), |
559 &callback); | 560 &callback); |
560 NetLog::Entry entry(&entry_data, request->net_log().GetLogLevel()); | 561 NetLog::Entry entry(&entry_data, request->net_log().GetLogLevel()); |
561 observer->OnAddEntry(entry); | 562 observer->OnAddEntry(entry); |
562 } | 563 } |
563 } | 564 } |
564 | 565 |
565 } // namespace net | 566 } // namespace net |
OLD | NEW |