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