| 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_registration.h" | 5 #include "content/browser/service_worker/service_worker_registration.h" |
| 6 | 6 |
| 7 #include "content/browser/service_worker/service_worker_context_core.h" | 7 #include "content/browser/service_worker/service_worker_context_core.h" |
| 8 #include "content/browser/service_worker/service_worker_info.h" | 8 #include "content/browser/service_worker/service_worker_info.h" |
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" |
| 10 | 10 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 context_->RemoveLiveRegistration(registration_id_); | 31 context_->RemoveLiveRegistration(registration_id_); |
| 32 } | 32 } |
| 33 | 33 |
| 34 ServiceWorkerRegistrationInfo ServiceWorkerRegistration::GetInfo() { | 34 ServiceWorkerRegistrationInfo ServiceWorkerRegistration::GetInfo() { |
| 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 35 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 36 return ServiceWorkerRegistrationInfo( | 36 return ServiceWorkerRegistrationInfo( |
| 37 script_url(), | 37 script_url(), |
| 38 pattern(), | 38 pattern(), |
| 39 registration_id_, | 39 registration_id_, |
| 40 active_version_ ? active_version_->GetInfo() : ServiceWorkerVersionInfo(), | 40 active_version_ ? active_version_->GetInfo() : ServiceWorkerVersionInfo(), |
| 41 pending_version_ ? pending_version_->GetInfo() | 41 waiting_version_ ? waiting_version_->GetInfo() |
| 42 : ServiceWorkerVersionInfo()); | 42 : ServiceWorkerVersionInfo()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 ServiceWorkerVersion* ServiceWorkerRegistration::GetNewestVersion() { | 45 ServiceWorkerVersion* ServiceWorkerRegistration::GetNewestVersion() { |
| 46 if (active_version()) | 46 if (active_version()) |
| 47 return active_version(); | 47 return active_version(); |
| 48 return pending_version(); | 48 return waiting_version(); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void ServiceWorkerRegistration::ActivatePendingVersion() { | 51 void ServiceWorkerRegistration::ActivateWaitingVersion() { |
| 52 active_version_->SetStatus(ServiceWorkerVersion::DEACTIVATED); | 52 active_version_->SetStatus(ServiceWorkerVersion::DEACTIVATED); |
| 53 active_version_ = pending_version_; | 53 active_version_ = waiting_version_; |
| 54 // TODO(kinuko): This should be set to ACTIVATING until activation finishes. | 54 // TODO(kinuko): This should be set to ACTIVATING until activation finishes. |
| 55 active_version_->SetStatus(ServiceWorkerVersion::ACTIVE); | 55 active_version_->SetStatus(ServiceWorkerVersion::ACTIVE); |
| 56 pending_version_ = NULL; | 56 waiting_version_ = NULL; |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace content | 59 } // namespace content |
| OLD | NEW |