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

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

Issue 558873003: Better coordinate what's responsible for associating a registration to a document. During navigatio… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_provider_host.h" 5 #include "content/browser/service_worker/service_worker_provider_host.h"
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "content/browser/message_port_message_filter.h" 8 #include "content/browser/message_port_message_filter.h"
9 #include "content/browser/service_worker/service_worker_context_core.h" 9 #include "content/browser/service_worker/service_worker_context_core.h"
10 #include "content/browser/service_worker/service_worker_context_request_handler. h" 10 #include "content/browser/service_worker/service_worker_context_request_handler. h"
(...skipping 10 matching lines...) Expand all
21 21
22 static const int kDocumentMainThreadId = 0; 22 static const int kDocumentMainThreadId = 0;
23 23
24 ServiceWorkerProviderHost::ServiceWorkerProviderHost( 24 ServiceWorkerProviderHost::ServiceWorkerProviderHost(
25 int process_id, int provider_id, 25 int process_id, int provider_id,
26 base::WeakPtr<ServiceWorkerContextCore> context, 26 base::WeakPtr<ServiceWorkerContextCore> context,
27 ServiceWorkerDispatcherHost* dispatcher_host) 27 ServiceWorkerDispatcherHost* dispatcher_host)
28 : process_id_(process_id), 28 : process_id_(process_id),
29 provider_id_(provider_id), 29 provider_id_(provider_id),
30 context_(context), 30 context_(context),
31 dispatcher_host_(dispatcher_host) { 31 dispatcher_host_(dispatcher_host),
32 allow_association_(true) {
32 } 33 }
33 34
34 ServiceWorkerProviderHost::~ServiceWorkerProviderHost() { 35 ServiceWorkerProviderHost::~ServiceWorkerProviderHost() {
35 // Clear docurl so the deferred activation of a waiting worker 36 // Clear docurl so the deferred activation of a waiting worker
36 // won't associate the new version with a provider being destroyed. 37 // won't associate the new version with a provider being destroyed.
37 document_url_ = GURL(); 38 document_url_ = GURL();
38 if (controlling_version_.get()) 39 if (controlling_version_.get())
39 controlling_version_->RemoveControllee(this); 40 controlling_version_->RemoveControllee(this);
40 if (active_version_.get()) 41 if (active_version_.get())
41 active_version_->RemovePotentialControllee(this); 42 active_version_->RemovePotentialControllee(this);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 } 180 }
180 return scoped_ptr<ServiceWorkerRequestHandler>(); 181 return scoped_ptr<ServiceWorkerRequestHandler>();
181 } 182 }
182 183
183 bool ServiceWorkerProviderHost::CanAssociateRegistration( 184 bool ServiceWorkerProviderHost::CanAssociateRegistration(
184 ServiceWorkerRegistration* registration) { 185 ServiceWorkerRegistration* registration) {
185 if (!context_) 186 if (!context_)
186 return false; 187 return false;
187 if (running_hosted_version_.get()) 188 if (running_hosted_version_.get())
188 return false; 189 return false;
189 if (!registration || associated_registration_.get()) 190 if (!registration || associated_registration_.get() || !allow_association_)
190 return false; 191 return false;
191 return true; 192 return true;
192 } 193 }
193 194
194 void ServiceWorkerProviderHost::PostMessage( 195 void ServiceWorkerProviderHost::PostMessage(
195 const base::string16& message, 196 const base::string16& message,
196 const std::vector<int>& sent_message_port_ids) { 197 const std::vector<int>& sent_message_port_ids) {
197 if (!dispatcher_host_) 198 if (!dispatcher_host_)
198 return; // Could be NULL in some tests. 199 return; // Could be NULL in some tests.
199 200
(...skipping 24 matching lines...) Expand all
224 dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass()); 225 dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass());
225 } 226 }
226 return info; 227 return info;
227 } 228 }
228 229
229 bool ServiceWorkerProviderHost::IsContextAlive() { 230 bool ServiceWorkerProviderHost::IsContextAlive() {
230 return context_ != NULL; 231 return context_ != NULL;
231 } 232 }
232 233
233 } // namespace content 234 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698