| 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 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 } | 419 } |
| 420 | 420 |
| 421 // "10. Set registration.waitingWorker to registration.installingWorker." | 421 // "10. Set registration.waitingWorker to registration.installingWorker." |
| 422 // "11. Set registration.installingWorker to null." | 422 // "11. Set registration.installingWorker to null." |
| 423 registration()->SetWaitingVersion(new_version()); | 423 registration()->SetWaitingVersion(new_version()); |
| 424 | 424 |
| 425 // "12. Run the [[UpdateState]] algorithm passing registration.waitingWorker | 425 // "12. Run the [[UpdateState]] algorithm passing registration.waitingWorker |
| 426 // and "installed" as the arguments." | 426 // and "installed" as the arguments." |
| 427 new_version()->SetStatus(ServiceWorkerVersion::INSTALLED); | 427 new_version()->SetStatus(ServiceWorkerVersion::INSTALLED); |
| 428 | 428 |
| 429 // TODO(michaeln): "13. If activateImmediate is true, then..." | 429 // "If registration's waiting worker's skip waiting flag is set:" |
| 430 | 430 if (new_version()->skip_waiting()) { |
| 431 // "14. Wait until no document is using registration as their | 431 registration()->ActivateWaitingVersion(); |
| 432 // Service Worker registration." | 432 } else { |
| 433 registration()->ActivateWaitingVersionWhenReady(); | 433 // "14. Wait until no document is using registration as their |
| 434 // Service Worker registration." |
| 435 registration()->ActivateWaitingVersionWhenReady(); |
| 436 } |
| 434 | 437 |
| 435 Complete(SERVICE_WORKER_OK); | 438 Complete(SERVICE_WORKER_OK); |
| 436 } | 439 } |
| 437 | 440 |
| 438 void ServiceWorkerRegisterJob::Complete(ServiceWorkerStatusCode status) { | 441 void ServiceWorkerRegisterJob::Complete(ServiceWorkerStatusCode status) { |
| 439 CompleteInternal(status); | 442 CompleteInternal(status); |
| 440 context_->job_coordinator()->FinishJob(pattern_, this); | 443 context_->job_coordinator()->FinishJob(pattern_, this); |
| 441 } | 444 } |
| 442 | 445 |
| 443 void ServiceWorkerRegisterJob::CompleteInternal( | 446 void ServiceWorkerRegisterJob::CompleteInternal( |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 551 ServiceWorkerProviderHost* host = it->GetProviderHost(); | 554 ServiceWorkerProviderHost* host = it->GetProviderHost(); |
| 552 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), | 555 if (ServiceWorkerUtils::ScopeMatches(registration->pattern(), |
| 553 host->document_url())) { | 556 host->document_url())) { |
| 554 if (host->CanAssociateRegistration(registration)) | 557 if (host->CanAssociateRegistration(registration)) |
| 555 host->AssociateRegistration(registration); | 558 host->AssociateRegistration(registration); |
| 556 } | 559 } |
| 557 } | 560 } |
| 558 } | 561 } |
| 559 | 562 |
| 560 } // namespace content | 563 } // namespace content |
| OLD | NEW |