diff --git a/libcef/browser/resource_request_job.cc b/libcef/browser/resource_request_job.cc index d6767b381..af53a2ce0 100644 --- a/libcef/browser/resource_request_job.cc +++ b/libcef/browser/resource_request_job.cc @@ -164,6 +164,7 @@ CefResourceRequestJob::~CefResourceRequestJob() { void CefResourceRequestJob::Start() { CEF_REQUIRE_IOT(); + request_start_time_ = base::Time::Now(); cef_request_ = CefRequest::Create(); // Populate the request data. @@ -285,6 +286,16 @@ void CefResourceRequestJob::GetResponseInfo(net::HttpResponseInfo* info) { info->headers = GetResponseHeaders(); } +void CefResourceRequestJob::GetLoadTimingInfo( + net::LoadTimingInfo* load_timing_info) const { + // If haven't made it far enough to receive any headers, don't return + // anything. This makes for more consistent behavior in the case of errors. + if (!response_ || receive_headers_end_.is_null()) + return; + load_timing_info->request_start_time = request_start_time_; + load_timing_info->receive_headers_end = receive_headers_end_; +} + bool CefResourceRequestJob::GetResponseCookies( std::vector* cookies) { CEF_REQUIRE_IOT(); @@ -349,6 +360,7 @@ void CefResourceRequestJob::SendHeaders() { // Get header information from the handler. handler_->GetResponseHeaders(response_, remaining_bytes_, redirectUrl); + receive_headers_end_ = base::TimeTicks::Now(); if (!redirectUrl.empty()) { std::string redirectUrlStr = redirectUrl; redirect_url_ = GURL(redirectUrlStr); diff --git a/libcef/browser/resource_request_job.h b/libcef/browser/resource_request_job.h index 5002cef3d..0bfd4f6e0 100644 --- a/libcef/browser/resource_request_job.h +++ b/libcef/browser/resource_request_job.h @@ -36,6 +36,8 @@ class CefResourceRequestJob : public net::URLRequestJob { virtual bool ReadRawData(net::IOBuffer* dest, int dest_size, int* bytes_read) OVERRIDE; virtual void GetResponseInfo(net::HttpResponseInfo* info) OVERRIDE; + virtual void GetLoadTimingInfo( + net::LoadTimingInfo* load_timing_info) const OVERRIDE; virtual bool GetResponseCookies(std::vector* cookies) OVERRIDE; virtual bool IsRedirectResponse(GURL* location, int* http_status_code) OVERRIDE; @@ -69,6 +71,10 @@ class CefResourceRequestJob : public net::URLRequestJob { scoped_refptr response_headers_; std::vector response_cookies_; size_t response_cookies_save_index_; + base::Time request_start_time_; + base::TimeTicks receive_headers_end_; + + // Must be the last member. base::WeakPtrFactory weak_factory_; friend class CefResourceRequestJobCallback;