| 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 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED); | 299 SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED); |
| 300 SendMessageAndRegisterCallback( | 300 SendMessageAndRegisterCallback( |
| 301 ServiceWorkerMsg_InstallEvent(active_version_id), | 301 ServiceWorkerMsg_InstallEvent(active_version_id), |
| 302 base::Bind(&HandleInstallPhaseEventFinished, params)); | 302 base::Bind(&HandleInstallPhaseEventFinished, params)); |
| 303 } | 303 } |
| 304 | 304 |
| 305 void ServiceWorkerVersion::DispatchActivateEvent( | 305 void ServiceWorkerVersion::DispatchActivateEvent( |
| 306 const StatusCallback& callback) { | 306 const StatusCallback& callback) { |
| 307 DCHECK_EQ(INSTALLED, status()) << status(); | 307 DCHECK_EQ(INSTALLED, status()) << status(); |
| 308 SetStatus(ACTIVATING); | 308 SetStatus(ACTIVATING); |
| 309 // TODO(kinuko): Implement. | 309 // TODO(dominicc): Also dispatch activate callbacks to the document, |
| 310 NOTIMPLEMENTED(); | 310 // and activate end callbacks to the service worker and the document. |
| 311 HandleInstallPhaseEventFinishedParameters params( | 311 HandleInstallPhaseEventFinishedParameters params( |
| 312 weak_factory_.GetWeakPtr(), | 312 weak_factory_.GetWeakPtr(), |
| 313 -1 /* dummy message_id */, | 313 ServiceWorkerHostMsg_ActivateEventFinished::ID, |
| 314 InstallPhaseEventFinishedMessageReader(), | 314 base::Bind(&ServiceWorkerHostMsg_ActivateEventFinished::Read), |
| 315 callback, | 315 callback, |
| 316 ACTIVE, | 316 ACTIVE, |
| 317 INSTALLED, | 317 INSTALLED, |
| 318 SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED); | 318 SERVICE_WORKER_ERROR_ACTIVATE_WORKER_FAILED); |
| 319 RunSoon(base::Bind(&HandleInstallPhaseEventFinished, | 319 SendMessageAndRegisterCallback( |
| 320 params, | 320 ServiceWorkerMsg_ActivateEvent(), |
| 321 SERVICE_WORKER_OK, | 321 base::Bind(&HandleInstallPhaseEventFinished, params)); |
| 322 IPC::Message(-1, -1, IPC::Message::PRIORITY_NORMAL))); | |
| 323 } | 322 } |
| 324 | 323 |
| 325 void ServiceWorkerVersion::DispatchFetchEvent( | 324 void ServiceWorkerVersion::DispatchFetchEvent( |
| 326 const ServiceWorkerFetchRequest& request, | 325 const ServiceWorkerFetchRequest& request, |
| 327 const FetchCallback& callback) { | 326 const FetchCallback& callback) { |
| 328 DCHECK_EQ(ACTIVE, status()) << status(); | 327 DCHECK_EQ(ACTIVE, status()) << status(); |
| 329 SendMessageAndRegisterCallback( | 328 SendMessageAndRegisterCallback( |
| 330 ServiceWorkerMsg_FetchEvent(request), | 329 ServiceWorkerMsg_FetchEvent(request), |
| 331 base::Bind(&HandleFetchResponse, callback)); | 330 base::Bind(&HandleFetchResponse, callback)); |
| 332 } | 331 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 if (callback) { | 372 if (callback) { |
| 374 callback->Run(SERVICE_WORKER_OK, message); | 373 callback->Run(SERVICE_WORKER_OK, message); |
| 375 message_callbacks_.Remove(request_id); | 374 message_callbacks_.Remove(request_id); |
| 376 return; | 375 return; |
| 377 } | 376 } |
| 378 NOTREACHED() << "Got unexpected message: " << request_id | 377 NOTREACHED() << "Got unexpected message: " << request_id |
| 379 << " " << message.type(); | 378 << " " << message.type(); |
| 380 } | 379 } |
| 381 | 380 |
| 382 } // namespace content | 381 } // namespace content |
| OLD | NEW |