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

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: Rebase. Created 5 years 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 // For the trace below we're using the NavigationURLLoaderImplCore as the
clamy 2015/12/22 10:55:24 nit: skip one line above comment.
carlosk 2015/12/22 13:58:18 Done.
80 // async trace id and reporting the new redirect URL as a parameter.
81 TRACE_EVENT_ASYNC_BEGIN2("navigation", "Navigation redirectDelay", this,
82 "&NavigationURLLoaderImplCore", this, "New URL",
83 redirect_info.new_url.spec());
78 } 84 }
79 85
80 void NavigationURLLoaderImplCore::NotifyResponseStarted( 86 void NavigationURLLoaderImplCore::NotifyResponseStarted(
81 ResourceResponse* response, 87 ResourceResponse* response,
82 scoped_ptr<StreamHandle> body) { 88 scoped_ptr<StreamHandle> body) {
83 DCHECK_CURRENTLY_ON(BrowserThread::IO); 89 DCHECK_CURRENTLY_ON(BrowserThread::IO);
90 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this);
91 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this,
92 "&NavigationURLLoaderImplCore", this, "success", true);
84 93
85 // If, by the time the task reaches the UI thread, |loader_| has already been 94 // If, by the time the task reaches the UI thread, |loader_| has already been
86 // destroyed, NotifyResponseStarted will not run. |body| will be destructed 95 // destroyed, NotifyResponseStarted will not run. |body| will be destructed
87 // and the request released at that point. 96 // and the request released at that point.
88 97
89 // Make a copy of the ResourceResponse before it is passed to another thread. 98 // Make a copy of the ResourceResponse before it is passed to another thread.
90 // 99 //
91 // TODO(davidben): This copy could be avoided if ResourceResponse weren't 100 // TODO(davidben): This copy could be avoided if ResourceResponse weren't
92 // reference counted and the loader stack passed unique ownership of the 101 // reference counted and the loader stack passed unique ownership of the
93 // response. https://crbug.com/416050 102 // response. https://crbug.com/416050
94 BrowserThread::PostTask( 103 BrowserThread::PostTask(
95 BrowserThread::UI, FROM_HERE, 104 BrowserThread::UI, FROM_HERE,
96 base::Bind(&NavigationURLLoaderImpl::NotifyResponseStarted, loader_, 105 base::Bind(&NavigationURLLoaderImpl::NotifyResponseStarted, loader_,
97 response->DeepCopy(), base::Passed(&body))); 106 response->DeepCopy(), base::Passed(&body)));
98 } 107 }
99 108
100 void NavigationURLLoaderImplCore::NotifyRequestFailed(bool in_cache, 109 void NavigationURLLoaderImplCore::NotifyRequestFailed(bool in_cache,
101 int net_error) { 110 int net_error) {
102 DCHECK_CURRENTLY_ON(BrowserThread::IO); 111 DCHECK_CURRENTLY_ON(BrowserThread::IO);
112 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this);
113 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this,
114 "&NavigationURLLoaderImplCore", this, "success",
115 false);
103 116
104 BrowserThread::PostTask( 117 BrowserThread::PostTask(
105 BrowserThread::UI, FROM_HERE, 118 BrowserThread::UI, FROM_HERE,
106 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_, 119 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_,
107 in_cache, net_error)); 120 in_cache, net_error));
108 } 121 }
109 122
110 } // namespace content 123 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698