summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
authormmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-24 15:55:51 +0000
committermmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-24 15:55:51 +0000
commitee094b89dd380eed93bc0e6ce380d03a0b1b5329 (patch)
treed49719e986de616af7b59b95046be1613568a8f7 /chrome/browser/net
parentbb872ba65a60c2ade48089f6f0bc538e0cc649ac (diff)
downloadchromium_src-ee094b89dd380eed93bc0e6ce380d03a0b1b5329.zip
chromium_src-ee094b89dd380eed93bc0e6ce380d03a0b1b5329.tar.gz
chromium_src-ee094b89dd380eed93bc0e6ce380d03a0b1b5329.tar.bz2
Adds HostResolveImpl Requests and Jobs to log.
Differences over the reverted version (http://codereview.chromium.org/3080034/show - reverted http://codereview.chromium.org/3137022/show ): * Jobs never log anything in their destructor, as the HostResolverImpl randomly outlives the NetLog, at least in some unit tests. * Removed the extra log entries for when a DNS lookup starts/completes. Instead, the job's event is ended in OnLookupComplete(). * Slight modification of the CanceledAsynchronousLookup unit test, as the Job is now closed before posting any events to the Request. For actual lookups, this behavior means the Job's duration more accurately reflects the time the DNS lookup takes itself. BUG=46844 TEST=Look at the net-internals screen. Review URL: http://codereview.chromium.org/3119027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57189 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r--chrome/browser/net/connection_tester.cc2
-rw-r--r--chrome/browser/net/passive_log_collector.cc51
-rw-r--r--chrome/browser/net/passive_log_collector.h32
3 files changed, 83 insertions, 2 deletions
diff --git a/chrome/browser/net/connection_tester.cc b/chrome/browser/net/connection_tester.cc
index 1dd598e..5f71795 100644
--- a/chrome/browser/net/connection_tester.cc
+++ b/chrome/browser/net/connection_tester.cc
@@ -82,7 +82,7 @@ class ExperimentURLRequestContext : public URLRequestContext {
// Create a vanilla HostResolver that disables caching.
const size_t kMaxJobs = 50u;
scoped_refptr<net::HostResolverImpl> impl =
- new net::HostResolverImpl(NULL, NULL, kMaxJobs);
+ new net::HostResolverImpl(NULL, NULL, kMaxJobs, NULL);
*host_resolver = impl;
diff --git a/chrome/browser/net/passive_log_collector.cc b/chrome/browser/net/passive_log_collector.cc
index 152d332..adc6500 100644
--- a/chrome/browser/net/passive_log_collector.cc
+++ b/chrome/browser/net/passive_log_collector.cc
@@ -57,7 +57,9 @@ PassiveLogCollector::PassiveLogCollector()
trackers_[net::NetLog::SOURCE_INIT_PROXY_RESOLVER] =
&init_proxy_resolver_tracker_;
trackers_[net::NetLog::SOURCE_SPDY_SESSION] = &spdy_session_tracker_;
-
+ trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_REQUEST] =
+ &dns_request_tracker_;
+ trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB] = &dns_job_tracker_;
// Make sure our mapping is up-to-date.
for (size_t i = 0; i < arraysize(trackers_); ++i)
DCHECK(trackers_[i]) << "Unhandled SourceType: " << i;
@@ -485,3 +487,50 @@ PassiveLogCollector::SpdySessionTracker::DoAddEntry(const Entry& entry,
return ACTION_NONE;
}
}
+
+//----------------------------------------------------------------------------
+// DNSRequestTracker
+//----------------------------------------------------------------------------
+
+const size_t PassiveLogCollector::DNSRequestTracker::kMaxNumSources = 200;
+const size_t PassiveLogCollector::DNSRequestTracker::kMaxGraveyardSize = 20;
+
+PassiveLogCollector::DNSRequestTracker::DNSRequestTracker()
+ : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) {
+}
+
+PassiveLogCollector::SourceTracker::Action
+PassiveLogCollector::DNSRequestTracker::DoAddEntry(const Entry& entry,
+ SourceInfo* out_info) {
+ AddEntryToSourceInfo(entry, out_info);
+ if (entry.type == net::NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST &&
+ entry.phase == net::NetLog::PHASE_END) {
+ return ACTION_MOVE_TO_GRAVEYARD;
+ } else {
+ return ACTION_NONE;
+ }
+}
+
+//----------------------------------------------------------------------------
+// DNSJobTracker
+//----------------------------------------------------------------------------
+
+const size_t PassiveLogCollector::DNSJobTracker::kMaxNumSources = 100;
+const size_t PassiveLogCollector::DNSJobTracker::kMaxGraveyardSize = 15;
+
+PassiveLogCollector::DNSJobTracker::DNSJobTracker()
+ : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) {
+}
+
+PassiveLogCollector::SourceTracker::Action
+PassiveLogCollector::DNSJobTracker::DoAddEntry(const Entry& entry,
+ SourceInfo* out_info) {
+ AddEntryToSourceInfo(entry, out_info);
+ if (entry.type == net::NetLog::TYPE_HOST_RESOLVER_IMPL_JOB &&
+ entry.phase == net::NetLog::PHASE_END) {
+ return ACTION_MOVE_TO_GRAVEYARD;
+ } else {
+ return ACTION_NONE;
+ }
+}
+
diff --git a/chrome/browser/net/passive_log_collector.h b/chrome/browser/net/passive_log_collector.h
index e7d741f..8ffd459 100644
--- a/chrome/browser/net/passive_log_collector.h
+++ b/chrome/browser/net/passive_log_collector.h
@@ -283,6 +283,36 @@ class PassiveLogCollector : public ChromeNetLog::Observer {
DISALLOW_COPY_AND_ASSIGN(SpdySessionTracker);
};
+ // Tracks the log entries for the last seen SOURCE_HOST_RESOLVER_IMPL_REQUEST.
+ class DNSRequestTracker : public SourceTracker {
+ public:
+ static const size_t kMaxNumSources;
+ static const size_t kMaxGraveyardSize;
+
+ DNSRequestTracker();
+
+ protected:
+ virtual Action DoAddEntry(const Entry& entry, SourceInfo* out_info);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DNSRequestTracker);
+ };
+
+ // Tracks the log entries for the last seen SOURCE_HOST_RESOLVER_IMPL_JOB.
+ class DNSJobTracker : public SourceTracker {
+ public:
+ static const size_t kMaxNumSources;
+ static const size_t kMaxGraveyardSize;
+
+ DNSJobTracker();
+
+ protected:
+ virtual Action DoAddEntry(const Entry& entry, SourceInfo* out_info);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(DNSJobTracker);
+ };
+
PassiveLogCollector();
~PassiveLogCollector();
@@ -317,6 +347,8 @@ class PassiveLogCollector : public ChromeNetLog::Observer {
RequestTracker socket_stream_tracker_;
InitProxyResolverTracker init_proxy_resolver_tracker_;
SpdySessionTracker spdy_session_tracker_;
+ DNSRequestTracker dns_request_tracker_;
+ DNSJobTracker dns_job_tracker_;
// This array maps each NetLog::SourceType to one of the tracker instances
// defined above. Use of this array avoid duplicating the list of trackers