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