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

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
« no previous file with comments | « content/browser/service_worker/service_worker_provider_host.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 (associated_registration_.get()) { 41 if (associated_registration_.get()) {
41 DecreaseProcessReference(associated_registration_->pattern()); 42 DecreaseProcessReference(associated_registration_->pattern());
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 } 177 }
177 return scoped_ptr<ServiceWorkerRequestHandler>(); 178 return scoped_ptr<ServiceWorkerRequestHandler>();
178 } 179 }
179 180
180 bool ServiceWorkerProviderHost::CanAssociateRegistration( 181 bool ServiceWorkerProviderHost::CanAssociateRegistration(
181 ServiceWorkerRegistration* registration) { 182 ServiceWorkerRegistration* registration) {
182 if (!context_) 183 if (!context_)
183 return false; 184 return false;
184 if (running_hosted_version_.get()) 185 if (running_hosted_version_.get())
185 return false; 186 return false;
186 if (!registration || associated_registration_.get()) 187 if (!registration || associated_registration_.get() || !allow_association_)
187 return false; 188 return false;
188 return true; 189 return true;
189 } 190 }
190 191
191 void ServiceWorkerProviderHost::PostMessage( 192 void ServiceWorkerProviderHost::PostMessage(
192 const base::string16& message, 193 const base::string16& message,
193 const std::vector<int>& sent_message_port_ids) { 194 const std::vector<int>& sent_message_port_ids) {
194 if (!dispatcher_host_) 195 if (!dispatcher_host_)
195 return; // Could be NULL in some tests. 196 return; // Could be NULL in some tests.
196 197
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 context_->process_manager()->RemoveProcessReferenceFromPattern( 244 context_->process_manager()->RemoveProcessReferenceFromPattern(
244 pattern, process_id_); 245 pattern, process_id_);
245 } 246 }
246 } 247 }
247 248
248 bool ServiceWorkerProviderHost::IsContextAlive() { 249 bool ServiceWorkerProviderHost::IsContextAlive() {
249 return context_ != NULL; 250 return context_ != NULL;
250 } 251 }
251 252
252 } // namespace content 253 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_provider_host.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698