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

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

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

Powered by Google App Engine
This is Rietveld 408576698