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" |
(...skipping 27 matching lines...) Expand all Loading... |
38 const GURL& script_url, | 38 const GURL& script_url, |
39 int64 registration_id); | 39 int64 registration_id); |
40 | 40 |
41 void Shutdown(); | 41 void Shutdown(); |
42 bool is_shutdown() const { return is_shutdown_; } | 42 bool is_shutdown() const { return is_shutdown_; } |
43 | 43 |
44 int64 id() const { return registration_id_; } | 44 int64 id() const { return registration_id_; } |
45 const GURL& script_url() const { return script_url_; } | 45 const GURL& script_url() const { return script_url_; } |
46 const GURL& pattern() const { return pattern_; } | 46 const GURL& pattern() const { return pattern_; } |
47 | 47 |
| 48 int64 next_version_id() { return next_version_id_++; } |
| 49 |
48 ServiceWorkerVersion* active_version() const { | 50 ServiceWorkerVersion* active_version() const { |
49 DCHECK(!is_shutdown_); | 51 DCHECK(!is_shutdown_); |
50 return active_version_.get(); | 52 return active_version_.get(); |
51 } | 53 } |
52 | 54 |
53 ServiceWorkerVersion* pending_version() const { | 55 ServiceWorkerVersion* pending_version() const { |
54 DCHECK(!is_shutdown_); | 56 DCHECK(!is_shutdown_); |
55 return pending_version_.get(); | 57 return pending_version_.get(); |
56 } | 58 } |
57 | 59 |
58 void set_active_version(ServiceWorkerVersion* version) { | 60 void set_active_version(ServiceWorkerVersion* version) { |
59 DCHECK(!is_shutdown_); | 61 DCHECK(!is_shutdown_); |
60 active_version_ = version; | 62 active_version_ = version; |
61 } | 63 } |
62 | 64 |
63 void set_pending_version(ServiceWorkerVersion* version) { | 65 void set_pending_version(ServiceWorkerVersion* version) { |
64 DCHECK(!is_shutdown_); | 66 DCHECK(!is_shutdown_); |
65 pending_version_ = version; | 67 pending_version_ = version; |
66 } | 68 } |
67 | 69 |
68 // The final synchronous switchover after all events have been | 70 // The final synchronous switchover after all events have been |
69 // fired, and the old "active version" is being shut down. | 71 // fired, and the old "active version" is being shut down. |
70 void ActivatePendingVersion(); | 72 void ActivatePendingVersion(); |
71 | 73 |
72 private: | 74 private: |
73 virtual ~ServiceWorkerRegistration(); | 75 ~ServiceWorkerRegistration(); |
74 friend class base::RefCounted<ServiceWorkerRegistration>; | 76 friend class base::RefCounted<ServiceWorkerRegistration>; |
75 | 77 |
76 const GURL pattern_; | 78 const GURL pattern_; |
77 const GURL script_url_; | 79 const GURL script_url_; |
78 const int64 registration_id_; | 80 const int64 registration_id_; |
| 81 int64 next_version_id_; |
79 | 82 |
80 scoped_refptr<ServiceWorkerVersion> active_version_; | 83 scoped_refptr<ServiceWorkerVersion> active_version_; |
81 scoped_refptr<ServiceWorkerVersion> pending_version_; | 84 scoped_refptr<ServiceWorkerVersion> pending_version_; |
82 | 85 |
83 bool is_shutdown_; | 86 bool is_shutdown_; |
84 | 87 |
85 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration); | 88 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration); |
86 }; | 89 }; |
87 } // namespace content | 90 } // namespace content |
88 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ | 91 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ |
OLD | NEW |