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

Side by Side Diff: content/browser/loader/navigation_resource_handler.cc

Issue 1721813002: Adding DRP specfic UMA for FirstContentfulPaint (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments from nasko@ 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/loader/navigation_resource_handler.h" 5 #include "content/browser/loader/navigation_resource_handler.h"
6 6
7 #include <memory>
8
7 #include "base/logging.h" 9 #include "base/logging.h"
8 #include "content/browser/devtools/devtools_netlog_observer.h" 10 #include "content/browser/devtools/devtools_netlog_observer.h"
9 #include "content/browser/loader/navigation_url_loader_impl_core.h" 11 #include "content/browser/loader/navigation_url_loader_impl_core.h"
12 #include "content/browser/loader/resource_dispatcher_host_impl.h"
10 #include "content/browser/loader/resource_request_info_impl.h" 13 #include "content/browser/loader/resource_request_info_impl.h"
11 #include "content/browser/resource_context_impl.h" 14 #include "content/browser/resource_context_impl.h"
12 #include "content/browser/streams/stream.h" 15 #include "content/browser/streams/stream.h"
13 #include "content/browser/streams/stream_context.h" 16 #include "content/browser/streams/stream_context.h"
17 #include "content/public/browser/navigation_data.h"
14 #include "content/public/browser/resource_controller.h" 18 #include "content/public/browser/resource_controller.h"
19 #include "content/public/browser/resource_dispatcher_host_delegate.h"
15 #include "content/public/browser/stream_handle.h" 20 #include "content/public/browser/stream_handle.h"
16 #include "content/public/common/resource_response.h" 21 #include "content/public/common/resource_response.h"
17 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
18 #include "net/url_request/url_request.h" 23 #include "net/url_request/url_request.h"
19 24
20 namespace content { 25 namespace content {
21 26
22 NavigationResourceHandler::NavigationResourceHandler( 27 NavigationResourceHandler::NavigationResourceHandler(
23 net::URLRequest* request, 28 net::URLRequest* request,
24 NavigationURLLoaderImplCore* core) 29 NavigationURLLoaderImplCore* core,
30 ResourceDispatcherHostImpl* resource_dispatcher_host)
25 : ResourceHandler(request), 31 : ResourceHandler(request),
26 core_(core) { 32 core_(core),
33 resource_dispatcher_host_(resource_dispatcher_host) {
27 core_->set_resource_handler(this); 34 core_->set_resource_handler(this);
28 writer_.set_immediate_mode(true); 35 writer_.set_immediate_mode(true);
29 } 36 }
30 37
31 NavigationResourceHandler::~NavigationResourceHandler() { 38 NavigationResourceHandler::~NavigationResourceHandler() {
32 if (core_) { 39 if (core_) {
33 core_->NotifyRequestFailed(false, net::ERR_ABORTED); 40 core_->NotifyRequestFailed(false, net::ERR_ABORTED);
34 DetachFromCore(); 41 DetachFromCore();
35 } 42 }
36 } 43 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 // dispatched at the navigation layer. 92 // dispatched at the navigation layer.
86 if (info->IsDownload() || info->is_stream()) 93 if (info->IsDownload() || info->is_stream())
87 return true; 94 return true;
88 95
89 StreamContext* stream_context = 96 StreamContext* stream_context =
90 GetStreamContextForResourceContext(info->GetContext()); 97 GetStreamContextForResourceContext(info->GetContext());
91 writer_.InitializeStream(stream_context->registry(), 98 writer_.InitializeStream(stream_context->registry(),
92 request()->url().GetOrigin()); 99 request()->url().GetOrigin());
93 100
94 DevToolsNetLogObserver::PopulateResponseInfo(request(), response); 101 DevToolsNetLogObserver::PopulateResponseInfo(request(), response);
95 core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle()); 102
103 // Ask the embedder for a NavigationData instance.
104 std::unique_ptr<NavigationData> navigation_data;
105 std::unique_ptr<NavigationData> cloned_data;
106 if (resource_dispatcher_host_ && resource_dispatcher_host_->delegate()) {
107 navigation_data =
108 resource_dispatcher_host_->delegate()->GetNavigationData(request());
mmenke 2016/05/03 16:06:24 Accessing the RDH and/or its delegate here seems f
bengr 2016/05/03 17:41:55 So we started with a unique_ptr, so we could simpl
RyanSturm 2016/05/03 18:14:13 Switching to RDHDelegate.
mmenke 2016/05/03 19:32:53 The thing is, the object is created on demand, and
109
110 // Clone the embedder's NavigationData before moving it to the UI thread.
111 if (navigation_data)
112 cloned_data = navigation_data->Clone();
113 }
114
115 core_->NotifyResponseStarted(response, writer_.stream()->CreateHandle(),
116 std::move(cloned_data));
96 *defer = true; 117 *defer = true;
118
97 return true; 119 return true;
98 } 120 }
99 121
100 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) { 122 bool NavigationResourceHandler::OnWillStart(const GURL& url, bool* defer) {
101 return true; 123 return true;
102 } 124 }
103 125
104 bool NavigationResourceHandler::OnBeforeNetworkStart(const GURL& url, 126 bool NavigationResourceHandler::OnBeforeNetworkStart(const GURL& url,
105 bool* defer) { 127 bool* defer) {
106 return true; 128 return true;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 NOTREACHED(); 165 NOTREACHED();
144 } 166 }
145 167
146 void NavigationResourceHandler::DetachFromCore() { 168 void NavigationResourceHandler::DetachFromCore() {
147 DCHECK(core_); 169 DCHECK(core_);
148 core_->set_resource_handler(nullptr); 170 core_->set_resource_handler(nullptr);
149 core_ = nullptr; 171 core_ = nullptr;
150 } 172 }
151 173
152 } // namespace content 174 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698