diff options
author | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 02:36:16 +0000 |
---|---|---|
committer | eroman@chromium.org <eroman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-04 02:36:16 +0000 |
commit | c31a5459ed8dede7085508a47cb69370d73b4521 (patch) | |
tree | f40dbd661f82a438ad7d9c071d2d43b8f015bc49 /net | |
parent | 813feb8fb79098c0188cbdd1676829fb74bd43b0 (diff) | |
download | chromium_src-c31a5459ed8dede7085508a47cb69370d73b4521.zip chromium_src-c31a5459ed8dede7085508a47cb69370d73b4521.tar.gz chromium_src-c31a5459ed8dede7085508a47cb69370d73b4521.tar.bz2 |
Add trace-point for URLRequest to the LoadLog.
This is probably the most important metric, since it measures the initial latency of the request (until when we get the headers back).
BUG=http://crbug.com/14478
Review URL: http://codereview.chromium.org/194018
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25425 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/load_log_event_type_list.h | 7 | ||||
-rw-r--r-- | net/url_request/url_request.cc | 4 | ||||
-rw-r--r-- | net/url_request/url_request_unittest.cc | 11 |
3 files changed, 22 insertions, 0 deletions
diff --git a/net/base/load_log_event_type_list.h b/net/base/load_log_event_type_list.h index 75b84b3..28cfc03 100644 --- a/net/base/load_log_event_type_list.h +++ b/net/base/load_log_event_type_list.h @@ -87,4 +87,11 @@ EVENT_TYPE(SOCKET_POOL_STALLED_MAX_SOCKETS) // The request stalled because there are too many sockets in the group. EVENT_TYPE(SOCKET_POOL_STALLED_MAX_SOCKETS_PER_GROUP) +// ------------------------------------------------------------------------ +// URLRequest +// ------------------------------------------------------------------------ + +// Measures the time between URLRequest::Start() and +// URLRequest::ResponseStarted(). +EVENT_TYPE(URL_REQUEST_START) diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc index e41965c..bf24c2d 100644 --- a/net/url_request/url_request.cc +++ b/net/url_request/url_request.cc @@ -360,6 +360,8 @@ void URLRequest::StartJob(URLRequestJob* job) { DCHECK(!is_pending_); DCHECK(!job_); + net::LoadLog::BeginEvent(load_log_, net::LoadLog::TYPE_URL_REQUEST_START); + job_ = job; job_->SetExtraRequestHeaders(extra_request_headers_); @@ -459,6 +461,8 @@ void URLRequest::ReceivedRedirect(const GURL& location, bool* defer_redirect) { } void URLRequest::ResponseStarted() { + net::LoadLog::EndEvent(load_log_, net::LoadLog::TYPE_URL_REQUEST_START); + URLRequestJob* job = GetJobManager()->MaybeInterceptResponse(this); if (job) { RestartWithJob(job); diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc index f4a795b..5448819 100644 --- a/net/url_request/url_request_unittest.cc +++ b/net/url_request/url_request_unittest.cc @@ -24,6 +24,8 @@ #include "base/string_util.h" #include "net/base/cookie_monster.h" #include "net/base/load_flags.h" +#include "net/base/load_log.h" +#include "net/base/load_log_unittest.h" #include "net/base/net_errors.h" #include "net/base/net_module.h" #include "net/base/net_util.h" @@ -202,6 +204,15 @@ TEST_F(URLRequestTestHTTP, GetTest_NoCache) { EXPECT_EQ(1, d.response_started_count()); EXPECT_FALSE(d.received_data_before_response()); EXPECT_NE(0, d.bytes_received()); + + // The first and last entries of the LoadLog should be for + // TYPE_URL_REQUEST_START. + net::ExpectLogContains(r.load_log(), 0, + net::LoadLog::TYPE_URL_REQUEST_START, + net::LoadLog::PHASE_BEGIN); + net::ExpectLogContains(r.load_log(), r.load_log()->events().size() - 1, + net::LoadLog::TYPE_URL_REQUEST_START, + net::LoadLog::PHASE_END); } } |