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