Chromium Code Reviews| 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 TRACE_EVENT_ASYNC_BEGIN2("navigation", "Navigation redirectDelay", this, | |
| 80 "&NavigationURLLoaderImplCore", this, "New URL", | |
| 81 redirect_info.new_url.spec()); | |
| 78 } | 82 } |
| 79 | 83 |
| 80 void NavigationURLLoaderImplCore::NotifyResponseStarted( | 84 void NavigationURLLoaderImplCore::NotifyResponseStarted( |
| 81 ResourceResponse* response, | 85 ResourceResponse* response, |
| 82 scoped_ptr<StreamHandle> body) { | 86 scoped_ptr<StreamHandle> body) { |
| 87 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this); | |
|
clamy
2015/12/18 15:42:11
nit: I would leave the DCHECK_CURRENTLY_ON first.
carlosk
2015/12/18 17:23:21
Done.
| |
| 88 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this, | |
| 89 "&NavigationURLLoaderImplCore", this, "success", true); | |
| 83 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 90 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 84 | 91 |
| 85 // If, by the time the task reaches the UI thread, |loader_| has already been | 92 // If, by the time the task reaches the UI thread, |loader_| has already been |
| 86 // destroyed, NotifyResponseStarted will not run. |body| will be destructed | 93 // destroyed, NotifyResponseStarted will not run. |body| will be destructed |
| 87 // and the request released at that point. | 94 // and the request released at that point. |
| 88 | 95 |
| 89 // Make a copy of the ResourceResponse before it is passed to another thread. | 96 // Make a copy of the ResourceResponse before it is passed to another thread. |
| 90 // | 97 // |
| 91 // TODO(davidben): This copy could be avoided if ResourceResponse weren't | 98 // TODO(davidben): This copy could be avoided if ResourceResponse weren't |
| 92 // reference counted and the loader stack passed unique ownership of the | 99 // reference counted and the loader stack passed unique ownership of the |
| 93 // response. https://crbug.com/416050 | 100 // response. https://crbug.com/416050 |
| 94 BrowserThread::PostTask( | 101 BrowserThread::PostTask( |
| 95 BrowserThread::UI, FROM_HERE, | 102 BrowserThread::UI, FROM_HERE, |
| 96 base::Bind(&NavigationURLLoaderImpl::NotifyResponseStarted, loader_, | 103 base::Bind(&NavigationURLLoaderImpl::NotifyResponseStarted, loader_, |
| 97 response->DeepCopy(), base::Passed(&body))); | 104 response->DeepCopy(), base::Passed(&body))); |
| 98 } | 105 } |
| 99 | 106 |
| 100 void NavigationURLLoaderImplCore::NotifyRequestFailed(bool in_cache, | 107 void NavigationURLLoaderImplCore::NotifyRequestFailed(bool in_cache, |
| 101 int net_error) { | 108 int net_error) { |
| 109 TRACE_EVENT_ASYNC_END0("navigation", "Navigation redirectDelay", this); | |
| 110 TRACE_EVENT_ASYNC_END2("navigation", "Navigation timeToResponseStarted", this, | |
| 111 "&NavigationURLLoaderImplCore", this, "success", | |
| 112 false); | |
| 102 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 113 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 103 | 114 |
| 104 BrowserThread::PostTask( | 115 BrowserThread::PostTask( |
| 105 BrowserThread::UI, FROM_HERE, | 116 BrowserThread::UI, FROM_HERE, |
| 106 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_, | 117 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_, |
| 107 in_cache, net_error)); | 118 in_cache, net_error)); |
| 108 } | 119 } |
| 109 | 120 |
| 110 } // namespace content | 121 } // namespace content |
| OLD | NEW |