| 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_version.h" | 5 #include "content/browser/service_worker/service_worker_version.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "content/browser/service_worker/embedded_worker_instance.h" | 8 #include "content/browser/service_worker/embedded_worker_instance.h" |
| 9 #include "content/browser/service_worker/embedded_worker_registry.h" | 9 #include "content/browser/service_worker/embedded_worker_registry.h" |
| 10 #include "content/browser/service_worker/service_worker_context_core.h" | 10 #include "content/browser/service_worker/service_worker_context_core.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 | 272 |
| 273 void ServiceWorkerVersion::DispatchFetchEvent( | 273 void ServiceWorkerVersion::DispatchFetchEvent( |
| 274 const ServiceWorkerFetchRequest& request, | 274 const ServiceWorkerFetchRequest& request, |
| 275 const FetchCallback& callback) { | 275 const FetchCallback& callback) { |
| 276 DCHECK_EQ(ACTIVE, status()) << status(); | 276 DCHECK_EQ(ACTIVE, status()) << status(); |
| 277 SendMessageAndRegisterCallback( | 277 SendMessageAndRegisterCallback( |
| 278 ServiceWorkerMsg_FetchEvent(request), | 278 ServiceWorkerMsg_FetchEvent(request), |
| 279 base::Bind(&HandleFetchResponse, callback)); | 279 base::Bind(&HandleFetchResponse, callback)); |
| 280 } | 280 } |
| 281 | 281 |
| 282 void ServiceWorkerVersion::DispatchSyncEvent(const StatusCallback& callback) { |
| 283 DCHECK_EQ(ACTIVE, status()) << status(); |
| 284 SendMessageAndRegisterCallback( |
| 285 ServiceWorkerMsg_SyncEvent(-1), |
| 286 base::Bind(&HandleEventFinished, |
| 287 weak_factory_.GetWeakPtr(), |
| 288 ServiceWorkerHostMsg_SyncEventFinished::ID, |
| 289 callback, |
| 290 ACTIVE, |
| 291 ACTIVE)); |
| 292 } |
| 293 |
| 282 void ServiceWorkerVersion::AddProcessToWorker(int process_id) { | 294 void ServiceWorkerVersion::AddProcessToWorker(int process_id) { |
| 283 DCHECK(!is_shutdown_); | 295 DCHECK(!is_shutdown_); |
| 284 embedded_worker_->AddProcessReference(process_id); | 296 embedded_worker_->AddProcessReference(process_id); |
| 285 } | 297 } |
| 286 | 298 |
| 287 void ServiceWorkerVersion::RemoveProcessToWorker(int process_id) { | 299 void ServiceWorkerVersion::RemoveProcessToWorker(int process_id) { |
| 288 // We may have been shutdown. | 300 // We may have been shutdown. |
| 289 if (embedded_worker_) | 301 if (embedded_worker_) |
| 290 embedded_worker_->ReleaseProcessReference(process_id); | 302 embedded_worker_->ReleaseProcessReference(process_id); |
| 291 } | 303 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 321 if (callback) { | 333 if (callback) { |
| 322 callback->Run(SERVICE_WORKER_OK, message); | 334 callback->Run(SERVICE_WORKER_OK, message); |
| 323 message_callbacks_.Remove(request_id); | 335 message_callbacks_.Remove(request_id); |
| 324 return; | 336 return; |
| 325 } | 337 } |
| 326 NOTREACHED() << "Got unexpected message: " << request_id | 338 NOTREACHED() << "Got unexpected message: " << request_id |
| 327 << " " << message.type(); | 339 << " " << message.type(); |
| 328 } | 340 } |
| 329 | 341 |
| 330 } // namespace content | 342 } // namespace content |
| OLD | NEW |