Index: chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc |
diff --git a/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc b/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc |
index cc36f63584bf41e131932889a297f929981c2f81..01064a142426c83f0558f469b02f750806cfa22a 100644 |
--- a/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc |
+++ b/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc |
@@ -345,6 +345,26 @@ void LogMainFrameMetricsOnUIThread(const GURL& url, |
} |
} |
+void NotifyUIThreadOfRequestStarted( |
Charlie Harrison
2017/04/18 16:51:32
Can we use WebContentsObserver::DidGetResourceResp
RyanSturm
2017/04/18 17:23:57
This seems to be called when headers are received.
Charlie Harrison
2017/04/18 17:38:35
Woops, you're right I completely misread the name
|
+ const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
+ const content::GlobalRequestID& request_id, |
+ ResourceType resource_type, |
+ base::TimeTicks request_creation_time) { |
+ content::WebContents* web_contents = web_contents_getter.Run(); |
+ |
+ if (!web_contents) |
+ return; |
+ |
+ page_load_metrics::MetricsWebContentsObserver* metrics_observer = |
+ page_load_metrics::MetricsWebContentsObserver::FromWebContents( |
+ web_contents); |
+ |
+ if (metrics_observer) { |
+ metrics_observer->OnRequestStarted(request_id, resource_type, |
+ request_creation_time); |
+ } |
+} |
+ |
void NotifyUIThreadOfRequestComplete( |
const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
const GURL& url, |
@@ -443,6 +463,17 @@ void ChromeResourceDispatcherHostDelegate::RequestBeginning( |
safe_browsing_->OnResourceRequest(request); |
const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request); |
+ |
+ // TODO(petewil): Unify the safe browsing request and the metrics observer |
+ // request if possible so we only have to cross to the main thread once. |
+ // http://crbug.com/712312. |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, FROM_HERE, |
+ base::Bind(&NotifyUIThreadOfRequestStarted, |
+ info->GetWebContentsGetterForRequest(), |
+ info->GetGlobalRequestID(), info->GetResourceType(), |
+ request->creation_time())); |
+ |
ProfileIOData* io_data = ProfileIOData::FromResourceContext( |
resource_context); |