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

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

Issue 1532873003: PlzNavigate: add initial traces for new TBM benchmarks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed crash issue for synchronous navigations. Created 4 years, 11 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"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 DCHECK_CURRENTLY_ON(BrowserThread::IO); 58 DCHECK_CURRENTLY_ON(BrowserThread::IO);
59 59
60 if (resource_handler_) 60 if (resource_handler_)
61 resource_handler_->FollowRedirect(); 61 resource_handler_->FollowRedirect();
62 } 62 }
63 63
64 void NavigationURLLoaderImplCore::NotifyRequestRedirected( 64 void NavigationURLLoaderImplCore::NotifyRequestRedirected(
65 const net::RedirectInfo& redirect_info, 65 const net::RedirectInfo& redirect_info,
66 ResourceResponse* response) { 66 ResourceResponse* response) {
67 DCHECK_CURRENTLY_ON(BrowserThread::IO); 67 DCHECK_CURRENTLY_ON(BrowserThread::IO);
68 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this);
68 69
69 // Make a copy of the ResourceResponse before it is passed to another thread. 70 // Make a copy of the ResourceResponse before it is passed to another thread.
70 // 71 //
71 // TODO(davidben): This copy could be avoided if ResourceResponse weren't 72 // TODO(davidben): This copy could be avoided if ResourceResponse weren't
72 // reference counted and the loader stack passed unique ownership of the 73 // reference counted and the loader stack passed unique ownership of the
73 // response. https://crbug.com/416050 74 // response. https://crbug.com/416050
74 BrowserThread::PostTask( 75 BrowserThread::PostTask(
75 BrowserThread::UI, FROM_HERE, 76 BrowserThread::UI, FROM_HERE,
76 base::Bind(&NavigationURLLoaderImpl::NotifyRequestRedirected, loader_, 77 base::Bind(&NavigationURLLoaderImpl::NotifyRequestRedirected, loader_,
77 redirect_info, response->DeepCopy())); 78 redirect_info, response->DeepCopy()));
79
80 // TODO(carlosk): extend this trace to support non-PlzNavigate navigations.
81 // For the trace below we're using the NavigationURLLoaderImplCore as the
82 // async trace id and reporting the new redirect URL as a parameter.
83 TRACE_EVENT_ASYNC_BEGIN2("navigation", "Navigation redirectDelay", this,
84 "&NavigationURLLoaderImplCore", this, "New URL",
85 redirect_info.new_url.spec());
78 } 86 }
79 87
80 void NavigationURLLoaderImplCore::NotifyResponseStarted( 88 void NavigationURLLoaderImplCore::NotifyResponseStarted(
81 ResourceResponse* response, 89 ResourceResponse* response,
82 scoped_ptr<StreamHandle> body) { 90 scoped_ptr<StreamHandle> body) {
83 DCHECK_CURRENTLY_ON(BrowserThread::IO); 91 DCHECK_CURRENTLY_ON(BrowserThread::IO);
92 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this);
93 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this,
94 "&NavigationURLLoaderImplCore", this, "success", true);
84 95
85 // If, by the time the task reaches the UI thread, |loader_| has already been 96 // If, by the time the task reaches the UI thread, |loader_| has already been
86 // destroyed, NotifyResponseStarted will not run. |body| will be destructed 97 // destroyed, NotifyResponseStarted will not run. |body| will be destructed
87 // and the request released at that point. 98 // and the request released at that point.
88 99
89 // Make a copy of the ResourceResponse before it is passed to another thread. 100 // Make a copy of the ResourceResponse before it is passed to another thread.
90 // 101 //
91 // TODO(davidben): This copy could be avoided if ResourceResponse weren't 102 // TODO(davidben): This copy could be avoided if ResourceResponse weren't
92 // reference counted and the loader stack passed unique ownership of the 103 // reference counted and the loader stack passed unique ownership of the
93 // response. https://crbug.com/416050 104 // response. https://crbug.com/416050
94 BrowserThread::PostTask( 105 BrowserThread::PostTask(
95 BrowserThread::UI, FROM_HERE, 106 BrowserThread::UI, FROM_HERE,
96 base::Bind(&NavigationURLLoaderImpl::NotifyResponseStarted, loader_, 107 base::Bind(&NavigationURLLoaderImpl::NotifyResponseStarted, loader_,
97 response->DeepCopy(), base::Passed(&body))); 108 response->DeepCopy(), base::Passed(&body)));
98 } 109 }
99 110
100 void NavigationURLLoaderImplCore::NotifyRequestFailed(bool in_cache, 111 void NavigationURLLoaderImplCore::NotifyRequestFailed(bool in_cache,
101 int net_error) { 112 int net_error) {
102 DCHECK_CURRENTLY_ON(BrowserThread::IO); 113 DCHECK_CURRENTLY_ON(BrowserThread::IO);
114 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this);
115 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this,
116 "&NavigationURLLoaderImplCore", this, "success",
117 false);
103 118
104 BrowserThread::PostTask( 119 BrowserThread::PostTask(
105 BrowserThread::UI, FROM_HERE, 120 BrowserThread::UI, FROM_HERE,
106 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_, 121 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_,
107 in_cache, net_error)); 122 in_cache, net_error));
108 } 123 }
109 124
110 } // namespace content 125 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/navigation_url_loader_impl.cc ('k') | content/browser/loader/resource_dispatcher_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698