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

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

Issue 2335133003: PlzNavigate: support the WebRequest API (Closed)
Patch Set: Rebase + addressed nit Created 4 years, 2 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_navigation_handle_core.h " 13 #include "content/browser/service_worker/service_worker_navigation_handle_core.h "
14 #include "content/common/navigation_params.h" 14 #include "content/common/navigation_params.h"
15 #include "content/public/browser/browser_thread.h" 15 #include "content/public/browser/browser_thread.h"
16 #include "content/public/browser/navigation_data.h" 16 #include "content/public/browser/navigation_data.h"
17 #include "content/public/browser/navigation_ui_data.h"
17 #include "content/public/browser/ssl_status.h" 18 #include "content/public/browser/ssl_status.h"
18 #include "content/public/browser/stream_handle.h" 19 #include "content/public/browser/stream_handle.h"
19 #include "content/public/common/resource_response.h" 20 #include "content/public/common/resource_response.h"
20 #include "net/base/net_errors.h" 21 #include "net/base/net_errors.h"
21 #include "net/url_request/redirect_info.h" 22 #include "net/url_request/redirect_info.h"
22 23
23 namespace content { 24 namespace content {
24 25
25 NavigationURLLoaderImplCore::NavigationURLLoaderImplCore( 26 NavigationURLLoaderImplCore::NavigationURLLoaderImplCore(
26 const base::WeakPtr<NavigationURLLoaderImpl>& loader) 27 const base::WeakPtr<NavigationURLLoaderImpl>& loader)
27 : loader_(loader), resource_handler_(nullptr) { 28 : loader_(loader), resource_handler_(nullptr) {
28 // This object is created on the UI thread but otherwise is accessed and 29 // This object is created on the UI thread but otherwise is accessed and
29 // deleted on the IO thread. 30 // deleted on the IO thread.
30 DCHECK_CURRENTLY_ON(BrowserThread::UI); 31 DCHECK_CURRENTLY_ON(BrowserThread::UI);
31 } 32 }
32 33
33 NavigationURLLoaderImplCore::~NavigationURLLoaderImplCore() { 34 NavigationURLLoaderImplCore::~NavigationURLLoaderImplCore() {
34 DCHECK_CURRENTLY_ON(BrowserThread::IO); 35 DCHECK_CURRENTLY_ON(BrowserThread::IO);
35 36
36 if (resource_handler_) 37 if (resource_handler_)
37 resource_handler_->Cancel(); 38 resource_handler_->Cancel();
38 } 39 }
39 40
40 void NavigationURLLoaderImplCore::Start( 41 void NavigationURLLoaderImplCore::Start(
41 ResourceContext* resource_context, 42 ResourceContext* resource_context,
42 ServiceWorkerNavigationHandleCore* service_worker_handle_core, 43 ServiceWorkerNavigationHandleCore* service_worker_handle_core,
43 std::unique_ptr<NavigationRequestInfo> request_info) { 44 std::unique_ptr<NavigationRequestInfo> request_info,
45 std::unique_ptr<NavigationUIData> navigation_ui_data) {
44 DCHECK_CURRENTLY_ON(BrowserThread::IO); 46 DCHECK_CURRENTLY_ON(BrowserThread::IO);
45 47
46 BrowserThread::PostTask( 48 BrowserThread::PostTask(
47 BrowserThread::UI, FROM_HERE, 49 BrowserThread::UI, FROM_HERE,
48 base::Bind(&NavigationURLLoaderImpl::NotifyRequestStarted, loader_, 50 base::Bind(&NavigationURLLoaderImpl::NotifyRequestStarted, loader_,
49 base::TimeTicks::Now())); 51 base::TimeTicks::Now()));
50 52
51 // The ResourceDispatcherHostImpl can be null in unit tests. 53 // The ResourceDispatcherHostImpl can be null in unit tests.
52 if (ResourceDispatcherHostImpl::Get()) { 54 if (ResourceDispatcherHostImpl::Get()) {
53 ResourceDispatcherHostImpl::Get()->BeginNavigationRequest( 55 ResourceDispatcherHostImpl::Get()->BeginNavigationRequest(
54 resource_context, *request_info, this, service_worker_handle_core); 56 resource_context, *request_info, std::move(navigation_ui_data), this,
57 service_worker_handle_core);
55 } 58 }
56 } 59 }
57 60
58 void NavigationURLLoaderImplCore::FollowRedirect() { 61 void NavigationURLLoaderImplCore::FollowRedirect() {
59 DCHECK_CURRENTLY_ON(BrowserThread::IO); 62 DCHECK_CURRENTLY_ON(BrowserThread::IO);
60 63
61 if (resource_handler_) 64 if (resource_handler_)
62 resource_handler_->FollowRedirect(); 65 resource_handler_->FollowRedirect();
63 } 66 }
64 67
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 "&NavigationURLLoaderImplCore", this, "success", 130 "&NavigationURLLoaderImplCore", this, "success",
128 false); 131 false);
129 132
130 BrowserThread::PostTask( 133 BrowserThread::PostTask(
131 BrowserThread::UI, FROM_HERE, 134 BrowserThread::UI, FROM_HERE,
132 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_, 135 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_,
133 in_cache, net_error)); 136 in_cache, net_error));
134 } 137 }
135 138
136 } // namespace content 139 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/navigation_url_loader_impl_core.h ('k') | content/browser/loader/navigation_url_loader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698