Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ | |
| 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/gtest_prod_util.h" | |
| 10 #include "base/logging.h" | |
| 11 #include "base/memory/ref_counted.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "content/browser/service_worker/service_worker_version.h" | |
| 14 #include "content/common/content_export.h" | |
| 15 | |
| 16 class GURL; | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 class ServiceWorkerVersion; | |
| 21 | |
| 22 // This class acts as a persistent instance | |
|
michaeln
2013/11/13 01:53:24
This class comment and the other could use some wo
| |
| 23 class CONTENT_EXPORT ServiceWorkerRegistration | |
| 24 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerRegistration>) { | |
| 25 public: | |
| 26 ServiceWorkerRegistration(const GURL& pattern, | |
| 27 const GURL& script_url, | |
| 28 int64 registration_id); | |
| 29 | |
| 30 int64 id() const { return registration_id_; } | |
|
michaeln
2013/11/13 01:53:24
maybe a const getter for 'pattern' too and co-loca
alecflett
2013/11/13 18:28:24
Done.
| |
| 31 | |
| 32 void Shutdown(); | |
| 33 | |
| 34 const GURL& script_url() const { return script_url_; } | |
| 35 | |
| 36 scoped_refptr<ServiceWorkerVersion> active_version() const { | |
| 37 DCHECK(!is_shutdown_); | |
|
michaeln
2013/11/13 01:53:24
dcheck'ing the setters seems useful, we don't dche
alecflett
2013/11/13 18:28:24
I suspect that we might want access to things like
| |
| 38 return active_version_.get(); | |
| 39 } | |
| 40 | |
| 41 scoped_refptr<ServiceWorkerVersion> in_waiting_version() const { | |
|
michaeln
2013/11/13 01:53:24
Terminology... wdyt of using the term "pending" in
alecflett
2013/11/13 18:28:24
SGTM
| |
| 42 DCHECK(!is_shutdown_); | |
| 43 return in_waiting_version_; | |
| 44 } | |
| 45 | |
| 46 void set_active_version(scoped_refptr<ServiceWorkerVersion> version) { | |
|
michaeln
2013/11/13 01:53:24
Does ServiceWorkerVersion* work as a parameter her
alecflett
2013/11/13 18:28:24
I did however switch the setters to take a const s
| |
| 47 DCHECK(!is_shutdown_); | |
| 48 active_version_ = version; | |
| 49 } | |
| 50 | |
| 51 void set_in_waiting_version(scoped_refptr<ServiceWorkerVersion> version) { | |
| 52 DCHECK(!is_shutdown_); | |
| 53 in_waiting_version_ = version; | |
| 54 } | |
| 55 | |
| 56 // The final synchronous switchover after all events have been | |
| 57 // fired, and the old "active version" is being shut down. | |
| 58 void ActivateInWaitingVersion(); | |
| 59 | |
| 60 private: | |
| 61 virtual ~ServiceWorkerRegistration(); | |
| 62 friend class base::RefCounted<ServiceWorkerRegistration>; | |
| 63 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerRegistrationTest, Shutdown); | |
| 64 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerRegistrationTest, ActivateFirst); | |
| 65 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerRegistrationTest, ActivateInWaiting); | |
| 66 | |
| 67 bool IsShutdown() const { return is_shutdown_; } | |
|
michaeln
2013/11/13 01:53:24
why is this one not unix-hacker-style? also since
alecflett
2013/11/13 18:28:24
good point. I moved this to be public, which let m
| |
| 68 | |
| 69 const GURL& pattern_; | |
| 70 const GURL& script_url_; | |
| 71 const int64 registration_id_; | |
| 72 | |
| 73 scoped_refptr<ServiceWorkerVersion> active_version_; | |
| 74 scoped_refptr<ServiceWorkerVersion> in_waiting_version_; | |
| 75 | |
| 76 bool is_shutdown_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration); | |
| 79 }; | |
| 80 } // namespace content | |
| 81 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ | |
| OLD | NEW |