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