| 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.h" | 5 #include "content/browser/loader/navigation_url_loader_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
| 12 #include "content/browser/frame_host/navigation_request_info.h" | 12 #include "content/browser/frame_host/navigation_request_info.h" |
| 13 #include "content/browser/loader/navigation_url_loader_delegate.h" | 13 #include "content/browser/loader/navigation_url_loader_delegate.h" |
| 14 #include "content/browser/loader/navigation_url_loader_impl_core.h" | 14 #include "content/browser/loader/navigation_url_loader_impl_core.h" |
| 15 #include "content/browser/service_worker/service_worker_navigation_handle.h" | 15 #include "content/browser/service_worker/service_worker_navigation_handle.h" |
| 16 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
| 17 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
| 18 #include "content/public/browser/navigation_data.h" | 18 #include "content/public/browser/navigation_data.h" |
| 19 #include "content/public/browser/navigation_ui_data.h" |
| 19 #include "content/public/browser/stream_handle.h" | 20 #include "content/public/browser/stream_handle.h" |
| 20 | 21 |
| 21 namespace content { | 22 namespace content { |
| 22 | 23 |
| 23 NavigationURLLoaderImpl::NavigationURLLoaderImpl( | 24 NavigationURLLoaderImpl::NavigationURLLoaderImpl( |
| 24 BrowserContext* browser_context, | 25 BrowserContext* browser_context, |
| 25 std::unique_ptr<NavigationRequestInfo> request_info, | 26 std::unique_ptr<NavigationRequestInfo> request_info, |
| 27 std::unique_ptr<NavigationUIData> navigation_ui_data, |
| 26 ServiceWorkerNavigationHandle* service_worker_handle, | 28 ServiceWorkerNavigationHandle* service_worker_handle, |
| 27 NavigationURLLoaderDelegate* delegate) | 29 NavigationURLLoaderDelegate* delegate) |
| 28 : delegate_(delegate), weak_factory_(this) { | 30 : delegate_(delegate), weak_factory_(this) { |
| 29 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 31 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 30 | 32 |
| 31 core_ = new NavigationURLLoaderImplCore(weak_factory_.GetWeakPtr()); | 33 core_ = new NavigationURLLoaderImplCore(weak_factory_.GetWeakPtr()); |
| 32 | 34 |
| 33 // TODO(carlosk): extend this trace to support non-PlzNavigate navigations. | 35 // TODO(carlosk): extend this trace to support non-PlzNavigate navigations. |
| 34 // For the trace below we're using the NavigationURLLoaderImplCore as the | 36 // For the trace below we're using the NavigationURLLoaderImplCore as the |
| 35 // async trace id, |navigation_start| as the timestamp and reporting the | 37 // async trace id, |navigation_start| as the timestamp and reporting the |
| 36 // FrameTreeNode id as a parameter. | 38 // FrameTreeNode id as a parameter. |
| 37 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( | 39 TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( |
| 38 "navigation", "Navigation timeToResponseStarted", core_, | 40 "navigation", "Navigation timeToResponseStarted", core_, |
| 39 request_info->common_params.navigation_start, | 41 request_info->common_params.navigation_start, |
| 40 "FrameTreeNode id", request_info->frame_tree_node_id); | 42 "FrameTreeNode id", request_info->frame_tree_node_id); |
| 41 ServiceWorkerNavigationHandleCore* service_worker_handle_core = | 43 ServiceWorkerNavigationHandleCore* service_worker_handle_core = |
| 42 service_worker_handle ? service_worker_handle->core() : nullptr; | 44 service_worker_handle ? service_worker_handle->core() : nullptr; |
| 43 BrowserThread::PostTask( | 45 BrowserThread::PostTask( |
| 44 BrowserThread::IO, FROM_HERE, | 46 BrowserThread::IO, FROM_HERE, |
| 45 base::Bind(&NavigationURLLoaderImplCore::Start, base::Unretained(core_), | 47 base::Bind(&NavigationURLLoaderImplCore::Start, base::Unretained(core_), |
| 46 browser_context->GetResourceContext(), | 48 browser_context->GetResourceContext(), |
| 47 service_worker_handle_core, base::Passed(&request_info))); | 49 service_worker_handle_core, base::Passed(&request_info), |
| 50 base::Passed(&navigation_ui_data))); |
| 48 } | 51 } |
| 49 | 52 |
| 50 NavigationURLLoaderImpl::~NavigationURLLoaderImpl() { | 53 NavigationURLLoaderImpl::~NavigationURLLoaderImpl() { |
| 51 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 54 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 52 | 55 |
| 53 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, core_); | 56 BrowserThread::DeleteSoon(BrowserThread::IO, FROM_HERE, core_); |
| 54 core_ = nullptr; | 57 core_ = nullptr; |
| 55 } | 58 } |
| 56 | 59 |
| 57 void NavigationURLLoaderImpl::FollowRedirect() { | 60 void NavigationURLLoaderImpl::FollowRedirect() { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 delegate_->OnRequestFailed(in_cache, net_error); | 101 delegate_->OnRequestFailed(in_cache, net_error); |
| 99 } | 102 } |
| 100 | 103 |
| 101 void NavigationURLLoaderImpl::NotifyRequestStarted(base::TimeTicks timestamp) { | 104 void NavigationURLLoaderImpl::NotifyRequestStarted(base::TimeTicks timestamp) { |
| 102 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 105 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 103 | 106 |
| 104 delegate_->OnRequestStarted(timestamp); | 107 delegate_->OnRequestStarted(timestamp); |
| 105 } | 108 } |
| 106 | 109 |
| 107 } // namespace content | 110 } // namespace content |
| OLD | NEW |