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_info.h" |
7 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
8 | 9 |
9 namespace content { | 10 namespace content { |
10 | 11 |
11 ServiceWorkerRegistration::ServiceWorkerRegistration(const GURL& pattern, | 12 ServiceWorkerRegistration::ServiceWorkerRegistration(const GURL& pattern, |
12 const GURL& script_url, | 13 const GURL& script_url, |
13 int64 registration_id) | 14 int64 registration_id) |
14 : pattern_(pattern), | 15 : pattern_(pattern), |
15 script_url_(script_url), | 16 script_url_(script_url), |
16 registration_id_(registration_id), | 17 registration_id_(registration_id), |
(...skipping 10 matching lines...) Expand all Loading... |
27 DCHECK(!is_shutdown_); | 28 DCHECK(!is_shutdown_); |
28 if (active_version_) | 29 if (active_version_) |
29 active_version_->Shutdown(); | 30 active_version_->Shutdown(); |
30 active_version_ = NULL; | 31 active_version_ = NULL; |
31 if (pending_version_) | 32 if (pending_version_) |
32 pending_version_->Shutdown(); | 33 pending_version_->Shutdown(); |
33 pending_version_ = NULL; | 34 pending_version_ = NULL; |
34 is_shutdown_ = true; | 35 is_shutdown_ = true; |
35 } | 36 } |
36 | 37 |
| 38 ServiceWorkerRegistrationInfo ServiceWorkerRegistration::GetInfo() { |
| 39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 40 return ServiceWorkerRegistrationInfo( |
| 41 script_url(), |
| 42 pattern(), |
| 43 active_version_ ? active_version_->GetInfo() : ServiceWorkerVersionInfo(), |
| 44 pending_version_ ? pending_version_->GetInfo() |
| 45 : ServiceWorkerVersionInfo()); |
| 46 } |
| 47 |
37 void ServiceWorkerRegistration::ActivatePendingVersion() { | 48 void ServiceWorkerRegistration::ActivatePendingVersion() { |
38 active_version_->set_status(ServiceWorkerVersion::DEACTIVATED); | 49 active_version_->set_status(ServiceWorkerVersion::DEACTIVATED); |
39 active_version_->Shutdown(); | 50 active_version_->Shutdown(); |
40 active_version_ = pending_version_; | 51 active_version_ = pending_version_; |
41 active_version_->set_status(ServiceWorkerVersion::ACTIVE); | 52 active_version_->set_status(ServiceWorkerVersion::ACTIVE); |
42 pending_version_ = NULL; | 53 pending_version_ = NULL; |
43 } | 54 } |
44 | 55 |
45 } // namespace content | 56 } // namespace content |
OLD | NEW |