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

Side by Side Diff: content/browser/loader/navigation_url_loader_impl_core.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 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_url_loader_impl_core.h" 5 #include "content/browser/loader/navigation_url_loader_impl_core.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "content/browser/frame_host/navigation_request_info.h" 10 #include "content/browser/frame_host/navigation_request_info.h"
11 #include "content/browser/loader/navigation_resource_handler.h" 11 #include "content/browser/loader/navigation_resource_handler.h"
12 #include "content/browser/loader/resource_dispatcher_host_impl.h" 12 #include "content/browser/loader/resource_dispatcher_host_impl.h"
13 #include "content/browser/service_worker/service_worker_navigation_handle_core.h " 13 #include "content/browser/service_worker/service_worker_navigation_handle_core.h "
14 #include "content/common/navigation_params.h" 14 #include "content/common/navigation_params.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/navigation_data.h"
16 #include "content/public/browser/stream_handle.h" 17 #include "content/public/browser/stream_handle.h"
17 #include "content/public/common/resource_response.h" 18 #include "content/public/common/resource_response.h"
18 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
19 #include "net/url_request/redirect_info.h" 20 #include "net/url_request/redirect_info.h"
20 21
21 namespace content { 22 namespace content {
22 23
23 NavigationURLLoaderImplCore::NavigationURLLoaderImplCore( 24 NavigationURLLoaderImplCore::NavigationURLLoaderImplCore(
24 const base::WeakPtr<NavigationURLLoaderImpl>& loader) 25 const base::WeakPtr<NavigationURLLoaderImpl>& loader)
25 : loader_(loader), 26 : loader_(loader),
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 // TODO(carlosk): extend this trace to support non-PlzNavigate navigations. 88 // TODO(carlosk): extend this trace to support non-PlzNavigate navigations.
88 // For the trace below we're using the NavigationURLLoaderImplCore as the 89 // For the trace below we're using the NavigationURLLoaderImplCore as the
89 // async trace id and reporting the new redirect URL as a parameter. 90 // async trace id and reporting the new redirect URL as a parameter.
90 TRACE_EVENT_ASYNC_BEGIN2("navigation", "Navigation redirectDelay", this, 91 TRACE_EVENT_ASYNC_BEGIN2("navigation", "Navigation redirectDelay", this,
91 "&NavigationURLLoaderImplCore", this, "New URL", 92 "&NavigationURLLoaderImplCore", this, "New URL",
92 redirect_info.new_url.spec()); 93 redirect_info.new_url.spec());
93 } 94 }
94 95
95 void NavigationURLLoaderImplCore::NotifyResponseStarted( 96 void NavigationURLLoaderImplCore::NotifyResponseStarted(
96 ResourceResponse* response, 97 ResourceResponse* response,
97 std::unique_ptr<StreamHandle> body) { 98 std::unique_ptr<StreamHandle> body,
99 std::unique_ptr<NavigationData> navigation_data) {
98 DCHECK_CURRENTLY_ON(BrowserThread::IO); 100 DCHECK_CURRENTLY_ON(BrowserThread::IO);
99 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this); 101 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this);
100 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this, 102 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this,
101 "&NavigationURLLoaderImplCore", this, "success", true); 103 "&NavigationURLLoaderImplCore", this, "success", true);
102 104
103 // If, by the time the task reaches the UI thread, |loader_| has already been 105 // If, by the time the task reaches the UI thread, |loader_| has already been
104 // destroyed, NotifyResponseStarted will not run. |body| will be destructed 106 // destroyed, NotifyResponseStarted will not run. |body| will be destructed
105 // and the request released at that point. 107 // and the request released at that point.
106 108
107 // Make a copy of the ResourceResponse before it is passed to another thread. 109 // Make a copy of the ResourceResponse before it is passed to another thread.
108 // 110 //
109 // TODO(davidben): This copy could be avoided if ResourceResponse weren't 111 // TODO(davidben): This copy could be avoided if ResourceResponse weren't
110 // reference counted and the loader stack passed unique ownership of the 112 // reference counted and the loader stack passed unique ownership of the
111 // response. https://crbug.com/416050 113 // response. https://crbug.com/416050
112 BrowserThread::PostTask( 114 BrowserThread::PostTask(
113 BrowserThread::UI, FROM_HERE, 115 BrowserThread::UI, FROM_HERE,
114 base::Bind(&NavigationURLLoaderImpl::NotifyResponseStarted, loader_, 116 base::Bind(&NavigationURLLoaderImpl::NotifyResponseStarted, loader_,
115 response->DeepCopy(), base::Passed(&body))); 117 response->DeepCopy(), base::Passed(&body),
118 base::Passed(&navigation_data)));
116 } 119 }
117 120
118 void NavigationURLLoaderImplCore::NotifyRequestFailed(bool in_cache, 121 void NavigationURLLoaderImplCore::NotifyRequestFailed(bool in_cache,
119 int net_error) { 122 int net_error) {
120 DCHECK_CURRENTLY_ON(BrowserThread::IO); 123 DCHECK_CURRENTLY_ON(BrowserThread::IO);
121 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this); 124 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this);
122 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this, 125 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this,
123 "&NavigationURLLoaderImplCore", this, "success", 126 "&NavigationURLLoaderImplCore", this, "success",
124 false); 127 false);
125 128
126 BrowserThread::PostTask( 129 BrowserThread::PostTask(
127 BrowserThread::UI, FROM_HERE, 130 BrowserThread::UI, FROM_HERE,
128 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_, 131 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_,
129 in_cache, net_error)); 132 in_cache, net_error));
130 } 133 }
131 134
132 } // namespace content 135 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/navigation_url_loader_impl_core.h ('k') | content/browser/loader/resource_dispatcher_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698