Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(296)

Side by Side Diff: chrome/browser/net/passive_log_collector.cc

Issue 6592027: Update NetLog in preparation for late binding of HttpStream jobs to requests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits. Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/net/passive_log_collector.h" 5 #include "chrome/browser/net/passive_log_collector.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 //---------------------------------------------------------------------------- 48 //----------------------------------------------------------------------------
49 // PassiveLogCollector 49 // PassiveLogCollector
50 //---------------------------------------------------------------------------- 50 //----------------------------------------------------------------------------
51 51
52 PassiveLogCollector::PassiveLogCollector() 52 PassiveLogCollector::PassiveLogCollector()
53 : ThreadSafeObserver(net::NetLog::LOG_BASIC), 53 : ThreadSafeObserver(net::NetLog::LOG_BASIC),
54 ALLOW_THIS_IN_INITIALIZER_LIST(connect_job_tracker_(this)), 54 ALLOW_THIS_IN_INITIALIZER_LIST(connect_job_tracker_(this)),
55 ALLOW_THIS_IN_INITIALIZER_LIST(url_request_tracker_(this)), 55 ALLOW_THIS_IN_INITIALIZER_LIST(url_request_tracker_(this)),
56 ALLOW_THIS_IN_INITIALIZER_LIST(socket_stream_tracker_(this)), 56 ALLOW_THIS_IN_INITIALIZER_LIST(socket_stream_tracker_(this)),
57 ALLOW_THIS_IN_INITIALIZER_LIST(http_stream_job_tracker_(this)),
57 num_events_seen_(0) { 58 num_events_seen_(0) {
58 59
59 // Define the mapping between source types and the tracker objects. 60 // Define the mapping between source types and the tracker objects.
60 memset(&trackers_[0], 0, sizeof(trackers_)); 61 memset(&trackers_[0], 0, sizeof(trackers_));
61 trackers_[net::NetLog::SOURCE_NONE] = &global_source_tracker_; 62 trackers_[net::NetLog::SOURCE_NONE] = &global_source_tracker_;
62 trackers_[net::NetLog::SOURCE_URL_REQUEST] = &url_request_tracker_; 63 trackers_[net::NetLog::SOURCE_URL_REQUEST] = &url_request_tracker_;
63 trackers_[net::NetLog::SOURCE_SOCKET_STREAM] = &socket_stream_tracker_; 64 trackers_[net::NetLog::SOURCE_SOCKET_STREAM] = &socket_stream_tracker_;
64 trackers_[net::NetLog::SOURCE_CONNECT_JOB] = &connect_job_tracker_; 65 trackers_[net::NetLog::SOURCE_CONNECT_JOB] = &connect_job_tracker_;
65 trackers_[net::NetLog::SOURCE_SOCKET] = &socket_tracker_; 66 trackers_[net::NetLog::SOURCE_SOCKET] = &socket_tracker_;
66 trackers_[net::NetLog::SOURCE_INIT_PROXY_RESOLVER] = 67 trackers_[net::NetLog::SOURCE_INIT_PROXY_RESOLVER] =
67 &init_proxy_resolver_tracker_; 68 &init_proxy_resolver_tracker_;
68 trackers_[net::NetLog::SOURCE_SPDY_SESSION] = &spdy_session_tracker_; 69 trackers_[net::NetLog::SOURCE_SPDY_SESSION] = &spdy_session_tracker_;
69 trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_REQUEST] = 70 trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_REQUEST] =
70 &dns_request_tracker_; 71 &dns_request_tracker_;
71 trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB] = &dns_job_tracker_; 72 trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB] = &dns_job_tracker_;
72 trackers_[net::NetLog::SOURCE_DISK_CACHE_ENTRY] = &disk_cache_entry_tracker_; 73 trackers_[net::NetLog::SOURCE_DISK_CACHE_ENTRY] = &disk_cache_entry_tracker_;
74 trackers_[net::NetLog::SOURCE_HTTP_STREAM_JOB] = &http_stream_job_tracker_;
73 // Make sure our mapping is up-to-date. 75 // Make sure our mapping is up-to-date.
74 for (size_t i = 0; i < arraysize(trackers_); ++i) 76 for (size_t i = 0; i < arraysize(trackers_); ++i)
75 DCHECK(trackers_[i]) << "Unhandled SourceType: " << i; 77 DCHECK(trackers_[i]) << "Unhandled SourceType: " << i;
76 } 78 }
77 79
78 PassiveLogCollector::~PassiveLogCollector() { 80 PassiveLogCollector::~PassiveLogCollector() {
79 } 81 }
80 82
81 void PassiveLogCollector::OnAddEntry( 83 void PassiveLogCollector::OnAddEntry(
82 net::NetLog::EventType type, 84 net::NetLog::EventType type,
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 parent_->GetTrackerForSourceType_(source.type)); 340 parent_->GetTrackerForSourceType_(source.type));
339 DCHECK(tracker); 341 DCHECK(tracker);
340 342
341 // Tell the owning tracker to increment the reference count of |source|. 343 // Tell the owning tracker to increment the reference count of |source|.
342 tracker->AdjustReferenceCountForSource(1, source.id); 344 tracker->AdjustReferenceCountForSource(1, source.id);
343 345
344 // Make a note to release this reference once |info| is destroyed. 346 // Make a note to release this reference once |info| is destroyed.
345 info->dependencies.push_back(source); 347 info->dependencies.push_back(source);
346 } 348 }
347 349
348 void 350 void PassiveLogCollector::SourceTracker::ReleaseAllReferencesToDependencies(
349 PassiveLogCollector::SourceTracker::ReleaseAllReferencesToDependencies(
350 SourceInfo* info) { 351 SourceInfo* info) {
351 // Release all references |info| was holding to other sources. 352 // Release all references |info| was holding to other sources.
352 for (SourceDependencyList::const_iterator it = info->dependencies.begin(); 353 for (SourceDependencyList::const_iterator it = info->dependencies.begin();
353 it != info->dependencies.end(); ++it) { 354 it != info->dependencies.end(); ++it) {
354 const net::NetLog::Source& source = *it; 355 const net::NetLog::Source& source = *it;
355 356
356 // Find the tracker which should be holding |source|. 357 // Find the tracker which should be holding |source|.
357 DCHECK(parent_); 358 DCHECK(parent_);
358 DCHECK_NE(source.type, net::NetLog::SOURCE_NONE); 359 DCHECK_NE(source.type, net::NetLog::SOURCE_NONE);
359 SourceTracker* tracker = static_cast<SourceTracker*>( 360 SourceTracker* tracker = static_cast<SourceTracker*>(
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 const size_t PassiveLogCollector::RequestTracker::kMaxNumSources = 100; 439 const size_t PassiveLogCollector::RequestTracker::kMaxNumSources = 100;
439 const size_t PassiveLogCollector::RequestTracker::kMaxGraveyardSize = 25; 440 const size_t PassiveLogCollector::RequestTracker::kMaxGraveyardSize = 25;
440 441
441 PassiveLogCollector::RequestTracker::RequestTracker(PassiveLogCollector* parent) 442 PassiveLogCollector::RequestTracker::RequestTracker(PassiveLogCollector* parent)
442 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, parent) { 443 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, parent) {
443 } 444 }
444 445
445 PassiveLogCollector::SourceTracker::Action 446 PassiveLogCollector::SourceTracker::Action
446 PassiveLogCollector::RequestTracker::DoAddEntry( 447 PassiveLogCollector::RequestTracker::DoAddEntry(
447 const ChromeNetLog::Entry& entry, SourceInfo* out_info) { 448 const ChromeNetLog::Entry& entry, SourceInfo* out_info) {
448 if (entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB || 449 if (entry.type == net::NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB) {
449 entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET) {
450 const net::NetLog::Source& source_dependency = 450 const net::NetLog::Source& source_dependency =
451 static_cast<net::NetLogSourceParameter*>(entry.params.get())->value(); 451 static_cast<net::NetLogSourceParameter*>(entry.params.get())->value();
452 AddReferenceToSourceDependency(source_dependency, out_info); 452 AddReferenceToSourceDependency(source_dependency, out_info);
453 } 453 }
454 454
455 AddEntryToSourceInfo(entry, out_info); 455 AddEntryToSourceInfo(entry, out_info);
456 456
457 // If the request has ended, move it to the graveyard. 457 // If the request has ended, move it to the graveyard.
458 if (entry.type == net::NetLog::TYPE_REQUEST_ALIVE && 458 if (entry.type == net::NetLog::TYPE_REQUEST_ALIVE &&
459 entry.phase == net::NetLog::PHASE_END) { 459 entry.phase == net::NetLog::PHASE_END) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 AddEntryToSourceInfo(entry, out_info); 578 AddEntryToSourceInfo(entry, out_info);
579 579
580 // If the request has ended, move it to the graveyard. 580 // If the request has ended, move it to the graveyard.
581 if (entry.type == net::NetLog::TYPE_DISK_CACHE_ENTRY && 581 if (entry.type == net::NetLog::TYPE_DISK_CACHE_ENTRY &&
582 entry.phase == net::NetLog::PHASE_END) { 582 entry.phase == net::NetLog::PHASE_END) {
583 return ACTION_MOVE_TO_GRAVEYARD; 583 return ACTION_MOVE_TO_GRAVEYARD;
584 } 584 }
585 585
586 return ACTION_NONE; 586 return ACTION_NONE;
587 } 587 }
588
589 //----------------------------------------------------------------------------
590 // HttpStreamJobTracker
591 //----------------------------------------------------------------------------
592
593 const size_t PassiveLogCollector::HttpStreamJobTracker::kMaxNumSources = 100;
594 const size_t PassiveLogCollector::HttpStreamJobTracker::kMaxGraveyardSize = 25;
595
596 PassiveLogCollector::HttpStreamJobTracker::HttpStreamJobTracker(
597 PassiveLogCollector* parent)
598 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, parent) {
599 }
600
601 PassiveLogCollector::SourceTracker::Action
602 PassiveLogCollector::HttpStreamJobTracker::DoAddEntry(
603 const ChromeNetLog::Entry& entry, SourceInfo* out_info) {
604 if (entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB ||
605 entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET) {
606 const net::NetLog::Source& source_dependency =
607 static_cast<net::NetLogSourceParameter*>(entry.params.get())->value();
608 AddReferenceToSourceDependency(source_dependency, out_info);
609 }
610
611 AddEntryToSourceInfo(entry, out_info);
612
613 // If the request has ended, move it to the graveyard.
614 if (entry.type == net::NetLog::TYPE_HTTP_STREAM_JOB &&
615 entry.phase == net::NetLog::PHASE_END) {
616 return ACTION_MOVE_TO_GRAVEYARD;
617 }
618
619 return ACTION_NONE;
620 }
OLDNEW
« no previous file with comments | « chrome/browser/net/passive_log_collector.h ('k') | chrome/browser/net/passive_log_collector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698