OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |