| 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_register_job.h" | 5 #include "content/browser/service_worker/service_worker_register_job.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/browser/service_worker/service_worker_context_core.h" | 10 #include "content/browser/service_worker/service_worker_context_core.h" |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 case net::ERR_ABORTED: | 347 case net::ERR_ABORTED: |
| 348 status = SERVICE_WORKER_ERROR_ABORT; | 348 status = SERVICE_WORKER_ERROR_ABORT; |
| 349 break; | 349 break; |
| 350 default: | 350 default: |
| 351 status = SERVICE_WORKER_ERROR_NETWORK; | 351 status = SERVICE_WORKER_ERROR_NETWORK; |
| 352 } | 352 } |
| 353 message = new_version()->script_cache_map()->main_script_status_message(); | 353 message = new_version()->script_cache_map()->main_script_status_message(); |
| 354 if (message.empty()) | 354 if (message.empty()) |
| 355 message = kFetchScriptError; | 355 message = kFetchScriptError; |
| 356 } | 356 } |
| 357 |
| 358 if (status == SERVICE_WORKER_ERROR_TIMEOUT) |
| 359 message = "Timed out while trying to start the Service Worker."; |
| 360 |
| 357 Complete(status, message); | 361 Complete(status, message); |
| 358 } | 362 } |
| 359 | 363 |
| 360 // This function corresponds to the spec's [[Install]] algorithm. | 364 // This function corresponds to the spec's [[Install]] algorithm. |
| 361 void ServiceWorkerRegisterJob::InstallAndContinue() { | 365 void ServiceWorkerRegisterJob::InstallAndContinue() { |
| 362 SetPhase(INSTALL); | 366 SetPhase(INSTALL); |
| 363 | 367 |
| 364 // "Set registration.installingWorker to worker." | 368 // "Set registration.installingWorker to worker." |
| 365 DCHECK(!registration()->installing_version()); | 369 DCHECK(!registration()->installing_version()); |
| 366 registration()->SetInstallingVersion(new_version()); | 370 registration()->SetInstallingVersion(new_version()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 383 | 387 |
| 384 // A subsequent registration job may terminate our installing worker. It can | 388 // A subsequent registration job may terminate our installing worker. It can |
| 385 // only do so after we've started the worker and dispatched the install | 389 // only do so after we've started the worker and dispatched the install |
| 386 // event, as those are atomic substeps in the [[Install]] algorithm. | 390 // event, as those are atomic substeps in the [[Install]] algorithm. |
| 387 if (doom_installing_worker_) | 391 if (doom_installing_worker_) |
| 388 Complete(SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED); | 392 Complete(SERVICE_WORKER_ERROR_INSTALL_WORKER_FAILED); |
| 389 } | 393 } |
| 390 | 394 |
| 391 void ServiceWorkerRegisterJob::OnInstallFinished( | 395 void ServiceWorkerRegisterJob::OnInstallFinished( |
| 392 ServiceWorkerStatusCode status) { | 396 ServiceWorkerStatusCode status) { |
| 393 // TODO(kinuko,falken): For some error cases (e.g. ServiceWorker is | |
| 394 // unexpectedly terminated) we may want to retry sending the event again. | |
| 395 if (status != SERVICE_WORKER_OK) { | 397 if (status != SERVICE_WORKER_OK) { |
| 396 // "8. If installFailed is true, then:..." | 398 // "8. If installFailed is true, then:..." |
| 397 Complete(status); | 399 Complete(status); |
| 398 return; | 400 return; |
| 399 } | 401 } |
| 400 | 402 |
| 401 SetPhase(STORE); | 403 SetPhase(STORE); |
| 402 registration()->set_last_update_check(base::Time::Now()); | 404 registration()->set_last_update_check(base::Time::Now()); |
| 403 context_->storage()->StoreRegistration( | 405 context_->storage()->StoreRegistration( |
| 404 registration(), | 406 registration(), |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 ServiceWorkerProviderHost* host = it->GetProviderHost(); | 558 ServiceWorkerProviderHost* host = it->GetProviderHost(); |
| 557 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), | 559 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), |
| 558 host->document_url())) { | 560 host->document_url())) { |
| 559 if (host->CanAssociateRegistration(registration)) | 561 if (host->CanAssociateRegistration(registration)) |
| 560 host->AssociateRegistration(registration); | 562 host->AssociateRegistration(registration); |
| 561 } | 563 } |
| 562 } | 564 } |
| 563 } | 565 } |
| 564 | 566 |
| 565 } // namespace content | 567 } // namespace content |
| OLD | NEW |