Chromium Code Reviews| 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 a9d0044df47a9a7af6fe433e9725592283b97c8f..1ba0e3c369da44aead35ba54b34edeb51b460eb1 100644 |
| --- a/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc |
| +++ b/chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc |
| @@ -354,6 +354,24 @@ void LogMainFrameMetricsOnUIThread(const GURL& url, |
| } |
| } |
| +void NotifyUIThreadOfRequestStarted( |
| + const content::ResourceRequestInfo::WebContentsGetter& web_contents_getter, |
| + const GURL& url, |
|
RyanSturm
2017/03/29 19:03:47
Are you using url here?
Pete Williamson
2017/04/13 23:10:21
Done.
|
| + const content::GlobalRequestID& request_id, |
| + ResourceType resource_type, |
| + base::TimeTicks request_creation_time) { |
| + content::WebContents* web_contents = web_contents_getter.Run(); |
| + |
| + 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, |
| @@ -442,6 +460,9 @@ bool ChromeResourceDispatcherHostDelegate::ShouldBeginRequest( |
| return true; |
| } |
| +// TODO: REVIEWERS: appcache_service is apparently not used. Is there any |
| +// reason that I shouldn't remove it? (Maybe it's a part of some interface used |
| +// elsewhere.) |
| void ChromeResourceDispatcherHostDelegate::RequestBeginning( |
| net::URLRequest* request, |
| content::ResourceContext* resource_context, |
| @@ -453,6 +474,15 @@ void ChromeResourceDispatcherHostDelegate::RequestBeginning( |
| 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. |
| + BrowserThread::PostTask( |
| + BrowserThread::UI, FROM_HERE, |
| + base::Bind(&NotifyUIThreadOfRequestStarted, |
| + info->GetWebContentsGetterForRequest(), request->url(), |
| + info->GetGlobalRequestID(), info->GetResourceType(), |
| + request->creation_time())); |
| + |
| // The lowering of request priority causes issues with scheduling, since |
| // content::ResourceScheduler uses it to delay and throttle requests. This is |
| // disabled only on Android, as the prerenders are not likely to compete with |