summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/base/load_log_event_type_list.h7
-rw-r--r--net/url_request/url_request.cc4
-rw-r--r--net/url_request/url_request_unittest.cc11
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);
}
}