| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 | 485 |
| 486 void ServiceWorkerRegisterJob::OnStoreRegistrationComplete( | 486 void ServiceWorkerRegisterJob::OnStoreRegistrationComplete( |
| 487 ServiceWorkerStatusCode status) { | 487 ServiceWorkerStatusCode status) { |
| 488 if (status != SERVICE_WORKER_OK) { | 488 if (status != SERVICE_WORKER_OK) { |
| 489 Complete(status); | 489 Complete(status); |
| 490 return; | 490 return; |
| 491 } | 491 } |
| 492 | 492 |
| 493 // "9. If registration.waitingWorker is not null, then:..." | 493 // "9. If registration.waitingWorker is not null, then:..." |
| 494 if (registration()->waiting_version()) { | 494 if (registration()->waiting_version()) { |
| 495 // "1. Run the [[UpdateState]] algorithm passing registration.waitingWorker | 495 // 1. Set redundantWorker to registration’s waiting worker. |
| 496 // and "redundant" as the arguments." | 496 // 2. Terminate redundantWorker. |
| 497 registration()->waiting_version()->StopWorker( |
| 498 base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 499 // TODO(falken): Move this further down. The spec says to set status to |
| 500 // 'redundant' after promoting the new version to .waiting attribute and |
| 501 // 'installed' status. |
| 497 registration()->waiting_version()->SetStatus( | 502 registration()->waiting_version()->SetStatus( |
| 498 ServiceWorkerVersion::REDUNDANT); | 503 ServiceWorkerVersion::REDUNDANT); |
| 499 } | 504 } |
| 500 | 505 |
| 501 // "10. Set registration.waitingWorker to registration.installingWorker." | 506 // "10. Set registration.waitingWorker to registration.installingWorker." |
| 502 // "11. Set registration.installingWorker to null." | 507 // "11. Set registration.installingWorker to null." |
| 503 registration()->SetWaitingVersion(new_version()); | 508 registration()->SetWaitingVersion(new_version()); |
| 504 | 509 |
| 505 // "12. Run the [[UpdateState]] algorithm passing registration.waitingWorker | 510 // "12. Run the [[UpdateState]] algorithm passing registration.waitingWorker |
| 506 // and "installed" as the arguments." | 511 // and "installed" as the arguments." |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 new_version()->force_bypass_cache_for_scripts() || | 637 new_version()->force_bypass_cache_for_scripts() || |
| 633 registration()->last_update_check().is_null()) { | 638 registration()->last_update_check().is_null()) { |
| 634 registration()->set_last_update_check(base::Time::Now()); | 639 registration()->set_last_update_check(base::Time::Now()); |
| 635 | 640 |
| 636 if (registration()->has_installed_version()) | 641 if (registration()->has_installed_version()) |
| 637 context_->storage()->UpdateLastUpdateCheckTime(registration()); | 642 context_->storage()->UpdateLastUpdateCheckTime(registration()); |
| 638 } | 643 } |
| 639 } | 644 } |
| 640 | 645 |
| 641 } // namespace content | 646 } // namespace content |
| OLD | NEW |