Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: content/browser/loader/navigation_url_loader_impl_core.cc

Issue 2335133003: PlzNavigate: support the WebRequest API (Closed)
Patch Set: PlzNavigate: support the WebRequest API Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "content/browser/loader/navigation_resource_handler.h" 11 #include "content/browser/loader/navigation_resource_handler.h"
12 #include "content/browser/loader/resource_dispatcher_host_impl.h" 12 #include "content/browser/loader/resource_dispatcher_host_impl.h"
13 #include "content/browser/service_worker/service_worker_context_wrapper.h" 13 #include "content/browser/service_worker/service_worker_context_wrapper.h"
14 #include "content/browser/service_worker/service_worker_registration.h" 14 #include "content/browser/service_worker/service_worker_registration.h"
15 #include "content/common/navigation_params.h" 15 #include "content/common/navigation_params.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/ssl_status.h" 19 #include "content/public/browser/ssl_status.h"
19 #include "content/public/browser/stream_handle.h" 20 #include "content/public/browser/stream_handle.h"
20 #include "content/public/common/resource_response.h" 21 #include "content/public/common/resource_response.h"
21 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
22 #include "net/url_request/redirect_info.h" 23 #include "net/url_request/redirect_info.h"
23 24
24 namespace content { 25 namespace content {
25 26
26 NavigationURLLoaderImplCore::NavigationURLLoaderImplCore( 27 NavigationURLLoaderImplCore::NavigationURLLoaderImplCore(
27 const base::WeakPtr<NavigationURLLoaderImpl>& loader) 28 const base::WeakPtr<NavigationURLLoaderImpl>& loader)
28 : loader_(loader), 29 : loader_(loader),
29 resource_handler_(nullptr), 30 resource_handler_(nullptr),
30 resource_context_(nullptr), 31 resource_context_(nullptr),
31 factory_(this) { 32 factory_(this) {
32 // This object is created on the UI thread but otherwise is accessed and 33 // This object is created on the UI thread but otherwise is accessed and
33 // deleted on the IO thread. 34 // deleted on the IO thread.
34 DCHECK_CURRENTLY_ON(BrowserThread::UI); 35 DCHECK_CURRENTLY_ON(BrowserThread::UI);
35 } 36 }
36 37
37 NavigationURLLoaderImplCore::~NavigationURLLoaderImplCore() { 38 NavigationURLLoaderImplCore::~NavigationURLLoaderImplCore() {
38 DCHECK_CURRENTLY_ON(BrowserThread::IO); 39 DCHECK_CURRENTLY_ON(BrowserThread::IO);
39 40
40 if (resource_handler_) 41 if (resource_handler_)
41 resource_handler_->Cancel(); 42 resource_handler_->Cancel();
42 } 43 }
43 44
44 void NavigationURLLoaderImplCore::Start( 45 void NavigationURLLoaderImplCore::Start(
45 ResourceContext* resource_context, 46 ResourceContext* resource_context,
46 ServiceWorkerContextWrapper* service_worker_context_wrapper, 47 ServiceWorkerContextWrapper* service_worker_context_wrapper,
47 std::unique_ptr<NavigationRequestInfo> request_info) { 48 std::unique_ptr<NavigationRequestInfo> request_info,
49 std::unique_ptr<NavigationUIData> navigation_ui_data) {
48 DCHECK_CURRENTLY_ON(BrowserThread::IO); 50 DCHECK_CURRENTLY_ON(BrowserThread::IO);
49 51
50 BrowserThread::PostTask( 52 BrowserThread::PostTask(
51 BrowserThread::UI, FROM_HERE, 53 BrowserThread::UI, FROM_HERE,
52 base::Bind(&NavigationURLLoaderImpl::NotifyRequestStarted, loader_, 54 base::Bind(&NavigationURLLoaderImpl::NotifyRequestStarted, loader_,
53 base::TimeTicks::Now())); 55 base::TimeTicks::Now()));
54 request_info_ = std::move(request_info); 56 request_info_ = std::move(request_info);
57 navigation_ui_data_ = std::move(navigation_ui_data);
55 resource_context_ = resource_context; 58 resource_context_ = resource_context;
56 59
57 // Check if there is a ServiceWorker registered for this navigation if 60 // Check if there is a ServiceWorker registered for this navigation if
58 // ServiceWorkers are allowed for this navigation. Otherwise start the 61 // ServiceWorkers are allowed for this navigation. Otherwise start the
59 // request right away. 62 // request right away.
60 // ServiceWorkerContextWrapper can be null in tests. 63 // ServiceWorkerContextWrapper can be null in tests.
61 if (!request_info_->begin_params.skip_service_worker && 64 if (!request_info_->begin_params.skip_service_worker &&
62 service_worker_context_wrapper) { 65 service_worker_context_wrapper) {
63 service_worker_context_wrapper->FindReadyRegistrationForDocument( 66 service_worker_context_wrapper->FindReadyRegistrationForDocument(
64 request_info_->common_params.url, 67 request_info_->common_params.url,
65 base::Bind(&NavigationURLLoaderImplCore::OnServiceWorkerChecksPerformed, 68 base::Bind(&NavigationURLLoaderImplCore::OnServiceWorkerChecksPerformed,
66 factory_.GetWeakPtr())); 69 factory_.GetWeakPtr()));
67 } else { 70 } else {
68 ResourceDispatcherHostImpl::Get()->BeginNavigationRequest( 71 ResourceDispatcherHostImpl::Get()->BeginNavigationRequest(
69 resource_context_, *request_info_, this); 72 resource_context_, *request_info_, std::move(navigation_ui_data_),
73 this);
70 } 74 }
71 } 75 }
72 76
73 void NavigationURLLoaderImplCore::FollowRedirect() { 77 void NavigationURLLoaderImplCore::FollowRedirect() {
74 DCHECK_CURRENTLY_ON(BrowserThread::IO); 78 DCHECK_CURRENTLY_ON(BrowserThread::IO);
75 79
76 if (resource_handler_) 80 if (resource_handler_)
77 resource_handler_->FollowRedirect(); 81 resource_handler_->FollowRedirect();
78 } 82 }
79 83
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 return; 167 return;
164 } 168 }
165 169
166 // Otherwise, start the navigation in the network stack. 170 // Otherwise, start the navigation in the network stack.
167 171
168 // The ResourceDispatcherHostImpl can be null in unit tests. 172 // The ResourceDispatcherHostImpl can be null in unit tests.
169 if (!ResourceDispatcherHostImpl::Get()) 173 if (!ResourceDispatcherHostImpl::Get())
170 return; 174 return;
171 175
172 ResourceDispatcherHostImpl::Get()->BeginNavigationRequest( 176 ResourceDispatcherHostImpl::Get()->BeginNavigationRequest(
173 resource_context_, *request_info_, this); 177 resource_context_, *request_info_, std::move(navigation_ui_data_), this);
174 } 178 }
175 179
176 } // namespace content 180 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698