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

Unified Diff: content/browser/loader/navigation_resource_throttle.cc

Issue 1721813002: Adding DRP specfic UMA for FirstContentfulPaint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 years, 7 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
Index: content/browser/loader/navigation_resource_throttle.cc
diff --git a/content/browser/loader/navigation_resource_throttle.cc b/content/browser/loader/navigation_resource_throttle.cc
index cc69069a9d7e41d206a0e2811925188bfd3ac8f9..b7d91f0498ac125de16b24a4b936d765629980ed 100644
--- a/content/browser/loader/navigation_resource_throttle.cc
+++ b/content/browser/loader/navigation_resource_throttle.cc
@@ -1,25 +1,29 @@
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "content/browser/loader/navigation_resource_throttle.h"
+#include <memory>
+
#include "base/bind.h"
#include "base/callback.h"
#include "base/location.h"
#include "base/logging.h"
#include "content/browser/frame_host/navigation_handle_impl.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/navigation_data.h"
#include "content/public/browser/resource_context.h"
#include "content/public/browser/resource_controller.h"
+#include "content/public/browser/resource_dispatcher_host_delegate.h"
#include "content/public/browser/resource_request_info.h"
#include "content/public/common/referrer.h"
#include "net/url_request/redirect_info.h"
#include "net/url_request/url_request.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_job_factory.h"
#include "ui/base/page_transition_types.h"
namespace content {
@@ -92,45 +96,53 @@ void CheckWillRedirectRequestOnUIThread(
->FilterURL(false, &new_validated_url);
navigation_handle->WillRedirectRequest(
new_validated_url, new_method, new_referrer_url, new_is_external_protocol,
headers, base::Bind(&SendCheckResultToIOThread, callback));
}
void WillProcessResponseOnUIThread(
UIChecksPerformedCallback callback,
int render_process_id,
int render_frame_host_id,
- scoped_refptr<net::HttpResponseHeaders> headers) {
+ scoped_refptr<net::HttpResponseHeaders> headers,
+ std::unique_ptr<NavigationData> navigation_data) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
RenderFrameHostImpl* render_frame_host =
RenderFrameHostImpl::FromID(render_process_id, render_frame_host_id);
if (!render_frame_host) {
SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED);
return;
}
NavigationHandleImpl* navigation_handle =
render_frame_host->navigation_handle();
if (!navigation_handle) {
SendCheckResultToIOThread(callback, NavigationThrottle::PROCEED);
return;
}
+ if (navigation_data)
+ navigation_handle->set_navigation_data(std::move(navigation_data));
+
navigation_handle->WillProcessResponse(
render_frame_host, headers,
base::Bind(&SendCheckResultToIOThread, callback));
}
} // namespace
-NavigationResourceThrottle::NavigationResourceThrottle(net::URLRequest* request)
- : request_(request), weak_ptr_factory_(this) {}
+NavigationResourceThrottle::NavigationResourceThrottle(
+ net::URLRequest* request,
+ ResourceDispatcherHostDelegate* resource_dispatcher_host_delegate)
+ : request_(request),
+ resource_dispatcher_host_delegate_(resource_dispatcher_host_delegate),
+ weak_ptr_factory_(this) {}
NavigationResourceThrottle::~NavigationResourceThrottle() {}
void NavigationResourceThrottle::WillStartRequest(bool* defer) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
const ResourceRequestInfo* info = ResourceRequestInfo::ForRequest(request_);
if (!info)
return;
int render_process_id, render_frame_id;
@@ -206,28 +218,40 @@ void NavigationResourceThrottle::WillProcessResponse(bool* defer) {
return;
// Send a copy of the response headers to the NavigationHandle on the UI
// thread.
scoped_refptr<net::HttpResponseHeaders> response_headers;
if (request_->response_headers()) {
response_headers = new net::HttpResponseHeaders(
request_->response_headers()->raw_headers());
}
+ std::unique_ptr<NavigationData> cloned_data;
+ if (resource_dispatcher_host_delegate_) {
+ // Ask the embedder for a NavigationData instance.
+ NavigationData* navigation_data =
+ resource_dispatcher_host_delegate_->GetNavigationData(request_);
+
+ // Clone the embedder's NavigationData before moving it to the UI thread.
+ if (navigation_data)
+ cloned_data = navigation_data->Clone();
+ }
+
UIChecksPerformedCallback callback =
base::Bind(&NavigationResourceThrottle::OnUIChecksPerformed,
weak_ptr_factory_.GetWeakPtr());
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&WillProcessResponseOnUIThread, callback, render_process_id,
- render_frame_id, response_headers));
+ render_frame_id, response_headers,
+ base::Passed(&cloned_data)));
*defer = true;
}
const char* NavigationResourceThrottle::GetNameForLogging() const {
return "NavigationResourceThrottle";
}
void NavigationResourceThrottle::OnUIChecksPerformed(
NavigationThrottle::ThrottleCheckResult result) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
« no previous file with comments | « content/browser/loader/navigation_resource_throttle.h ('k') | content/browser/loader/navigation_url_loader_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698