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

Side by Side Diff: content/child/service_worker/service_worker_network_provider.cc

Issue 2940563002: Fix SW tests with servicification (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/renderer/render_frame_impl.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 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/child/service_worker/service_worker_network_provider.h" 5 #include "content/child/service_worker/service_worker_network_provider.h"
6 6
7 #include "base/atomic_sequence_num.h" 7 #include "base/atomic_sequence_num.h"
8 #include "content/child/child_thread_impl.h" 8 #include "content/child/child_thread_impl.h"
9 #include "content/child/request_extra_data.h" 9 #include "content/child/request_extra_data.h"
10 #include "content/child/service_worker/service_worker_handle_reference.h" 10 #include "content/child/service_worker/service_worker_handle_reference.h"
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 request.SetExtraData(extra_data); 62 request.SetExtraData(extra_data);
63 63
64 // If the provider does not have a controller at this point, the renderer 64 // If the provider does not have a controller at this point, the renderer
65 // expects the request to never be handled by a controlling service worker, 65 // expects the request to never be handled by a controlling service worker,
66 // so set the ServiceWorkerMode to skip local workers here. Otherwise, a 66 // so set the ServiceWorkerMode to skip local workers here. Otherwise, a
67 // service worker that is in the process of becoming the controller (i.e., 67 // service worker that is in the process of becoming the controller (i.e.,
68 // via claim()) on the browser-side could handle the request and break 68 // via claim()) on the browser-side could handle the request and break
69 // the assumptions of the renderer. 69 // the assumptions of the renderer.
70 if (request.GetFrameType() != blink::WebURLRequest::kFrameTypeTopLevel && 70 if (request.GetFrameType() != blink::WebURLRequest::kFrameTypeTopLevel &&
71 request.GetFrameType() != blink::WebURLRequest::kFrameTypeNested && 71 request.GetFrameType() != blink::WebURLRequest::kFrameTypeNested &&
72 !provider_->IsControlledByServiceWorker() && 72 !provider_->IsControlledByServiceWorker() &&
falken 2017/06/13 05:48:47 Seems likely this should use IsControlledByService
kinuko 2017/06/13 06:45:55 Changed the 'IsServicificationEnabled()' code in t
73 request.GetServiceWorkerMode() != 73 request.GetServiceWorkerMode() !=
74 blink::WebURLRequest::ServiceWorkerMode::kNone) { 74 blink::WebURLRequest::ServiceWorkerMode::kNone) {
75 request.SetServiceWorkerMode( 75 request.SetServiceWorkerMode(
76 blink::WebURLRequest::ServiceWorkerMode::kForeign); 76 blink::WebURLRequest::ServiceWorkerMode::kForeign);
77 } 77 }
78 } 78 }
79 79
80 bool IsControlledByServiceWorker() override { 80 bool IsControlledByServiceWorker() override {
81 if (ServiceWorkerUtils::IsServicificationEnabled()) {
82 // Interception for subresource loading is not working (yet)
83 // when servicification is enabled.
84 return false;
85 }
81 return provider_->IsControlledByServiceWorker(); 86 return provider_->IsControlledByServiceWorker();
82 } 87 }
83 88
84 int GetProviderID() const override { return provider_->provider_id(); } 89 int GetProviderID() const override { return provider_->provider_id(); }
85 90
86 int64_t ServiceWorkerID() override { 91 int64_t ServiceWorkerID() override {
87 if (provider_->context() && provider_->context()->controller()) 92 if (provider_->context() && provider_->context()->controller())
88 return provider_->context()->controller()->version_id(); 93 return provider_->context()->controller()->version_id();
89 return kInvalidServiceWorkerVersionId; 94 return kInvalidServiceWorkerVersionId;
90 } 95 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 void ServiceWorkerNetworkProvider::SetServiceWorkerVersionId( 226 void ServiceWorkerNetworkProvider::SetServiceWorkerVersionId(
222 int64_t version_id, 227 int64_t version_id,
223 int embedded_worker_id) { 228 int embedded_worker_id) {
224 DCHECK_NE(kInvalidServiceWorkerProviderId, provider_id_); 229 DCHECK_NE(kInvalidServiceWorkerProviderId, provider_id_);
225 if (!ChildThreadImpl::current()) 230 if (!ChildThreadImpl::current())
226 return; // May be null in some tests. 231 return; // May be null in some tests.
227 dispatcher_host_->OnSetHostedVersionId(provider_id(), version_id, 232 dispatcher_host_->OnSetHostedVersionId(provider_id(), version_id,
228 embedded_worker_id); 233 embedded_worker_id);
229 } 234 }
230 235
231 bool ServiceWorkerNetworkProvider::IsControlledByServiceWorker() const { 236 bool ServiceWorkerNetworkProvider::IsControlledByServiceWorker() const {
falken 2017/06/13 05:48:47 Would it be safer to put the return false here ins
kinuko 2017/06/13 06:45:55 Done.
232 return context() && context()->controller(); 237 return context() && context()->controller();
233 } 238 }
234 239
235 } // namespace content 240 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/renderer/render_frame_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698