Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(861)

Unified Diff: content/browser/service_worker/service_worker_registration.h

Issue 70683002: Stub out ServiceWorkerRegistration and Version classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_registration.h
diff --git a/content/browser/service_worker/service_worker_registration.h b/content/browser/service_worker/service_worker_registration.h
new file mode 100644
index 0000000000000000000000000000000000000000..d25195bfbcde331052cd654af460ea7e37fb3e9b
--- /dev/null
+++ b/content/browser/service_worker/service_worker_registration.h
@@ -0,0 +1,81 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_
+#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_
+
+#include "base/basictypes.h"
+#include "base/gtest_prod_util.h"
+#include "base/logging.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/browser/service_worker/service_worker_version.h"
+#include "content/common/content_export.h"
+
+class GURL;
+
+namespace content {
+
+class ServiceWorkerVersion;
+
+// This class acts as a persistent instance
michaeln 2013/11/13 01:53:24 This class comment and the other could use some wo
+class CONTENT_EXPORT ServiceWorkerRegistration
+ : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerRegistration>) {
+ public:
+ ServiceWorkerRegistration(const GURL& pattern,
+ const GURL& script_url,
+ int64 registration_id);
+
+ 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.
+
+ void Shutdown();
+
+ const GURL& script_url() const { return script_url_; }
+
+ scoped_refptr<ServiceWorkerVersion> active_version() const {
+ 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
+ return active_version_.get();
+ }
+
+ 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
+ DCHECK(!is_shutdown_);
+ return in_waiting_version_;
+ }
+
+ 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
+ DCHECK(!is_shutdown_);
+ active_version_ = version;
+ }
+
+ void set_in_waiting_version(scoped_refptr<ServiceWorkerVersion> version) {
+ DCHECK(!is_shutdown_);
+ in_waiting_version_ = version;
+ }
+
+ // The final synchronous switchover after all events have been
+ // fired, and the old "active version" is being shut down.
+ void ActivateInWaitingVersion();
+
+ private:
+ virtual ~ServiceWorkerRegistration();
+ friend class base::RefCounted<ServiceWorkerRegistration>;
+ FRIEND_TEST_ALL_PREFIXES(ServiceWorkerRegistrationTest, Shutdown);
+ FRIEND_TEST_ALL_PREFIXES(ServiceWorkerRegistrationTest, ActivateFirst);
+ FRIEND_TEST_ALL_PREFIXES(ServiceWorkerRegistrationTest, ActivateInWaiting);
+
+ 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
+
+ const GURL& pattern_;
+ const GURL& script_url_;
+ const int64 registration_id_;
+
+ scoped_refptr<ServiceWorkerVersion> active_version_;
+ scoped_refptr<ServiceWorkerVersion> in_waiting_version_;
+
+ bool is_shutdown_;
+
+ DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration);
+};
+} // namespace content
+#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_

Powered by Google App Engine
This is Rietveld 408576698