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/child/service_worker/service_worker_dispatcher.h" | 5 #include "content/child/service_worker/service_worker_dispatcher.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/threading/thread_local.h" | 9 #include "base/threading/thread_local.h" |
10 #include "content/child/child_thread.h" | 10 #include "content/child/child_thread.h" |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 registration->SetInstalling(GetServiceWorker(attrs.installing, true)); | 255 registration->SetInstalling(GetServiceWorker(attrs.installing, true)); |
256 registration->SetWaiting(GetServiceWorker(attrs.waiting, true)); | 256 registration->SetWaiting(GetServiceWorker(attrs.waiting, true)); |
257 registration->SetActive(GetServiceWorker(attrs.active, true)); | 257 registration->SetActive(GetServiceWorker(attrs.active, true)); |
258 | 258 |
259 callbacks->onSuccess(registration); | 259 callbacks->onSuccess(registration); |
260 pending_registration_callbacks_.Remove(request_id); | 260 pending_registration_callbacks_.Remove(request_id); |
261 } | 261 } |
262 | 262 |
263 void ServiceWorkerDispatcher::OnUnregistered( | 263 void ServiceWorkerDispatcher::OnUnregistered( |
264 int thread_id, | 264 int thread_id, |
265 int request_id) { | 265 int request_id, |
| 266 ServiceWorkerStatusCode status) { |
266 WebServiceWorkerUnregistrationCallbacks* callbacks = | 267 WebServiceWorkerUnregistrationCallbacks* callbacks = |
267 pending_unregistration_callbacks_.Lookup(request_id); | 268 pending_unregistration_callbacks_.Lookup(request_id); |
268 DCHECK(callbacks); | 269 DCHECK(callbacks); |
269 if (!callbacks) | 270 if (!callbacks) |
270 return; | 271 return; |
271 bool is_success = true; | 272 bool is_success = (status == SERVICE_WORKER_OK); |
272 callbacks->onSuccess(&is_success); | 273 callbacks->onSuccess(&is_success); |
273 pending_unregistration_callbacks_.Remove(request_id); | 274 pending_unregistration_callbacks_.Remove(request_id); |
274 } | 275 } |
275 | 276 |
276 void ServiceWorkerDispatcher::OnRegistrationError( | 277 void ServiceWorkerDispatcher::OnRegistrationError( |
277 int thread_id, | 278 int thread_id, |
278 int request_id, | 279 int request_id, |
279 WebServiceWorkerError::ErrorType error_type, | 280 WebServiceWorkerError::ErrorType error_type, |
280 const base::string16& message) { | 281 const base::string16& message) { |
281 WebServiceWorkerRegistrationCallbacks* callbacks = | 282 WebServiceWorkerRegistrationCallbacks* callbacks = |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 registrations_[registration_handle_id] = registration; | 502 registrations_[registration_handle_id] = registration; |
502 } | 503 } |
503 | 504 |
504 void ServiceWorkerDispatcher::RemoveServiceWorkerRegistration( | 505 void ServiceWorkerDispatcher::RemoveServiceWorkerRegistration( |
505 int registration_handle_id) { | 506 int registration_handle_id) { |
506 DCHECK(ContainsKey(registrations_, registration_handle_id)); | 507 DCHECK(ContainsKey(registrations_, registration_handle_id)); |
507 registrations_.erase(registration_handle_id); | 508 registrations_.erase(registration_handle_id); |
508 } | 509 } |
509 | 510 |
510 } // namespace content | 511 } // namespace content |
OLD | NEW |