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

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

Issue 188283003: Add ServiceWorkerVersion::status() (which is to be persisted unlike running status) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 months 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
index c577ac30c2c0d0271cbf83359a3df49a1da8888a..e9065d261dd6a6f9fd87f97895fc8bdee4c6c27c 100644
--- a/content/browser/service_worker/service_worker_version.h
+++ b/content/browser/service_worker/service_worker_version.h
@@ -69,27 +69,41 @@ class CONTENT_EXPORT ServiceWorkerVersion
const ServiceWorkerFetchResponse& response)>
FetchCallback;
- enum Status {
+ enum RunningStatus {
STOPPED = EmbeddedWorkerInstance::STOPPED,
STARTING = EmbeddedWorkerInstance::STARTING,
RUNNING = EmbeddedWorkerInstance::RUNNING,
STOPPING = EmbeddedWorkerInstance::STOPPING,
};
+ // Current version status; this status should be persisted unlike
+ // running status. Note that this class doesn't change status on its own,
+ // consumers of this class should explicitly set a new status by
+ // set_status().
+ enum Status {
+ NEW, // Just created but installation is not finished.
+ WAITING, // Installation is finished and is ready to be activated.
+ ACTIVE, // Activation is finished and can run as active.
michaeln 2014/03/06 19:49:54 Is there a state following ACTIVE to represent the
+ };
+
ServiceWorkerVersion(
ServiceWorkerRegistration* registration,
EmbeddedWorkerRegistry* worker_registry,
- int64 version_id);
+ int64 version_id,
+ Status status);
int64 version_id() const { return version_id_; }
void Shutdown();
bool is_shutdown() const { return is_shutdown_; }
- Status status() const {
- return static_cast<Status>(embedded_worker_->status());
+ RunningStatus running_status() const {
+ return static_cast<RunningStatus>(embedded_worker_->status());
}
+ Status status() const { return status_; }
+ void set_status(Status status) { status_ = status; }
+
// Starts an embedded worker for this version.
// This returns OK (success) if the worker is already running.
void StartWorker(const StatusCallback& callback);
@@ -121,11 +135,15 @@ class CONTENT_EXPORT ServiceWorkerVersion
// to notify install completion.
// |active_version_embedded_worker_id| must be a valid positive ID
// if there's an active (previous) version running.
+ // Calling this while status is not NEW is not valid; will error out with
+ // SERVICE_WORKER_ERROR_FAILED.
void DispatchInstallEvent(int active_version_embedded_worker_id,
const StatusCallback& callback);
// Sends fetch event to the associated embedded worker and calls
// |callback| with the response from the worker.
+ // Calling this while status is not ACTIVE is not valid; will error out with
+ // SERVICE_WORKER_ERROR_FAILED.
void DispatchFetchEvent(const ServiceWorkerFetchRequest& request,
const FetchCallback& callback);
@@ -151,6 +169,8 @@ class CONTENT_EXPORT ServiceWorkerVersion
const int64 version_id_;
+ Status status_;
+
bool is_shutdown_;
scoped_refptr<ServiceWorkerRegistration> registration_;
scoped_ptr<EmbeddedWorkerInstance> embedded_worker_;

Powered by Google App Engine
This is Rietveld 408576698