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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 } | 138 } |
139 | 139 |
140 running_hosted_version_ = live_version; | 140 running_hosted_version_ = live_version; |
141 return true; | 141 return true; |
142 } | 142 } |
143 | 143 |
144 void ServiceWorkerProviderHost::AssociateRegistration( | 144 void ServiceWorkerProviderHost::AssociateRegistration( |
145 ServiceWorkerRegistration* registration) { | 145 ServiceWorkerRegistration* registration) { |
146 DCHECK(CanAssociateRegistration(registration)); | 146 DCHECK(CanAssociateRegistration(registration)); |
147 associated_registration_ = registration; | 147 associated_registration_ = registration; |
| 148 |
| 149 if (dispatcher_host_) { |
| 150 ServiceWorkerRegistrationObjectInfo info = |
| 151 dispatcher_host_->GetOrCreateRegistrationHandle( |
| 152 provider_id(), registration); |
| 153 dispatcher_host_->Send(new ServiceWorkerMsg_AssociateRegistration( |
| 154 kDocumentMainThreadId, provider_id(), info)); |
| 155 } |
| 156 |
148 registration->AddListener(this); | 157 registration->AddListener(this); |
149 UpdatePotentialControllees(registration->installing_version(), | 158 UpdatePotentialControllees(registration->installing_version(), |
150 registration->waiting_version(), | 159 registration->waiting_version(), |
151 registration->active_version()); | 160 registration->active_version()); |
152 SetControllerVersionAttribute(registration->active_version()); | 161 SetControllerVersionAttribute(registration->active_version()); |
153 } | 162 } |
154 | 163 |
155 void ServiceWorkerProviderHost::UnassociateRegistration() { | 164 void ServiceWorkerProviderHost::UnassociateRegistration() { |
156 if (!associated_registration_.get()) | 165 if (!associated_registration_.get()) |
157 return; | 166 return; |
| 167 |
| 168 if (dispatcher_host_) { |
| 169 dispatcher_host_->Send(new ServiceWorkerMsg_UnassociateRegistration( |
| 170 kDocumentMainThreadId, provider_id())); |
| 171 } |
| 172 |
158 associated_registration_->RemoveListener(this); | 173 associated_registration_->RemoveListener(this); |
159 associated_registration_ = NULL; | 174 associated_registration_ = NULL; |
160 UpdatePotentialControllees(NULL, NULL, NULL); | 175 UpdatePotentialControllees(NULL, NULL, NULL); |
161 SetControllerVersionAttribute(NULL); | 176 SetControllerVersionAttribute(NULL); |
162 } | 177 } |
163 | 178 |
164 scoped_ptr<ServiceWorkerRequestHandler> | 179 scoped_ptr<ServiceWorkerRequestHandler> |
165 ServiceWorkerProviderHost::CreateRequestHandler( | 180 ServiceWorkerProviderHost::CreateRequestHandler( |
166 ResourceType resource_type, | 181 ResourceType resource_type, |
167 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, | 182 base::WeakPtr<storage::BlobStorageContext> blob_storage_context, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass()); | 239 dispatcher_host_->RegisterServiceWorkerHandle(handle.Pass()); |
225 } | 240 } |
226 return info; | 241 return info; |
227 } | 242 } |
228 | 243 |
229 bool ServiceWorkerProviderHost::IsContextAlive() { | 244 bool ServiceWorkerProviderHost::IsContextAlive() { |
230 return context_ != NULL; | 245 return context_ != NULL; |
231 } | 246 } |
232 | 247 |
233 } // namespace content | 248 } // namespace content |
OLD | NEW |