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

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

Issue 62203007: Implement memory-persistent registration (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address kinuko's comments Created 7 years 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_register_job.h
diff --git a/content/browser/service_worker/service_worker_register_job.h b/content/browser/service_worker/service_worker_register_job.h
new file mode 100644
index 0000000000000000000000000000000000000000..06e0c6bd8ede79eb390508a1f0e19e15a5c57201
--- /dev/null
+++ b/content/browser/service_worker/service_worker_register_job.h
@@ -0,0 +1,78 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
kinuko 2013/12/04 13:04:29 Some files have (c) while others do not. Afaik ou
alecflett 2013/12/06 05:43:33 Whatever I check in, there's some bot that always
+// 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_REGISTER_JOB_H_
+#define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_
+
+#include "base/memory/weak_ptr.h"
+#include "content/browser/service_worker/service_worker_registration_status.h"
+#include "content/browser/service_worker/service_worker_storage.h"
+
+namespace content {
+
+// A ServiceWorkerRegisterJob lives only for the lifetime of a single
+// registration or unregistration.
+class ServiceWorkerRegisterJob {
+ public:
+ typedef base::Callback<
+ void(ServiceWorkerRegisterJob*,
+ ServiceWorkerRegistrationStatus status,
+ ServiceWorkerRegistration*)> RegistrationCompleteCallback;
+
+ // All type of jobs (Register and Unregister) complete through a
+ // single call to this callback on the IO thread.
+ ServiceWorkerRegisterJob(const base::WeakPtr<ServiceWorkerStorage>& storage,
+ const RegistrationCompleteCallback& callback);
+ ~ServiceWorkerRegisterJob();
+
+ // The Registration flow includes most or all of the following,
+ // depending on what is already registered:
+ // - creating a ServiceWorkerRegistration instance if there isn't
+ // already something registered
+ // - creating a ServiceWorkerVersion for the new registration instance.
+ // - starting a worker for the ServiceWorkerVersion
+ // - telling the Version to evaluate the script
+ // - firing the 'install' event at the ServiceWorkerVersion
+ // - firing the 'activate' event at the ServiceWorkerVersion
+ // - Waiting for older ServiceWorkerVersions to deactivate
+ // - designating the new version to be the 'active' version
+ // This method should be called once and only once per job.
kinuko 2013/12/04 13:04:29 To perform all these operations would Storage be t
alecflett 2013/12/06 05:43:33 I think as far as owning the Job class instance, i
+ void StartRegister(const GURL& pattern, const GURL& script_url);
+
+ // The Unregistration process is primarily cleanup, removing
+ // everything that was created during the Registration process,
+ // including the ServiceWorkerRegistration itself.
+ // This method should be called once and only once per job.
+ void StartUnregister(const GURL& pattern);
+
+ private:
+ // These are all steps in the registration and unregistration pipeline.
+ void RegisterPatternAndContinue(
+ const GURL& pattern,
+ const GURL& script_url,
+ const ServiceWorkerStorage::RegistrationCallback& callback,
+ ServiceWorkerRegistrationStatus previous_status);
+
+ void UnregisterPatternAndContinue(
+ const GURL& pattern,
+ const GURL& script_url,
+ const ServiceWorkerStorage::UnregistrationCallback& callback,
+ ServiceWorkerRegistrationStatus previous_status,
+ const scoped_refptr<ServiceWorkerRegistration>& previous_registration);
+
+ // These methods convert
kinuko 2013/12/04 13:04:29 incomplete sentence?
alecflett 2013/12/06 05:43:33 Done.
+ void UnregisterComplete(ServiceWorkerRegistrationStatus status);
+ void RegisterComplete(
+ ServiceWorkerRegistrationStatus status,
+ const scoped_refptr<ServiceWorkerRegistration>& registration);
+
+ const base::WeakPtr<ServiceWorkerStorage> storage_;
+ const RegistrationCompleteCallback callback_;
+ base::WeakPtrFactory<ServiceWorkerRegisterJob> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegisterJob);
+};
+} // namespace content
+
+#endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTER_JOB_H_

Powered by Google App Engine
This is Rietveld 408576698