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

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

Issue 2936623002: Implement dumb URLLoader{Factory} for ServiceWorker script loading (for try)
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
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_dispatcher.h"
10 #include "content/child/service_worker/service_worker_handle_reference.h" 11 #include "content/child/service_worker/service_worker_handle_reference.h"
11 #include "content/child/service_worker/service_worker_provider_context.h" 12 #include "content/child/service_worker/service_worker_provider_context.h"
12 #include "content/common/navigation_params.h" 13 #include "content/common/navigation_params.h"
13 #include "content/common/service_worker/service_worker_messages.h" 14 #include "content/common/service_worker/service_worker_messages.h"
14 #include "content/common/service_worker/service_worker_provider_host_info.h" 15 #include "content/common/service_worker/service_worker_provider_host_info.h"
15 #include "content/common/service_worker/service_worker_utils.h" 16 #include "content/common/service_worker/service_worker_utils.h"
16 #include "content/public/common/browser_side_navigation_policy.h" 17 #include "content/public/common/browser_side_navigation_policy.h"
17 #include "ipc/ipc_sync_channel.h" 18 #include "ipc/ipc_sync_channel.h"
18 #include "mojo/public/cpp/bindings/associated_group.h" 19 #include "mojo/public/cpp/bindings/associated_group.h"
19 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" 20 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 201
201 ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider( 202 ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider(
202 int route_id, 203 int route_id,
203 ServiceWorkerProviderType provider_type, 204 ServiceWorkerProviderType provider_type,
204 bool is_parent_frame_secure) 205 bool is_parent_frame_secure)
205 : ServiceWorkerNetworkProvider(route_id, 206 : ServiceWorkerNetworkProvider(route_id,
206 provider_type, 207 provider_type,
207 GetNextProviderId(), 208 GetNextProviderId(),
208 is_parent_frame_secure) {} 209 is_parent_frame_secure) {}
209 210
211 ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider(
212 mojom::ServiceWorkerProviderClientInfoPtr info)
213 : provider_id_(info->provider_id) {
214 context_ = new ServiceWorkerProviderContext(
215 provider_id_, info->type, std::move(info->client_request),
216 ChildThreadImpl::current()->thread_safe_sender());
217
218 if (info->script_loader_factory_ptr_info.is_valid())
219 script_loader_factory_.Bind(
220 std::move(info->script_loader_factory_ptr_info));
221
222 ServiceWorkerDispatcher* dispatcher =
223 ServiceWorkerDispatcher::GetOrCreateThreadSpecificInstance(
224 ChildThreadImpl::current()->thread_safe_sender(),
225 base::ThreadTaskRunnerHandle::Get().get());
226 // TODO(shimazu): Set registration/attributes directly to |context_|.
227 dispatcher->OnAssociateRegistration(-1, info->provider_id, info->registration,
228 info->attributes);
229
230 provider_host_.Bind(std::move(info->host_ptr_info));
231 }
232
210 ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider() 233 ServiceWorkerNetworkProvider::ServiceWorkerNetworkProvider()
211 : provider_id_(kInvalidServiceWorkerProviderId) {} 234 : provider_id_(kInvalidServiceWorkerProviderId) {}
212 235
213 ServiceWorkerNetworkProvider::~ServiceWorkerNetworkProvider() { 236 ServiceWorkerNetworkProvider::~ServiceWorkerNetworkProvider() {
214 if (provider_id_ == kInvalidServiceWorkerProviderId) 237 if (provider_id_ == kInvalidServiceWorkerProviderId)
215 return; 238 return;
216 if (!ChildThreadImpl::current()) 239 if (!ChildThreadImpl::current())
217 return; // May be null in some tests. 240 return; // May be null in some tests.
218 provider_host_.reset(); 241 provider_host_.reset();
219 } 242 }
220 243
221 void ServiceWorkerNetworkProvider::SetServiceWorkerVersionId(
222 int64_t version_id,
223 int embedded_worker_id) {
224 DCHECK_NE(kInvalidServiceWorkerProviderId, provider_id_);
225 if (!ChildThreadImpl::current())
226 return; // May be null in some tests.
227 dispatcher_host_->OnSetHostedVersionId(provider_id(), version_id,
228 embedded_worker_id);
229 }
230
231 bool ServiceWorkerNetworkProvider::IsControlledByServiceWorker() const { 244 bool ServiceWorkerNetworkProvider::IsControlledByServiceWorker() const {
232 if (ServiceWorkerUtils::IsServicificationEnabled()) { 245 if (ServiceWorkerUtils::IsServicificationEnabled()) {
233 // Interception for subresource loading is not working (yet) 246 // Interception for subresource loading is not working (yet)
234 // when servicification is enabled. 247 // when servicification is enabled.
235 return false; 248 return false;
236 } 249 }
237 return context() && context()->controller(); 250 return context() && context()->controller();
238 } 251 }
239 252
240 } // namespace content 253 } // namespace content
OLDNEW
« no previous file with comments | « content/child/service_worker/service_worker_network_provider.h ('k') | content/common/service_worker/embedded_worker.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698