Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1260)

Unified Diff: chrome/browser/loader/chrome_resource_dispatcher_host_delegate.cc

Issue 2780003003: Send an event to the page load metrics to track resource starting. (Closed)
Patch Set: FREEZE.unindexed - took merge and fixed it up Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/page_load_metrics/metrics_web_contents_observer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2123d4fd3cefd8a6427fbc319a587fd018e7f5ac..a0c7a7b47bb87de9b963d3031bf062ae65e5d38c 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(
+ 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,
@@ -446,6 +466,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);
« no previous file with comments | « chrome/browser/BUILD.gn ('k') | chrome/browser/page_load_metrics/metrics_web_contents_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698