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 23 matching lines...) Expand all Loading... | |
34 // won't associate the new version with a provider being destroyed. | 34 // won't associate the new version with a provider being destroyed. |
35 document_url_ = GURL(); | 35 document_url_ = GURL(); |
36 if (controlling_version_) | 36 if (controlling_version_) |
37 controlling_version_->RemoveControllee(this); | 37 controlling_version_->RemoveControllee(this); |
38 if (active_version_) | 38 if (active_version_) |
39 active_version_->RemovePotentialControllee(this); | 39 active_version_->RemovePotentialControllee(this); |
40 if (waiting_version_) | 40 if (waiting_version_) |
41 waiting_version_->RemovePotentialControllee(this); | 41 waiting_version_->RemovePotentialControllee(this); |
42 if (installing_version_) | 42 if (installing_version_) |
43 installing_version_->RemovePotentialControllee(this); | 43 installing_version_->RemovePotentialControllee(this); |
44 if (associated_registration_) | |
45 associated_registration_->RemoveListener(this); | |
46 } | |
47 | |
48 void ServiceWorkerProviderHost::OnVersionAttributesChanged( | |
49 ServiceWorkerRegistration* registration, | |
50 ChangedVersionAttributesMask changed_mask, | |
51 const ServiceWorkerRegistrationInfo& info) { | |
52 if (changed_mask.installing_changed()) | |
53 SetInstallingVersion(registration->installing_version()); | |
54 if (changed_mask.waiting_changed()) | |
55 SetWaitingVersion(registration->waiting_version()); | |
56 if (changed_mask.active_changed()) | |
57 SetActiveVersion(registration->active_version()); | |
44 } | 58 } |
45 | 59 |
46 void ServiceWorkerProviderHost::SetDocumentUrl(const GURL& url) { | 60 void ServiceWorkerProviderHost::SetDocumentUrl(const GURL& url) { |
47 DCHECK(!url.has_ref()); | 61 DCHECK(!url.has_ref()); |
48 document_url_ = url; | 62 document_url_ = url; |
49 } | 63 } |
50 | 64 |
51 void ServiceWorkerProviderHost::SetControllerVersion( | 65 void ServiceWorkerProviderHost::SetControllerVersion( |
52 ServiceWorkerVersion* version) { | 66 ServiceWorkerVersion* version) { |
53 DCHECK(CanAssociateVersion(version)); | 67 DCHECK(CanAssociateVersion(version)); |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 else if (waiting_version_) | 208 else if (waiting_version_) |
195 already_associated_version = waiting_version_; | 209 already_associated_version = waiting_version_; |
196 else if (installing_version_) | 210 else if (installing_version_) |
197 already_associated_version = installing_version_; | 211 already_associated_version = installing_version_; |
198 | 212 |
199 return !already_associated_version || | 213 return !already_associated_version || |
200 already_associated_version->registration_id() == | 214 already_associated_version->registration_id() == |
201 version->registration_id(); | 215 version->registration_id(); |
202 } | 216 } |
203 | 217 |
218 void ServiceWorkerProviderHost::AssociateRegistration( | |
219 ServiceWorkerRegistration* registration) { | |
220 DCHECK(registration); | |
221 if (!context_ || associated_registration_) | |
falken
2014/08/05 02:41:28
nit: Since AssociateRegistration only takes effect
nhiroki
2014/08/05 15:51:12
Done.
| |
222 return; | |
223 associated_registration_ = registration; | |
224 registration->AddListener(this); | |
225 } | |
226 | |
204 void ServiceWorkerProviderHost::PostMessage( | 227 void ServiceWorkerProviderHost::PostMessage( |
205 const base::string16& message, | 228 const base::string16& message, |
206 const std::vector<int>& sent_message_port_ids) { | 229 const std::vector<int>& sent_message_port_ids) { |
207 if (!dispatcher_host_) | 230 if (!dispatcher_host_) |
208 return; // Could be NULL in some tests. | 231 return; // Could be NULL in some tests. |
209 | 232 |
210 std::vector<int> new_routing_ids; | 233 std::vector<int> new_routing_ids; |
211 dispatcher_host_->message_port_message_filter()-> | 234 dispatcher_host_->message_port_message_filter()-> |
212 UpdateMessagePortsWithNewRoutes(sent_message_port_ids, | 235 UpdateMessagePortsWithNewRoutes(sent_message_port_ids, |
213 &new_routing_ids); | 236 &new_routing_ids); |
(...skipping 17 matching lines...) Expand all Loading... | |
231 dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass()); | 254 dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass()); |
232 } | 255 } |
233 return info; | 256 return info; |
234 } | 257 } |
235 | 258 |
236 bool ServiceWorkerProviderHost::IsContextAlive() { | 259 bool ServiceWorkerProviderHost::IsContextAlive() { |
237 return context_ != NULL; | 260 return context_ != NULL; |
238 } | 261 } |
239 | 262 |
240 } // namespace content | 263 } // namespace content |
OLD | NEW |