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

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

Issue 4067002: First pass at adding http/backend cache to NetLog (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Minor cleanup Created 10 years 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/lock.h" 10 #include "base/lock.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 trackers_[net::NetLog::SOURCE_URL_REQUEST] = &url_request_tracker_; 64 trackers_[net::NetLog::SOURCE_URL_REQUEST] = &url_request_tracker_;
65 trackers_[net::NetLog::SOURCE_SOCKET_STREAM] = &socket_stream_tracker_; 65 trackers_[net::NetLog::SOURCE_SOCKET_STREAM] = &socket_stream_tracker_;
66 trackers_[net::NetLog::SOURCE_CONNECT_JOB] = &connect_job_tracker_; 66 trackers_[net::NetLog::SOURCE_CONNECT_JOB] = &connect_job_tracker_;
67 trackers_[net::NetLog::SOURCE_SOCKET] = &socket_tracker_; 67 trackers_[net::NetLog::SOURCE_SOCKET] = &socket_tracker_;
68 trackers_[net::NetLog::SOURCE_INIT_PROXY_RESOLVER] = 68 trackers_[net::NetLog::SOURCE_INIT_PROXY_RESOLVER] =
69 &init_proxy_resolver_tracker_; 69 &init_proxy_resolver_tracker_;
70 trackers_[net::NetLog::SOURCE_SPDY_SESSION] = &spdy_session_tracker_; 70 trackers_[net::NetLog::SOURCE_SPDY_SESSION] = &spdy_session_tracker_;
71 trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_REQUEST] = 71 trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_REQUEST] =
72 &dns_request_tracker_; 72 &dns_request_tracker_;
73 trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB] = &dns_job_tracker_; 73 trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB] = &dns_job_tracker_;
74 trackers_[net::NetLog::SOURCE_DISK_CACHE_ENTRY] = &disk_cache_entry_tracker_;
74 // Make sure our mapping is up-to-date. 75 // Make sure our mapping is up-to-date.
75 for (size_t i = 0; i < arraysize(trackers_); ++i) 76 for (size_t i = 0; i < arraysize(trackers_); ++i)
76 DCHECK(trackers_[i]) << "Unhandled SourceType: " << i; 77 DCHECK(trackers_[i]) << "Unhandled SourceType: " << i;
77 } 78 }
78 79
79 PassiveLogCollector::~PassiveLogCollector() { 80 PassiveLogCollector::~PassiveLogCollector() {
80 } 81 }
81 82
82 void PassiveLogCollector::OnAddEntry( 83 void PassiveLogCollector::OnAddEntry(
83 net::NetLog::EventType type, 84 net::NetLog::EventType type,
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 PassiveLogCollector::DNSJobTracker::DoAddEntry(const ChromeNetLog::Entry& entry, 555 PassiveLogCollector::DNSJobTracker::DoAddEntry(const ChromeNetLog::Entry& entry,
555 SourceInfo* out_info) { 556 SourceInfo* out_info) {
556 AddEntryToSourceInfo(entry, out_info); 557 AddEntryToSourceInfo(entry, out_info);
557 if (entry.type == net::NetLog::TYPE_HOST_RESOLVER_IMPL_JOB && 558 if (entry.type == net::NetLog::TYPE_HOST_RESOLVER_IMPL_JOB &&
558 entry.phase == net::NetLog::PHASE_END) { 559 entry.phase == net::NetLog::PHASE_END) {
559 return ACTION_MOVE_TO_GRAVEYARD; 560 return ACTION_MOVE_TO_GRAVEYARD;
560 } else { 561 } else {
561 return ACTION_NONE; 562 return ACTION_NONE;
562 } 563 }
563 } 564 }
565
566 //----------------------------------------------------------------------------
567 // DiskCacheEntryTracker
568 //----------------------------------------------------------------------------
569
570 const size_t PassiveLogCollector::DiskCacheEntryTracker::kMaxNumSources = 100;
571 const size_t PassiveLogCollector::DiskCacheEntryTracker::kMaxGraveyardSize = 25;
572
573 PassiveLogCollector::DiskCacheEntryTracker::DiskCacheEntryTracker()
574 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) {
575 }
576
577 PassiveLogCollector::SourceTracker::Action
578 PassiveLogCollector::DiskCacheEntryTracker::DoAddEntry(
579 const ChromeNetLog::Entry& entry, SourceInfo* out_info) {
580 AddEntryToSourceInfo(entry, out_info);
581
582 // If the request has ended, move it to the graveyard.
583 if (entry.type == net::NetLog::TYPE_DISK_CACHE_ENTRY &&
584 entry.phase == net::NetLog::PHASE_END) {
585 return ACTION_MOVE_TO_GRAVEYARD;
586 }
587
588 return ACTION_NONE;
589 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698