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 |
index de1f0617e0c2bc44ce1dc16e2eba78ecc2458d09..dfca0f0ac4181346f65c1c055276bc3340f34a9d 100644 |
--- a/content/browser/service_worker/service_worker_registration.h |
+++ b/content/browser/service_worker/service_worker_registration.h |
@@ -20,22 +20,15 @@ namespace content { |
class ServiceWorkerRegistrationInfo; |
class ServiceWorkerVersion; |
-// This class manages all persistence of service workers: |
-// - Registrations |
-// - Mapping of caches to registrations / versions |
-// |
-// This is the place where we manage simultaneous |
-// requests for the same registrations and caches, making sure that |
-// two pages that are registering the same pattern at the same time |
-// have their registrations coalesced rather than overwriting each |
-// other. |
-// |
-// This class also manages the state of the upgrade process, which |
-// includes managing which ServiceWorkerVersion is "active" vs "in |
-// waiting". |
+// This class represents a service worker regiratration. The |
falken
2014/07/18 05:13:25
"registration" (and other comments from the previo
michaeln
2014/07/18 19:19:24
thnx for pointing them out, please continue to do
|
+// scope and script url are constant for the life of the persistent |
+// registration. It's refcounted to facillitate multiple controllees |
+// being associated with the same registration. The class roughly |
+// corresponds to navigator.serviceWorker.registgration. |
class CONTENT_EXPORT ServiceWorkerRegistration |
: NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerRegistration>) { |
public: |
+ typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback; |
class Listener { |
public: |
@@ -71,8 +64,8 @@ class CONTENT_EXPORT ServiceWorkerRegistration |
ServiceWorkerRegistrationInfo GetInfo(); |
- // Sets the corresposding version attribute and resets the position (if any) |
- // left vacant (ie. by a waiting version being promoted). |
+ // Sets the corresposding version attribute and resets the position |
+ // (if any) left vacant (ie. by a waiting version being promoted). |
// Also notifies listeners via OnVersionAttributesChanged. |
void SetActiveVersion(ServiceWorkerVersion* version); |
void SetWaitingVersion(ServiceWorkerVersion* version); |
@@ -83,6 +76,11 @@ class CONTENT_EXPORT ServiceWorkerRegistration |
// listeners via OnVersionAttributesChanged. |
void UnsetVersion(ServiceWorkerVersion* version); |
+ // This method corresponds to the [[Activate]] algorithm described in |
+ // the service worker specification. It's only valid to call this method |
+ // when the registration's active version has no controllees. |
+ void ActivateWaitingVersion(const StatusCallback& completion_callback); |
+ |
private: |
~ServiceWorkerRegistration(); |
friend class base::RefCounted<ServiceWorkerRegistration>; |
@@ -94,6 +92,10 @@ class CONTENT_EXPORT ServiceWorkerRegistration |
void UnsetVersionInternal( |
ServiceWorkerVersion* version, |
ChangedVersionAttributesMask* mask); |
+ void OnActivateEventFinished( |
+ ServiceWorkerVersion* activating_version, |
+ const StatusCallback& completion_callback, |
+ ServiceWorkerStatusCode status); |
const GURL pattern_; |
const GURL script_url_; |