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

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

Issue 1294243004: PlzNavigate: Make ServiceWorker work with PlzNavigate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missed a spot. Created 5 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_context_wrapper.h"
13 #include "content/common/navigation_params.h" 14 #include "content/common/navigation_params.h"
15 #include "content/common/service_worker/service_worker_types.h"
14 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/stream_handle.h" 17 #include "content/public/browser/stream_handle.h"
16 #include "content/public/common/resource_response.h" 18 #include "content/public/common/resource_response.h"
17 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
18 #include "net/url_request/redirect_info.h" 20 #include "net/url_request/redirect_info.h"
19 21
20 namespace content { 22 namespace content {
21 23
22 NavigationURLLoaderImplCore::NavigationURLLoaderImplCore( 24 NavigationURLLoaderImplCore::NavigationURLLoaderImplCore(
23 const base::WeakPtr<NavigationURLLoaderImpl>& loader) 25 const base::WeakPtr<NavigationURLLoaderImpl>& loader,
26 ServiceWorkerContext* service_worker_context)
24 : loader_(loader), 27 : loader_(loader),
25 resource_handler_(nullptr) { 28 resource_handler_(nullptr),
29 service_worker_context_(
30 static_cast<ServiceWorkerContextWrapper*>(service_worker_context)) {
26 // This object is created on the UI thread but otherwise is accessed and 31 // This object is created on the UI thread but otherwise is accessed and
27 // deleted on the IO thread. 32 // deleted on the IO thread.
28 DCHECK_CURRENTLY_ON(BrowserThread::UI); 33 DCHECK_CURRENTLY_ON(BrowserThread::UI);
29 } 34 }
30 35
31 NavigationURLLoaderImplCore::~NavigationURLLoaderImplCore() { 36 NavigationURLLoaderImplCore::~NavigationURLLoaderImplCore() {
32 DCHECK_CURRENTLY_ON(BrowserThread::IO); 37 DCHECK_CURRENTLY_ON(BrowserThread::IO);
33 38
34 if (resource_handler_) 39 if (resource_handler_)
35 resource_handler_->Cancel(); 40 resource_handler_->Cancel();
36 } 41 }
37 42
38 void NavigationURLLoaderImplCore::Start( 43 void NavigationURLLoaderImplCore::Start(
39 ResourceContext* resource_context, 44 ResourceContext* resource_context,
40 int frame_tree_node_id, 45 int frame_tree_node_id,
41 scoped_ptr<NavigationRequestInfo> request_info) { 46 scoped_ptr<NavigationRequestInfo> request_info) {
42 DCHECK_CURRENTLY_ON(BrowserThread::IO); 47 DCHECK_CURRENTLY_ON(BrowserThread::IO);
43 48
44 BrowserThread::PostTask( 49 BrowserThread::PostTask(
45 BrowserThread::UI, FROM_HERE, 50 BrowserThread::UI, FROM_HERE,
46 base::Bind(&NavigationURLLoaderImpl::NotifyRequestStarted, loader_, 51 base::Bind(&NavigationURLLoaderImpl::NotifyRequestStarted, loader_,
47 base::TimeTicks::Now())); 52 base::TimeTicks::Now()));
48 53
49 ResourceDispatcherHostImpl::Get()->BeginNavigationRequest( 54 ResourceDispatcherHostImpl::Get()->BeginNavigationRequest(
50 resource_context, frame_tree_node_id, 55 resource_context, *request_info, this, service_worker_context_);
51 *request_info, this);
52 } 56 }
53 57
54 void NavigationURLLoaderImplCore::FollowRedirect() { 58 void NavigationURLLoaderImplCore::FollowRedirect() {
55 DCHECK_CURRENTLY_ON(BrowserThread::IO); 59 DCHECK_CURRENTLY_ON(BrowserThread::IO);
56 60
57 if (resource_handler_) 61 if (resource_handler_)
58 resource_handler_->FollowRedirect(); 62 resource_handler_->FollowRedirect();
59 } 63 }
60 64
61
62 void NavigationURLLoaderImplCore::NotifyRequestRedirected( 65 void NavigationURLLoaderImplCore::NotifyRequestRedirected(
63 const net::RedirectInfo& redirect_info, 66 const net::RedirectInfo& redirect_info,
64 ResourceResponse* response) { 67 ResourceResponse* response) {
65 DCHECK_CURRENTLY_ON(BrowserThread::IO); 68 DCHECK_CURRENTLY_ON(BrowserThread::IO);
66 69
67 // Make a copy of the ResourceResponse before it is passed to another thread. 70 // Make a copy of the ResourceResponse before it is passed to another thread.
68 // 71 //
69 // TODO(davidben): This copy could be avoided if ResourceResponse weren't 72 // TODO(davidben): This copy could be avoided if ResourceResponse weren't
70 // reference counted and the loader stack passed unique ownership of the 73 // reference counted and the loader stack passed unique ownership of the
71 // response. https://crbug.com/416050 74 // response. https://crbug.com/416050
(...skipping 27 matching lines...) Expand all
99 int net_error) { 102 int net_error) {
100 DCHECK_CURRENTLY_ON(BrowserThread::IO); 103 DCHECK_CURRENTLY_ON(BrowserThread::IO);
101 104
102 BrowserThread::PostTask( 105 BrowserThread::PostTask(
103 BrowserThread::UI, FROM_HERE, 106 BrowserThread::UI, FROM_HERE,
104 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_, 107 base::Bind(&NavigationURLLoaderImpl::NotifyRequestFailed, loader_,
105 in_cache, net_error)); 108 in_cache, net_error));
106 } 109 }
107 110
108 } // namespace content 111 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698