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

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

Issue 70683002: Stub out ServiceWorkerRegistration and Version classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switch all parameters to raw pointers 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_version.h
diff --git a/content/browser/service_worker/service_worker_version.h b/content/browser/service_worker/service_worker_version.h
new file mode 100644
index 0000000000000000000000000000000000000000..41b33ed55cf7defd9fba1696e08bc972bcc8e3fb
--- /dev/null
+++ b/content/browser/service_worker/service_worker_version.h
@@ -0,0 +1,69 @@
+// 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_VERSION_H_
+#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
+
+#include "base/basictypes.h"
+#include "base/gtest_prod_util.h"
+#include "base/memory/ref_counted.h"
+#include "content/common/content_export.h"
+
+class GURL;
+
+namespace content {
+
+class ServiceWorkerRegistration;
+
+// This class corresponds to a specific version of a ServiceWorker
+// script for a given pattern. When a script is upgraded, there may be
+// more than one ServiceWorkerVersion "running" at a time, but only
+// one of them is active. This class connects the actual script with a
+// running worker.
+// Instances of this class are in one of two install states:
+// - Pending: The script is in the process of being installed. There
+// may be another active script running.
+// - Active: The script is the only worker handling requests for the
+// registration's pattern.
+//
+// In addition, a version has a running state (this is a rough
+// sketch). Since a service worker can be stopped and started at any
+// time, it will transition among these states multiple times during
+// its lifetime.
+// - Stopped: The script is not running
+// - Starting: A request to fire an event against the version has been
+// queued, but the worker is not yet
+// loaded/initialized/etc.
+// - Started: The worker is ready to receive events
+// - Stopping: The worker is returning to the stopped state.
+//
+// The worker can "run" in both the Pending and the Active
+// install states above. During the Pending state, the worker is only
+// started in order to fire the 'install' and 'activate'
+// events. During the Active state, it can receive other events such
+// as 'fetch'.
+//
+// And finally, is_shutdown_ is detects the live-ness of the object
+// itself. If the object is shut down, then it is in the process of
+// being deleted from memory. This happens when a version is replaced
+// as well as at browser shutdown.
+class CONTENT_EXPORT ServiceWorkerVersion
kinuko 2013/11/18 02:18:24 nit: Do we really need to export all these classes
alecflett 2013/11/18 17:50:08 Yep, in order to write unit tests..I feel like CON
+ : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerVersion>) {
+ public:
+ explicit ServiceWorkerVersion(ServiceWorkerRegistration* registration);
+
+ void Shutdown();
+ bool is_shutdown() const { return is_shutdown_; }
+
+ private:
+ ~ServiceWorkerVersion();
+ friend class base::RefCounted<ServiceWorkerVersion>;
kinuko 2013/11/18 02:18:24 style-nit: can you move this line right after priv
alecflett 2013/11/18 17:50:08 Sure, I'll take care of this in the next patch, ho
+
+ bool is_shutdown_;
+ scoped_refptr<ServiceWorkerRegistration> registration_;
+
+ DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
+};
+} // namespace content
+#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_

Powered by Google App Engine
This is Rietveld 408576698