diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-28 22:25:59 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-28 22:25:59 +0000 |
commit | 7b496b3cc7299672eaeff93fba4a444576c60214 (patch) | |
tree | cf178fa966eff186b2918b40fc1ddb9d038287ac | |
parent | 5d97aa4302484c9fd7b78395f30dd4b063731861 (diff) | |
download | chromium_src-7b496b3cc7299672eaeff93fba4a444576c60214.zip chromium_src-7b496b3cc7299672eaeff93fba4a444576c60214.tar.gz chromium_src-7b496b3cc7299672eaeff93fba4a444576c60214.tar.bz2 |
Update NetLog in preparation for late binding of HttpStream jobs to requests.
BUG=54371,42669
TEST=Open up about:net-internals#Events and make sure HTTP_STREAM_JOBs appear and are tied together to URL_REQUESTs.
Review URL: http://codereview.chromium.org/6592027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76287 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/net/passive_log_collector.cc | 41 | ||||
-rw-r--r-- | chrome/browser/net/passive_log_collector.h | 39 | ||||
-rw-r--r-- | chrome/browser/net/passive_log_collector_unittest.cc | 158 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/sourceentry.js | 1 | ||||
-rw-r--r-- | net/base/host_resolver_impl.cc | 2 | ||||
-rw-r--r-- | net/base/net_log_event_type_list.h | 19 | ||||
-rw-r--r-- | net/base/net_log_source_type_list.h | 3 | ||||
-rw-r--r-- | net/http/http_stream_factory_impl.cc | 5 | ||||
-rw-r--r-- | net/http/http_stream_factory_impl_job.cc | 12 | ||||
-rw-r--r-- | net/http/http_stream_factory_impl_job.h | 2 | ||||
-rw-r--r-- | net/http/http_stream_factory_impl_request.cc | 15 | ||||
-rw-r--r-- | net/http/http_stream_factory_impl_request.h | 11 |
12 files changed, 198 insertions, 110 deletions
diff --git a/chrome/browser/net/passive_log_collector.cc b/chrome/browser/net/passive_log_collector.cc index 8ac8e53..a4f8b5b 100644 --- a/chrome/browser/net/passive_log_collector.cc +++ b/chrome/browser/net/passive_log_collector.cc @@ -54,6 +54,7 @@ PassiveLogCollector::PassiveLogCollector() ALLOW_THIS_IN_INITIALIZER_LIST(connect_job_tracker_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(url_request_tracker_(this)), ALLOW_THIS_IN_INITIALIZER_LIST(socket_stream_tracker_(this)), + ALLOW_THIS_IN_INITIALIZER_LIST(http_stream_job_tracker_(this)), num_events_seen_(0) { // Define the mapping between source types and the tracker objects. @@ -70,6 +71,7 @@ PassiveLogCollector::PassiveLogCollector() &dns_request_tracker_; trackers_[net::NetLog::SOURCE_HOST_RESOLVER_IMPL_JOB] = &dns_job_tracker_; trackers_[net::NetLog::SOURCE_DISK_CACHE_ENTRY] = &disk_cache_entry_tracker_; + trackers_[net::NetLog::SOURCE_HTTP_STREAM_JOB] = &http_stream_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; @@ -345,8 +347,7 @@ void PassiveLogCollector::SourceTracker::AddReferenceToSourceDependency( info->dependencies.push_back(source); } -void -PassiveLogCollector::SourceTracker::ReleaseAllReferencesToDependencies( +void PassiveLogCollector::SourceTracker::ReleaseAllReferencesToDependencies( SourceInfo* info) { // Release all references |info| was holding to other sources. for (SourceDependencyList::const_iterator it = info->dependencies.begin(); @@ -445,8 +446,7 @@ PassiveLogCollector::RequestTracker::RequestTracker(PassiveLogCollector* parent) PassiveLogCollector::SourceTracker::Action PassiveLogCollector::RequestTracker::DoAddEntry( const ChromeNetLog::Entry& entry, SourceInfo* out_info) { - if (entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB || - entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET) { + if (entry.type == net::NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB) { const net::NetLog::Source& source_dependency = static_cast<net::NetLogSourceParameter*>(entry.params.get())->value(); AddReferenceToSourceDependency(source_dependency, out_info); @@ -585,3 +585,36 @@ PassiveLogCollector::DiskCacheEntryTracker::DoAddEntry( return ACTION_NONE; } + +//---------------------------------------------------------------------------- +// HttpStreamJobTracker +//---------------------------------------------------------------------------- + +const size_t PassiveLogCollector::HttpStreamJobTracker::kMaxNumSources = 100; +const size_t PassiveLogCollector::HttpStreamJobTracker::kMaxGraveyardSize = 25; + +PassiveLogCollector::HttpStreamJobTracker::HttpStreamJobTracker( + PassiveLogCollector* parent) + : SourceTracker(kMaxNumSources, kMaxGraveyardSize, parent) { +} + +PassiveLogCollector::SourceTracker::Action +PassiveLogCollector::HttpStreamJobTracker::DoAddEntry( + const ChromeNetLog::Entry& entry, SourceInfo* out_info) { + if (entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB || + entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET) { + const net::NetLog::Source& source_dependency = + static_cast<net::NetLogSourceParameter*>(entry.params.get())->value(); + AddReferenceToSourceDependency(source_dependency, out_info); + } + + AddEntryToSourceInfo(entry, out_info); + + // If the request has ended, move it to the graveyard. + if (entry.type == net::NetLog::TYPE_HTTP_STREAM_JOB && + entry.phase == net::NetLog::PHASE_END) { + return ACTION_MOVE_TO_GRAVEYARD; + } + + return ACTION_NONE; +} diff --git a/chrome/browser/net/passive_log_collector.h b/chrome/browser/net/passive_log_collector.h index a415d59..6c39ae9 100644 --- a/chrome/browser/net/passive_log_collector.h +++ b/chrome/browser/net/passive_log_collector.h @@ -200,10 +200,9 @@ class PassiveLogCollector : public ChromeNetLog::ThreadSafeObserver { explicit ConnectJobTracker(PassiveLogCollector* parent); - protected: + private: virtual Action DoAddEntry(const ChromeNetLog::Entry& entry, SourceInfo* out_info); - private: DISALLOW_COPY_AND_ASSIGN(ConnectJobTracker); }; @@ -215,11 +214,10 @@ class PassiveLogCollector : public ChromeNetLog::ThreadSafeObserver { SocketTracker(); - protected: + private: virtual Action DoAddEntry(const ChromeNetLog::Entry& entry, SourceInfo* out_info); - private: DISALLOW_COPY_AND_ASSIGN(SocketTracker); }; @@ -231,11 +229,10 @@ class PassiveLogCollector : public ChromeNetLog::ThreadSafeObserver { explicit RequestTracker(PassiveLogCollector* parent); - protected: + private: virtual Action DoAddEntry(const ChromeNetLog::Entry& entry, SourceInfo* out_info); - private: DISALLOW_COPY_AND_ASSIGN(RequestTracker); }; @@ -248,11 +245,10 @@ class PassiveLogCollector : public ChromeNetLog::ThreadSafeObserver { InitProxyResolverTracker(); - protected: + private: virtual Action DoAddEntry(const ChromeNetLog::Entry& entry, SourceInfo* out_info); - private: DISALLOW_COPY_AND_ASSIGN(InitProxyResolverTracker); }; @@ -264,11 +260,10 @@ class PassiveLogCollector : public ChromeNetLog::ThreadSafeObserver { SpdySessionTracker(); - protected: + private: virtual Action DoAddEntry(const ChromeNetLog::Entry& entry, SourceInfo* out_info); - private: DISALLOW_COPY_AND_ASSIGN(SpdySessionTracker); }; @@ -280,11 +275,10 @@ class PassiveLogCollector : public ChromeNetLog::ThreadSafeObserver { DNSRequestTracker(); - protected: + private: virtual Action DoAddEntry(const ChromeNetLog::Entry& entry, SourceInfo* out_info); - private: DISALLOW_COPY_AND_ASSIGN(DNSRequestTracker); }; @@ -296,11 +290,10 @@ class PassiveLogCollector : public ChromeNetLog::ThreadSafeObserver { DNSJobTracker(); - protected: + private: virtual Action DoAddEntry(const ChromeNetLog::Entry& entry, SourceInfo* out_info); - private: DISALLOW_COPY_AND_ASSIGN(DNSJobTracker); }; @@ -312,14 +305,27 @@ class PassiveLogCollector : public ChromeNetLog::ThreadSafeObserver { DiskCacheEntryTracker(); - protected: + private: virtual Action DoAddEntry(const ChromeNetLog::Entry& entry, SourceInfo* out_info); - private: DISALLOW_COPY_AND_ASSIGN(DiskCacheEntryTracker); }; + class HttpStreamJobTracker : public SourceTracker { + public: + static const size_t kMaxNumSources; + static const size_t kMaxGraveyardSize; + + explicit HttpStreamJobTracker(PassiveLogCollector* parent); + + private: + virtual Action DoAddEntry(const ChromeNetLog::Entry& entry, + SourceInfo* out_info); + DISALLOW_COPY_AND_ASSIGN(HttpStreamJobTracker); + }; + + PassiveLogCollector(); ~PassiveLogCollector(); @@ -357,6 +363,7 @@ class PassiveLogCollector : public ChromeNetLog::ThreadSafeObserver { DNSRequestTracker dns_request_tracker_; DNSJobTracker dns_job_tracker_; DiskCacheEntryTracker disk_cache_entry_tracker_; + HttpStreamJobTracker http_stream_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 diff --git a/chrome/browser/net/passive_log_collector_unittest.cc b/chrome/browser/net/passive_log_collector_unittest.cc index c948baa..91f238f 100644 --- a/chrome/browser/net/passive_log_collector_unittest.cc +++ b/chrome/browser/net/passive_log_collector_unittest.cc @@ -15,6 +15,7 @@ namespace { typedef PassiveLogCollector::RequestTracker RequestTracker; typedef PassiveLogCollector::SourceInfoList SourceInfoList; typedef PassiveLogCollector::SocketTracker SocketTracker; +typedef PassiveLogCollector::HttpStreamJobTracker HttpStreamJobTracker; using net::NetLog; const NetLog::SourceType kSourceType = NetLog::SOURCE_NONE; @@ -201,29 +202,29 @@ TEST(SpdySessionTracker, MovesToGraveyard) { EXPECT_EQ(1u, GetDeadSources(tracker).size()); } -// Test that when a SOURCE_SOCKET is connected to a SOURCE_URL_REQUEST -// (via the TYPE_SOCKET_POOL_BOUND_TO_SOCKET event), it holds a reference -// to the SOURCE_SOCKET preventing it from getting deleted as long as the -// SOURCE_URL_REQUEST is still around. +// Test that when a SOURCE_HTTP_STREAM_JOB is connected to a SOURCE_URL_REQUEST +// (via the TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB event), it holds a reference +// to the SOURCE_HTTP_STREAM_JOB preventing it from getting deleted as long as +// the SOURCE_URL_REQUEST is still around. TEST(PassiveLogCollectorTest, HoldReferenceToDependentSource) { PassiveLogCollector log; EXPECT_EQ(0u, GetLiveSources(log.url_request_tracker_).size()); - EXPECT_EQ(0u, GetLiveSources(log.socket_tracker_).size()); + EXPECT_EQ(0u, GetLiveSources(log.http_stream_job_tracker_).size()); uint32 next_id = 0; - NetLog::Source socket_source(NetLog::SOURCE_SOCKET, next_id++); + NetLog::Source stream_job_source(NetLog::SOURCE_HTTP_STREAM_JOB, next_id++); NetLog::Source url_request_source(NetLog::SOURCE_URL_REQUEST, next_id++); - // Start a SOURCE_SOCKET. - log.OnAddEntry(NetLog::TYPE_SOCKET_ALIVE, + // Start a SOURCE_HTTP_STREAM_JOB. + log.OnAddEntry(NetLog::TYPE_HTTP_STREAM_JOB, base::TimeTicks(), - socket_source, + stream_job_source, NetLog::PHASE_BEGIN, NULL); EXPECT_EQ(0u, GetLiveSources(log.url_request_tracker_).size()); - EXPECT_EQ(1u, GetLiveSources(log.socket_tracker_).size()); + EXPECT_EQ(1u, GetLiveSources(log.http_stream_job_tracker_).size()); // Start a SOURCE_URL_REQUEST. log.OnAddEntry(NetLog::TYPE_REQUEST_ALIVE, @@ -233,7 +234,7 @@ TEST(PassiveLogCollectorTest, HoldReferenceToDependentSource) { NULL); // Check that there is no association between the SOURCE_URL_REQUEST and the - // SOURCE_SOCKET yet. + // SOURCE_HTTP_STREAM_JOB yet. ASSERT_EQ(1u, GetLiveSources(log.url_request_tracker_).size()); { PassiveLogCollector::SourceInfo info = @@ -241,40 +242,40 @@ TEST(PassiveLogCollectorTest, HoldReferenceToDependentSource) { EXPECT_EQ(0, info.reference_count); EXPECT_EQ(0u, info.dependencies.size()); } - ASSERT_EQ(1u, GetLiveSources(log.socket_tracker_).size()); + ASSERT_EQ(1u, GetLiveSources(log.http_stream_job_tracker_).size()); { PassiveLogCollector::SourceInfo info = - GetLiveSources(log.socket_tracker_)[0]; + GetLiveSources(log.http_stream_job_tracker_)[0]; EXPECT_EQ(0, info.reference_count); EXPECT_EQ(0u, info.dependencies.size()); } - // Associate the SOURCE_SOCKET with the SOURCE_URL_REQUEST. - log.OnAddEntry(NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET, + // Associate the SOURCE_HTTP_STREAM_JOB with the SOURCE_URL_REQUEST. + log.OnAddEntry(NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB, base::TimeTicks(), url_request_source, NetLog::PHASE_NONE, - new net::NetLogSourceParameter("x", socket_source)); + new net::NetLogSourceParameter("x", stream_job_source)); // Check that an associate was made -- the SOURCE_URL_REQUEST should have - // added a reference to the SOURCE_SOCKET. + // added a reference to the SOURCE_HTTP_STREAM_JOB. ASSERT_EQ(1u, GetLiveSources(log.url_request_tracker_).size()); { PassiveLogCollector::SourceInfo info = GetLiveSources(log.url_request_tracker_)[0]; EXPECT_EQ(0, info.reference_count); EXPECT_EQ(1u, info.dependencies.size()); - EXPECT_EQ(socket_source.id, info.dependencies[0].id); + EXPECT_EQ(stream_job_source.id, info.dependencies[0].id); } - ASSERT_EQ(1u, GetLiveSources(log.socket_tracker_).size()); + ASSERT_EQ(1u, GetLiveSources(log.http_stream_job_tracker_).size()); { PassiveLogCollector::SourceInfo info = - GetLiveSources(log.socket_tracker_)[0]; + GetLiveSources(log.http_stream_job_tracker_)[0]; EXPECT_EQ(1, info.reference_count); EXPECT_EQ(0u, info.dependencies.size()); } - // Now end both |source_socket| and |source_url_request|. This sends them + // Now end both |stream_job_source| and |url_request_source|. This sends them // to deletion queue, and they will be deleted once space runs out. log.OnAddEntry(NetLog::TYPE_REQUEST_ALIVE, @@ -283,14 +284,14 @@ TEST(PassiveLogCollectorTest, HoldReferenceToDependentSource) { NetLog::PHASE_END, NULL); - log.OnAddEntry(NetLog::TYPE_SOCKET_ALIVE, + log.OnAddEntry(NetLog::TYPE_HTTP_STREAM_JOB, base::TimeTicks(), - socket_source, + stream_job_source, NetLog::PHASE_END, NULL); - // Verify that both sources are in fact dead, and that |source_url_request| - // still holds a reference to |source_socket|. + // Verify that both sources are in fact dead, and that |url_request_source| + // still holds a reference to |stream_job_source|. ASSERT_EQ(0u, GetLiveSources(log.url_request_tracker_).size()); ASSERT_EQ(1u, GetDeadSources(log.url_request_tracker_).size()); { @@ -298,41 +299,41 @@ TEST(PassiveLogCollectorTest, HoldReferenceToDependentSource) { GetDeadSources(log.url_request_tracker_)[0]; EXPECT_EQ(0, info.reference_count); EXPECT_EQ(1u, info.dependencies.size()); - EXPECT_EQ(socket_source.id, info.dependencies[0].id); + EXPECT_EQ(stream_job_source.id, info.dependencies[0].id); } - EXPECT_EQ(0u, GetLiveSources(log.socket_tracker_).size()); - ASSERT_EQ(1u, GetDeadSources(log.socket_tracker_).size()); + EXPECT_EQ(0u, GetLiveSources(log.http_stream_job_tracker_).size()); + ASSERT_EQ(1u, GetDeadSources(log.http_stream_job_tracker_).size()); { PassiveLogCollector::SourceInfo info = - GetDeadSources(log.socket_tracker_)[0]; + GetDeadSources(log.http_stream_job_tracker_)[0]; EXPECT_EQ(1, info.reference_count); EXPECT_EQ(0u, info.dependencies.size()); } - // Cycle through a bunch of SOURCE_SOCKET -- if it were not referenced, this - // loop will have deleted it. - for (size_t i = 0; i < SocketTracker::kMaxGraveyardSize; ++i) { - log.OnAddEntry(NetLog::TYPE_SOCKET_ALIVE, + // Cycle through a bunch of SOURCE_HTTP_STREAM_JOB -- if it were not + // referenced, this loop will have deleted it. + for (size_t i = 0; i < HttpStreamJobTracker::kMaxGraveyardSize; ++i) { + log.OnAddEntry(NetLog::TYPE_HTTP_STREAM_JOB, base::TimeTicks(), - NetLog::Source(NetLog::SOURCE_SOCKET, next_id++), + NetLog::Source(NetLog::SOURCE_HTTP_STREAM_JOB, next_id++), NetLog::PHASE_END, NULL); } - EXPECT_EQ(0u, GetLiveSources(log.socket_tracker_).size()); - ASSERT_EQ(SocketTracker::kMaxGraveyardSize + 1, - GetDeadSources(log.socket_tracker_).size()); + EXPECT_EQ(0u, GetLiveSources(log.http_stream_job_tracker_).size()); + ASSERT_EQ(HttpStreamJobTracker::kMaxGraveyardSize + 1, + GetDeadSources(log.http_stream_job_tracker_).size()); { PassiveLogCollector::SourceInfo info = - GetDeadSources(log.socket_tracker_)[0]; - EXPECT_EQ(socket_source.id, info.source_id); + GetDeadSources(log.http_stream_job_tracker_)[0]; + EXPECT_EQ(stream_job_source.id, info.source_id); EXPECT_EQ(1, info.reference_count); EXPECT_EQ(0u, info.dependencies.size()); } // Cycle through a bunch of SOURCE_URL_REQUEST -- this will cause - // |source_url_request| to be freed, which in turn should release the final - // reference to |source_socket| cause it to be freed as well. + // |url_request_source| to be freed, which in turn should release the final + // reference to |stream_job_source| cause it to be freed as well. for (size_t i = 0; i < RequestTracker::kMaxGraveyardSize; ++i) { log.OnAddEntry(NetLog::TYPE_REQUEST_ALIVE, base::TimeTicks(), @@ -345,25 +346,25 @@ TEST(PassiveLogCollectorTest, HoldReferenceToDependentSource) { EXPECT_EQ(RequestTracker::kMaxGraveyardSize, GetDeadSources(log.url_request_tracker_).size()); - EXPECT_EQ(0u, GetLiveSources(log.socket_tracker_).size()); - EXPECT_EQ(SocketTracker::kMaxGraveyardSize, - GetDeadSources(log.socket_tracker_).size()); + EXPECT_EQ(0u, GetLiveSources(log.http_stream_job_tracker_).size()); + EXPECT_EQ(HttpStreamJobTracker::kMaxGraveyardSize, + GetDeadSources(log.http_stream_job_tracker_).size()); } -// Have a URL_REQUEST hold a reference to a SOCKET. Then cause the SOCKET to -// get evicted (by exceeding maximum sources limit). Now the URL_REQUEST is -// referencing a non-existant SOCKET. Lastly, evict the URL_REQUEST so it +// Have a HTTP_STREAM_JOB hold a reference to a SOCKET. Then cause the SOCKET to +// get evicted (by exceeding maximum sources limit). Now the HTTP_STREAM_JOB is +// referencing a non-existant SOCKET. Lastly, evict the HTTP_STREAM_JOB so it // tries to drop all of its references. Make sure that in releasing its // non-existant reference it doesn't trip any DCHECKs. TEST(PassiveLogCollectorTest, HoldReferenceToDeletedSource) { PassiveLogCollector log; - EXPECT_EQ(0u, GetLiveSources(log.url_request_tracker_).size()); + EXPECT_EQ(0u, GetLiveSources(log.http_stream_job_tracker_).size()); EXPECT_EQ(0u, GetLiveSources(log.socket_tracker_).size()); uint32 next_id = 0; NetLog::Source socket_source(NetLog::SOURCE_SOCKET, next_id++); - NetLog::Source url_request_source(NetLog::SOURCE_URL_REQUEST, next_id++); + NetLog::Source stream_job_source(NetLog::SOURCE_HTTP_STREAM_JOB, next_id++); // Start a SOURCE_SOCKET. log.OnAddEntry(NetLog::TYPE_SOCKET_ALIVE, @@ -372,29 +373,29 @@ TEST(PassiveLogCollectorTest, HoldReferenceToDeletedSource) { NetLog::PHASE_BEGIN, NULL); - EXPECT_EQ(0u, GetLiveSources(log.url_request_tracker_).size()); + EXPECT_EQ(0u, GetLiveSources(log.http_stream_job_tracker_).size()); EXPECT_EQ(1u, GetLiveSources(log.socket_tracker_).size()); - // Start a SOURCE_URL_REQUEST. - log.OnAddEntry(NetLog::TYPE_REQUEST_ALIVE, + // Start a SOURCE_HTTP_STREAM_JOB. + log.OnAddEntry(NetLog::TYPE_HTTP_STREAM_JOB, base::TimeTicks(), - url_request_source, + stream_job_source, NetLog::PHASE_BEGIN, NULL); - // Associate the SOURCE_SOCKET with the SOURCE_URL_REQUEST. + // Associate the SOURCE_SOCKET with the SOURCE_HTTP_STREAM_JOB. log.OnAddEntry(NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET, base::TimeTicks(), - url_request_source, + stream_job_source, NetLog::PHASE_NONE, new net::NetLogSourceParameter("x", socket_source)); - // Check that an associate was made -- the SOURCE_URL_REQUEST should have + // Check that an associate was made -- the SOURCE_HTTP_STREAM_JOB should have // added a reference to the SOURCE_SOCKET. - ASSERT_EQ(1u, GetLiveSources(log.url_request_tracker_).size()); + ASSERT_EQ(1u, GetLiveSources(log.http_stream_job_tracker_).size()); { PassiveLogCollector::SourceInfo info = - GetLiveSources(log.url_request_tracker_)[0]; + GetLiveSources(log.http_stream_job_tracker_)[0]; EXPECT_EQ(0, info.reference_count); EXPECT_EQ(1u, info.dependencies.size()); EXPECT_EQ(socket_source.id, info.dependencies[0].id); @@ -422,20 +423,20 @@ TEST(PassiveLogCollectorTest, HoldReferenceToDeletedSource) { // requests to cause it to be deleted. Once that source is deleted, it will // try to give up its reference to the SOCKET. However that socket_id no // longer exists -- should not DCHECK(). - log.OnAddEntry(NetLog::TYPE_REQUEST_ALIVE, + log.OnAddEntry(NetLog::TYPE_HTTP_STREAM_JOB, base::TimeTicks(), - url_request_source, + stream_job_source, NetLog::PHASE_END, NULL); - for (size_t i = 0; i < RequestTracker::kMaxGraveyardSize; ++i) { - log.OnAddEntry(NetLog::TYPE_REQUEST_ALIVE, + for (size_t i = 0; i < HttpStreamJobTracker::kMaxGraveyardSize; ++i) { + log.OnAddEntry(NetLog::TYPE_HTTP_STREAM_JOB, base::TimeTicks(), - NetLog::Source(NetLog::SOURCE_URL_REQUEST, next_id++), + NetLog::Source(NetLog::SOURCE_HTTP_STREAM_JOB, next_id++), NetLog::PHASE_END, NULL); } - EXPECT_EQ(RequestTracker::kMaxGraveyardSize, - GetDeadSources(log.url_request_tracker_).size()); + EXPECT_EQ(HttpStreamJobTracker::kMaxGraveyardSize, + GetDeadSources(log.http_stream_job_tracker_).size()); } // Regression test for http://crbug.com/58847 @@ -443,17 +444,17 @@ TEST(PassiveLogCollectorTest, ReleaseDependencyToUnreferencedSource) { PassiveLogCollector log; // If these constants are weird, the test won't be testing the right thing. - EXPECT_LT(PassiveLogCollector::RequestTracker::kMaxGraveyardSize, - PassiveLogCollector::RequestTracker::kMaxNumSources); + EXPECT_LT(PassiveLogCollector::HttpStreamJobTracker::kMaxGraveyardSize, + PassiveLogCollector::HttpStreamJobTracker::kMaxNumSources); - // Add a "reference" to a non-existant source (sourceID=1706 does not exist). + // Add a "reference" to a non-existant source (sourceID=1263 does not exist). scoped_refptr<net::NetLog::EventParameters> params = new net::NetLogSourceParameter( "source_dependency", net::NetLog::Source(net::NetLog::SOURCE_SOCKET, 1263)); log.OnAddEntry(net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET, base::TimeTicks(), - net::NetLog::Source(net::NetLog::SOURCE_URL_REQUEST, 1706), + net::NetLog::Source(net::NetLog::SOURCE_HTTP_STREAM_JOB, 1706), net::NetLog::PHASE_NONE, params); @@ -461,9 +462,9 @@ TEST(PassiveLogCollectorTest, ReleaseDependencyToUnreferencedSource) { // reference count for 1263 was not adjusted since it doesn't actually exist. // Move source 1706 to the graveyard. - log.OnAddEntry(net::NetLog::TYPE_REQUEST_ALIVE, + log.OnAddEntry(net::NetLog::TYPE_HTTP_STREAM_JOB, base::TimeTicks(), - net::NetLog::Source(net::NetLog::SOURCE_URL_REQUEST, 1706), + net::NetLog::Source(net::NetLog::SOURCE_HTTP_STREAM_JOB, 1706), net::NetLog::PHASE_END, NULL); @@ -474,21 +475,20 @@ TEST(PassiveLogCollectorTest, ReleaseDependencyToUnreferencedSource) { net::NetLog::Source(net::NetLog::SOURCE_SOCKET, 1263), net::NetLog::PHASE_END, NULL); - // Add kMaxGraveyardSize unreferenced URL_REQUESTS, so the circular buffer - // containing source 1706. After adding kMaxGraveyardSize - 1 the buffer - // will be full. Now when we add one more more source it will now evict the - // oldest item, which is 1706. In doing so, 1706 will try to release the + // Add kMaxGraveyardSize unreferenced HTTP_STREAM_JOBS, so the circular + // buffer containing source 1706. After adding kMaxGraveyardSize - 1 the + // buffer will be full. Now when we add one more more source it will now evict + // the oldest item, which is 1706. In doing so, 1706 will try to release the // reference it *thinks* it has on 1263. However 1263 has a reference count // of 0 and is already in a graveyard. for (size_t i = 0; - i < PassiveLogCollector::RequestTracker::kMaxGraveyardSize; ++i) { - log.OnAddEntry(net::NetLog::TYPE_REQUEST_ALIVE, + i < PassiveLogCollector::HttpStreamJobTracker::kMaxGraveyardSize; ++i) { + log.OnAddEntry(net::NetLog::TYPE_HTTP_STREAM_JOB, base::TimeTicks(), - net::NetLog::Source(net::NetLog::SOURCE_URL_REQUEST, i), + net::NetLog::Source(net::NetLog::SOURCE_HTTP_STREAM_JOB, i), net::NetLog::PHASE_END, NULL); } // To pass, this should simply not have DCHECK-ed above. } - diff --git a/chrome/browser/resources/net_internals/sourceentry.js b/chrome/browser/resources/net_internals/sourceentry.js index 6c02c03..bd2a4cb 100644 --- a/chrome/browser/resources/net_internals/sourceentry.js +++ b/chrome/browser/resources/net_internals/sourceentry.js @@ -223,6 +223,7 @@ SourceEntry.prototype.getDescription = function() { switch (e.source.type) { case LogSourceType.URL_REQUEST: case LogSourceType.SOCKET_STREAM: + case LogSourceType.HTTP_STREAM_JOB: description = e.params.url; break; case LogSourceType.CONNECT_JOB: diff --git a/net/base/host_resolver_impl.cc b/net/base/host_resolver_impl.cc index 5c61b4f..7df346f 100644 --- a/net/base/host_resolver_impl.cc +++ b/net/base/host_resolver_impl.cc @@ -175,7 +175,7 @@ class RequestInfoParameters : public NetLog::EventParameters { const NetLog::Source source_; }; -// Parameters associated with the creation of a HostResolveImpl::Job. +// Parameters associated with the creation of a HostResolverImpl::Job. class JobCreationParameters : public NetLog::EventParameters { public: JobCreationParameters(const std::string& host, const NetLog::Source& source) diff --git a/net/base/net_log_event_type_list.h b/net/base/net_log_event_type_list.h index 0f1eecf..ec72cb4 100644 --- a/net/base/net_log_event_type_list.h +++ b/net/base/net_log_event_type_list.h @@ -468,7 +468,7 @@ EVENT_TYPE(SOCKET_POOL_BOUND_TO_SOCKET) EVENT_TYPE(SOCKET_POOL_CONNECTING_N_SOCKETS) // ------------------------------------------------------------------------ -// net::URLRequest +// URLRequest // ------------------------------------------------------------------------ // Measures the time it took a net::URLRequestJob to start. For the most part @@ -582,6 +582,23 @@ EVENT_TYPE(DISK_CACHE_CLOSE) EVENT_TYPE(DISK_CACHE_DOOM) // ------------------------------------------------------------------------ +// HttpStreamFactoryImpl +// ------------------------------------------------------------------------ + +// Measures the time taken to fulfill the HttpStreamRequest. +EVENT_TYPE(HTTP_STREAM_REQUEST) + +// Measures the time taken to execute the HttpStreamFactoryImpl::Job +EVENT_TYPE(HTTP_STREAM_JOB) + +// Identifies the NetLog::Source() for the Job that fulfilled the request. +// request. The event parameters are: +// { +// "source_dependency": <Source identifier for the job we acquired> +// } +EVENT_TYPE(HTTP_STREAM_REQUEST_BOUND_TO_JOB) + +// ------------------------------------------------------------------------ // HttpNetworkTransaction // ------------------------------------------------------------------------ diff --git a/net/base/net_log_source_type_list.h b/net/base/net_log_source_type_list.h index ba34955..d25986c 100644 --- a/net/base/net_log_source_type_list.h +++ b/net/base/net_log_source_type_list.h @@ -16,5 +16,6 @@ SOURCE_TYPE(SPDY_SESSION, 6) SOURCE_TYPE(HOST_RESOLVER_IMPL_REQUEST, 7) SOURCE_TYPE(HOST_RESOLVER_IMPL_JOB, 8) SOURCE_TYPE(DISK_CACHE_ENTRY, 9) +SOURCE_TYPE(HTTP_STREAM_JOB, 10) -SOURCE_TYPE(COUNT, 10) // Always keep this as the last entry. +SOURCE_TYPE(COUNT, 11) // Always keep this as the last entry. diff --git a/net/http/http_stream_factory_impl.cc b/net/http/http_stream_factory_impl.cc index e4e94b1..74942a3 100644 --- a/net/http/http_stream_factory_impl.cc +++ b/net/http/http_stream_factory_impl.cc @@ -34,7 +34,7 @@ HttpStreamRequest* HttpStreamFactoryImpl::RequestStream( HttpStreamRequest::Delegate* delegate, const BoundNetLog& net_log) { Job* job = new Job(this, session_); - Request* request = new Request(request_info.url, this, delegate); + Request* request = new Request(request_info.url, this, delegate, net_log); request_map_[job] = request; request->BindJob(job); job->Start(request, request_info, ssl_config, net_log); @@ -73,7 +73,8 @@ void HttpStreamFactoryImpl::OnSpdySessionReady( Request* request = request_map_[job]; request->Complete(job->was_alternate_protocol_available(), job->was_npn_negotiated(), - job->using_spdy()); + job->using_spdy(), + job->net_log().source()); bool use_relative_url = direct || request->url().SchemeIs("https"); request->OnStreamReady( job->ssl_config(), diff --git a/net/http/http_stream_factory_impl_job.cc b/net/http/http_stream_factory_impl_job.cc index 6884a79..8ae5f82 100644 --- a/net/http/http_stream_factory_impl_job.cc +++ b/net/http/http_stream_factory_impl_job.cc @@ -9,6 +9,7 @@ #include "base/string_number_conversions.h" #include "base/string_util.h" #include "base/stringprintf.h" +#include "base/values.h" #include "net/base/connection_type_histograms.h" #include "net/base/net_log.h" #include "net/base/net_util.h" @@ -76,6 +77,8 @@ HttpStreamFactoryImpl::Job::Job(HttpStreamFactoryImpl* stream_factory, } HttpStreamFactoryImpl::Job::~Job() { + net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_JOB, NULL); + // When we're in a partially constructed state, waiting for the user to // provide certificate handling information or authentication, we can't reuse // this stream at all. @@ -164,7 +167,8 @@ void HttpStreamFactoryImpl::Job::OnStreamReadyCallback() { DCHECK(stream_.get()); request_->Complete(was_alternate_protocol_available(), was_npn_negotiated(), - using_spdy()); + using_spdy(), + net_log_.source()); request_->OnStreamReady(ssl_config_, proxy_info_, stream_.release()); // |this| may be deleted after this call. } @@ -375,7 +379,11 @@ int HttpStreamFactoryImpl::Job::StartInternal( CHECK_EQ(STATE_NONE, next_state_); request_info_ = request_info; ssl_config_ = ssl_config; - net_log_ = net_log; + net_log_ = BoundNetLog::Make(net_log.net_log(), + NetLog::SOURCE_HTTP_STREAM_JOB); + net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_JOB, + make_scoped_refptr(new NetLogStringParameter( + "url", request_info.url.GetOrigin().spec()))); next_state_ = STATE_RESOLVE_PROXY; int rv = RunLoop(OK); DCHECK_EQ(ERR_IO_PENDING, rv); diff --git a/net/http/http_stream_factory_impl_job.h b/net/http/http_stream_factory_impl_job.h index 59b0b09..5a8f029 100644 --- a/net/http/http_stream_factory_impl_job.h +++ b/net/http/http_stream_factory_impl_job.h @@ -9,6 +9,7 @@ #include "base/scoped_ptr.h" #include "base/task.h" #include "net/base/completion_callback.h" +#include "net/base/net_log.h" #include "net/base/ssl_config_service.h" #include "net/http/http_alternate_protocols.h" #include "net/http/http_auth.h" @@ -59,6 +60,7 @@ class HttpStreamFactoryImpl::Job { bool was_alternate_protocol_available() const; bool was_npn_negotiated() const; bool using_spdy() const; + const BoundNetLog& net_log() const { return net_log_; } const SSLConfig& ssl_config() const; const ProxyInfo& proxy_info() const; diff --git a/net/http/http_stream_factory_impl_request.cc b/net/http/http_stream_factory_impl_request.cc index 7826659..b6e6b9f 100644 --- a/net/http/http_stream_factory_impl_request.cc +++ b/net/http/http_stream_factory_impl_request.cc @@ -12,10 +12,12 @@ namespace net { HttpStreamFactoryImpl::Request::Request(const GURL& url, HttpStreamFactoryImpl* factory, - HttpStreamRequest::Delegate* delegate) + HttpStreamRequest::Delegate* delegate, + const BoundNetLog& net_log) : url_(url), factory_(factory), delegate_(delegate), + net_log_(net_log), job_(NULL), completed_(false), was_alternate_protocol_available_(false), @@ -23,9 +25,13 @@ HttpStreamFactoryImpl::Request::Request(const GURL& url, using_spdy_(false) { DCHECK(factory_); DCHECK(delegate_); + + net_log_.BeginEvent(NetLog::TYPE_HTTP_STREAM_REQUEST, NULL); } HttpStreamFactoryImpl::Request::~Request() { + net_log_.EndEvent(NetLog::TYPE_HTTP_STREAM_REQUEST, NULL); + factory_->request_map_.erase(job_); // TODO(willchan): Remove this when we decouple requests and jobs. @@ -53,12 +59,17 @@ void HttpStreamFactoryImpl::Request::BindJob(HttpStreamFactoryImpl::Job* job) { void HttpStreamFactoryImpl::Request::Complete( bool was_alternate_protocol_available, bool was_npn_negotiated, - bool using_spdy) { + bool using_spdy, + const NetLog::Source& job_source) { DCHECK(!completed_); completed_ = true; was_alternate_protocol_available_ = was_alternate_protocol_available; was_npn_negotiated_ = was_npn_negotiated; using_spdy_ = using_spdy; + net_log_.AddEvent( + NetLog::TYPE_HTTP_STREAM_REQUEST_BOUND_TO_JOB, + make_scoped_refptr(new NetLogSourceParameter( + "source_dependency", job_source))); } void HttpStreamFactoryImpl::Request::OnStreamReady( diff --git a/net/http/http_stream_factory_impl_request.h b/net/http/http_stream_factory_impl_request.h index 468ebd3..e7eadbe 100644 --- a/net/http/http_stream_factory_impl_request.h +++ b/net/http/http_stream_factory_impl_request.h @@ -7,6 +7,7 @@ #include "base/scoped_ptr.h" #include "googleurl/src/gurl.h" +#include "net/base/net_log.h" #include "net/http/http_stream_factory_impl.h" namespace net { @@ -15,7 +16,8 @@ class HttpStreamFactoryImpl::Request : public HttpStreamRequest { public: Request(const GURL& url, HttpStreamFactoryImpl* factory, - HttpStreamRequest::Delegate* delegate); + HttpStreamRequest::Delegate* delegate, + const BoundNetLog& net_log); virtual ~Request(); // Returns the Job that the Request started up. @@ -34,9 +36,12 @@ class HttpStreamFactoryImpl::Request : public HttpStreamRequest { void BindJob(HttpStreamFactoryImpl::Job* job); // Marks completion of the request. Must be called before OnStreamReady(). + // |source| is the NetLog::Source generated by the Job that fulfilled this + // request. void Complete(bool was_alternate_protocol_available, bool was_npn_negotiated, - bool using_spdy); + bool using_spdy, + const NetLog::Source& source); // If this Request has a spdy_session_key, remove this session from the // SpdySessionRequestMap. @@ -77,6 +82,7 @@ class HttpStreamFactoryImpl::Request : public HttpStreamRequest { const GURL url_; HttpStreamFactoryImpl* const factory_; HttpStreamRequest::Delegate* const delegate_; + const BoundNetLog net_log_; // The |job_| that this request is tied to. HttpStreamFactoryImpl::Job* job_; @@ -91,4 +97,5 @@ class HttpStreamFactoryImpl::Request : public HttpStreamRequest { }; } // namespace net + #endif // NET_HTTP_HTTP_STREAM_FACTORY_IMPL_H_ |