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

Side by Side Diff: content/browser/service_worker/service_worker_url_loader_job.cc

Issue 2931033005: Small fixes for Servicified SW code path (Closed)
Patch Set: . Created 3 years, 6 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
« no previous file with comments | « no previous file | content/child/service_worker/service_worker_network_provider.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/service_worker/service_worker_url_loader_job.h" 5 #include "content/browser/service_worker/service_worker_url_loader_job.h"
6 6
7 #include "base/command_line.h"
8 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h" 7 #include "content/browser/service_worker/service_worker_fetch_dispatcher.h"
9 #include "content/browser/service_worker/service_worker_version.h" 8 #include "content/browser/service_worker/service_worker_version.h"
10 #include "content/common/service_worker/service_worker_utils.h" 9 #include "content/common/service_worker/service_worker_utils.h"
11 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/resource_request_info.h" 11 #include "content/public/browser/resource_request_info.h"
13 #include "content/public/common/browser_side_navigation_policy.h"
14 #include "content/public/common/content_switches.h" 12 #include "content/public/common/content_switches.h"
15 #include "net/base/io_buffer.h" 13 #include "net/base/io_buffer.h"
16 #include "storage/browser/blob/blob_reader.h" 14 #include "storage/browser/blob/blob_reader.h"
17 #include "storage/browser/blob/blob_storage_context.h" 15 #include "storage/browser/blob/blob_storage_context.h"
18 16
19 namespace content { 17 namespace content {
20 18
21 ServiceWorkerURLLoaderJob::ServiceWorkerURLLoaderJob( 19 ServiceWorkerURLLoaderJob::ServiceWorkerURLLoaderJob(
22 LoaderCallback callback, 20 LoaderCallback callback,
23 Delegate* delegate, 21 Delegate* delegate,
24 const ResourceRequest& resource_request, 22 const ResourceRequest& resource_request,
25 base::WeakPtr<storage::BlobStorageContext> blob_storage_context) 23 base::WeakPtr<storage::BlobStorageContext> blob_storage_context)
26 : loader_callback_(std::move(callback)), 24 : loader_callback_(std::move(callback)),
27 delegate_(delegate), 25 delegate_(delegate),
28 resource_request_(resource_request), 26 resource_request_(resource_request),
29 blob_storage_context_(blob_storage_context), 27 blob_storage_context_(blob_storage_context),
30 binding_(this), 28 binding_(this),
31 weak_factory_(this) { 29 weak_factory_(this) {
32 DCHECK(IsBrowserSideNavigationEnabled() && 30 DCHECK(ServiceWorkerUtils::IsServicificationEnabled());
33 base::CommandLine::ForCurrentProcess()->HasSwitch(
34 switches::kEnableNetworkService));
35 } 31 }
36 32
37 ServiceWorkerURLLoaderJob::~ServiceWorkerURLLoaderJob() {} 33 ServiceWorkerURLLoaderJob::~ServiceWorkerURLLoaderJob() {}
38 34
39 void ServiceWorkerURLLoaderJob::FallbackToNetwork() { 35 void ServiceWorkerURLLoaderJob::FallbackToNetwork() {
40 response_type_ = FALLBACK_TO_NETWORK; 36 response_type_ = FALLBACK_TO_NETWORK;
41 // This could be called multiple times in some cases because we simply 37 // This could be called multiple times in some cases because we simply
42 // call this synchronously here and don't wait for a separate async 38 // call this synchronously here and don't wait for a separate async
43 // StartRequest cue like what URLRequestJob case does. 39 // StartRequest cue like what URLRequestJob case does.
44 // TODO(kinuko): Make sure this is ok or we need to make this async. 40 // TODO(kinuko): Make sure this is ok or we need to make this async.
(...skipping 24 matching lines...) Expand all
69 NOTIMPLEMENTED(); 65 NOTIMPLEMENTED();
70 return 0; 66 return 0;
71 } 67 }
72 68
73 void ServiceWorkerURLLoaderJob::FailDueToLostController() { 69 void ServiceWorkerURLLoaderJob::FailDueToLostController() {
74 NOTIMPLEMENTED(); 70 NOTIMPLEMENTED();
75 } 71 }
76 72
77 void ServiceWorkerURLLoaderJob::Cancel() { 73 void ServiceWorkerURLLoaderJob::Cancel() {
78 canceled_ = true; 74 canceled_ = true;
75 weak_factory_.InvalidateWeakPtrs();
76 blob_reader_.reset();
77 blob_storage_context_.reset();
78 fetch_dispatcher_.reset();
79 } 79 }
80 80
81 bool ServiceWorkerURLLoaderJob::WasCanceled() const { 81 bool ServiceWorkerURLLoaderJob::WasCanceled() const {
82 return canceled_; 82 return canceled_;
83 } 83 }
84 84
85 void ServiceWorkerURLLoaderJob::StartRequest() { 85 void ServiceWorkerURLLoaderJob::StartRequest() {
86 DCHECK_EQ(FORWARD_TO_SERVICE_WORKER, response_type_); 86 DCHECK_EQ(FORWARD_TO_SERVICE_WORKER, response_type_);
87 87
88 ServiceWorkerMetrics::URLRequestJobResult result = 88 ServiceWorkerMetrics::URLRequestJobResult result =
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 void ServiceWorkerURLLoaderJob::FollowRedirect() { 213 void ServiceWorkerURLLoaderJob::FollowRedirect() {
214 NOTIMPLEMENTED(); 214 NOTIMPLEMENTED();
215 } 215 }
216 216
217 void ServiceWorkerURLLoaderJob::SetPriority(net::RequestPriority priority, 217 void ServiceWorkerURLLoaderJob::SetPriority(net::RequestPriority priority,
218 int32_t intra_priority_value) { 218 int32_t intra_priority_value) {
219 NOTIMPLEMENTED(); 219 NOTIMPLEMENTED();
220 } 220 }
221 221
222 } // namespace content 222 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/child/service_worker/service_worker_network_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698