OLD | NEW |
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 // TODO(carlosk): extend this trace to support non-PlzNavigate navigations. | 96 // TODO(carlosk): extend this trace to support non-PlzNavigate navigations. |
97 // For the trace below we're using the NavigationURLLoaderImplCore as the | 97 // For the trace below we're using the NavigationURLLoaderImplCore as the |
98 // async trace id and reporting the new redirect URL as a parameter. | 98 // async trace id and reporting the new redirect URL as a parameter. |
99 TRACE_EVENT_ASYNC_BEGIN2("navigation", "Navigation redirectDelay", this, | 99 TRACE_EVENT_ASYNC_BEGIN2("navigation", "Navigation redirectDelay", this, |
100 "&NavigationURLLoaderImplCore", this, "New URL", | 100 "&NavigationURLLoaderImplCore", this, "New URL", |
101 redirect_info.new_url.spec()); | 101 redirect_info.new_url.spec()); |
102 } | 102 } |
103 | 103 |
104 void NavigationURLLoaderImplCore::NotifyResponseStarted( | 104 void NavigationURLLoaderImplCore::NotifyResponseStarted( |
105 ResourceResponse* response, | 105 ResourceResponse* response, |
106 std::unique_ptr<StreamHandle> body, | 106 mojo::ScopedDataPipeConsumerHandle consumer_handle, |
107 const SSLStatus& ssl_status, | 107 const SSLStatus& ssl_status, |
108 std::unique_ptr<NavigationData> navigation_data, | 108 std::unique_ptr<NavigationData> navigation_data, |
109 const GlobalRequestID& request_id, | 109 const GlobalRequestID& request_id, |
110 bool is_download, | 110 bool is_download, |
111 bool is_stream) { | 111 bool is_stream) { |
112 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 112 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
113 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this); | 113 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this); |
114 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this, | 114 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this, |
115 "&NavigationURLLoaderImplCore", this, "success", true); | 115 "&NavigationURLLoaderImplCore", this, "success", true); |
116 | 116 |
117 // If, by the time the task reaches the UI thread, |loader_| has already been | 117 // If, by the time the task reaches the UI thread, |loader_| has already been |
118 // destroyed, NotifyResponseStarted will not run. |body| will be destructed | 118 // destroyed, NotifyResponseStarted will not run. |body| will be destructed |
119 // and the request released at that point. | 119 // and the request released at that point. |
120 | 120 |
121 // Make a copy of the ResourceResponse before it is passed to another thread. | 121 // Make a copy of the ResourceResponse before it is passed to another thread. |
122 // | 122 // |
123 // TODO(davidben): This copy could be avoided if ResourceResponse weren't | 123 // TODO(davidben): This copy could be avoided if ResourceResponse weren't |
124 // reference counted and the loader stack passed unique ownership of the | 124 // reference counted and the loader stack passed unique ownership of the |
125 // response. https://crbug.com/416050 | 125 // response. https://crbug.com/416050 |
126 BrowserThread::PostTask( | 126 BrowserThread::PostTask( |
127 BrowserThread::UI, FROM_HERE, | 127 BrowserThread::UI, FROM_HERE, |
128 base::Bind(&NavigationURLLoaderImpl::NotifyResponseStarted, loader_, | 128 base::Bind(&NavigationURLLoaderImpl::NotifyResponseStarted, loader_, |
129 response->DeepCopy(), base::Passed(&body), ssl_status, | 129 response->DeepCopy(), base::Passed(std::move(consumer_handle)), |
130 base::Passed(&navigation_data), request_id, is_download, | 130 ssl_status, base::Passed(&navigation_data), request_id, |
131 is_stream)); | 131 is_download, is_stream)); |
132 } | 132 } |
133 | 133 |
134 void NavigationURLLoaderImplCore::NotifyRequestFailed(bool in_cache, | 134 void NavigationURLLoaderImplCore::NotifyRequestFailed(bool in_cache, |
135 int net_error) { | 135 int net_error) { |
136 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 136 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
137 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this); | 137 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this); |
138 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this, | 138 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this, |
139 "&NavigationURLLoaderImplCore", this, "success", | 139 "&NavigationURLLoaderImplCore", this, "success", |
140 false); | 140 false); |
141 | 141 |
142 BrowserThread::PostTask( | 142 BrowserThread::PostTask( |
143 BrowserThread::UI, FROM_HERE, | 143 BrowserThread::UI, FROM_HERE, |
144 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_, | 144 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_, |
145 in_cache, net_error)); | 145 in_cache, net_error)); |
146 } | 146 } |
147 | 147 |
148 } // namespace content | 148 } // namespace content |
OLD | NEW |