| 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 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "content/browser/service_worker/service_worker_version.h" | 13 #include "content/browser/service_worker/service_worker_version.h" |
| 14 #include "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
| 15 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 16 | 16 |
| 17 namespace content { | 17 namespace content { |
| 18 | 18 |
| 19 class ServiceWorkerRegistrationInfo; |
| 19 class ServiceWorkerVersion; | 20 class ServiceWorkerVersion; |
| 20 | 21 |
| 21 // This class manages all persistence of service workers: | 22 // This class manages all persistence of service workers: |
| 22 // - Registrations | 23 // - Registrations |
| 23 // - Mapping of caches to registrations / versions | 24 // - Mapping of caches to registrations / versions |
| 24 // | 25 // |
| 25 // This is the place where we manage simultaneous | 26 // This is the place where we manage simultaneous |
| 26 // requests for the same registrations and caches, making sure that | 27 // requests for the same registrations and caches, making sure that |
| 27 // two pages that are registering the same pattern at the same time | 28 // two pages that are registering the same pattern at the same time |
| 28 // have their registrations coalesced rather than overwriting each | 29 // have their registrations coalesced rather than overwriting each |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 void set_active_version(ServiceWorkerVersion* version) { | 61 void set_active_version(ServiceWorkerVersion* version) { |
| 61 DCHECK(!is_shutdown_); | 62 DCHECK(!is_shutdown_); |
| 62 active_version_ = version; | 63 active_version_ = version; |
| 63 } | 64 } |
| 64 | 65 |
| 65 void set_pending_version(ServiceWorkerVersion* version) { | 66 void set_pending_version(ServiceWorkerVersion* version) { |
| 66 DCHECK(!is_shutdown_); | 67 DCHECK(!is_shutdown_); |
| 67 pending_version_ = version; | 68 pending_version_ = version; |
| 68 } | 69 } |
| 69 | 70 |
| 71 ServiceWorkerRegistrationInfo GetInfo(); |
| 72 |
| 70 // The final synchronous switchover after all events have been | 73 // The final synchronous switchover after all events have been |
| 71 // fired, and the old "active version" is being shut down. | 74 // fired, and the old "active version" is being shut down. |
| 72 void ActivatePendingVersion(); | 75 void ActivatePendingVersion(); |
| 73 | 76 |
| 74 private: | 77 private: |
| 75 ~ServiceWorkerRegistration(); | 78 ~ServiceWorkerRegistration(); |
| 76 friend class base::RefCounted<ServiceWorkerRegistration>; | 79 friend class base::RefCounted<ServiceWorkerRegistration>; |
| 77 | 80 |
| 78 const GURL pattern_; | 81 const GURL pattern_; |
| 79 const GURL script_url_; | 82 const GURL script_url_; |
| 80 const int64 registration_id_; | 83 const int64 registration_id_; |
| 81 int64 next_version_id_; | 84 int64 next_version_id_; |
| 82 | 85 |
| 83 scoped_refptr<ServiceWorkerVersion> active_version_; | 86 scoped_refptr<ServiceWorkerVersion> active_version_; |
| 84 scoped_refptr<ServiceWorkerVersion> pending_version_; | 87 scoped_refptr<ServiceWorkerVersion> pending_version_; |
| 85 | 88 |
| 86 bool is_shutdown_; | 89 bool is_shutdown_; |
| 87 | 90 |
| 88 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration); | 91 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration); |
| 89 }; | 92 }; |
| 90 } // namespace content | 93 } // namespace content |
| 91 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ | 94 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ |
| OLD | NEW |