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

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: NavigationData final draft before adding tests Created 4 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
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 63210620c9f3fb59a790033b72efd34d153183d6..4f84184fe3e7c00e40adfaf88a0752921f089506 100644
--- a/content/browser/loader/navigation_resource_throttle.cc
+++ b/content/browser/loader/navigation_resource_throttle.cc
@@ -1,25 +1,30 @@
// 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/browser/loader/resource_dispatcher_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 {
@@ -93,45 +98,52 @@ void CheckWillRedirectRequestOnUIThread(
navigation_handle->WillRedirectRequest(
new_validated_url, new_method_is_post, 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.get()) {
nasko 2016/04/26 20:18:40 nit: No need for {} on one line if statements.
RyanSturm 2016/04/27 23:27:47 Done.
+ navigation_handle->SetNavigationData(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,
+ ResourceDispatcherHostImpl* rdh)
+ : request_(request), rdh_(rdh), 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;
@@ -208,28 +220,38 @@ 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());
}
+ // Ask the embedder for a NavigationData instance.
+ std::unique_ptr<NavigationData> navigation_data(nullptr);
+ if (rdh_ && rdh_->delegate())
+ navigation_data = rdh_->delegate()->GetNavigationData(request_);
+
+ // Clone the embedder NavigationData before moving it to the UI thread.
+ std::unique_ptr<NavigationData> clone(nullptr);
+ if (navigation_data.get())
+ clone = 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(&clone)));
*defer = true;
}
const char* NavigationResourceThrottle::GetNameForLogging() const {
return "NavigationResourceThrottle";
}
void NavigationResourceThrottle::OnUIChecksPerformed(
NavigationThrottle::ThrottleCheckResult result) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);

Powered by Google App Engine
This is Rietveld 408576698