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

Side by Side Diff: content/browser/service_worker/service_worker_registration.h

Issue 413063004: Service Worker: in Unregister, wait until after the active worker no longer controls a document (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase and merge Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 } 53 }
54 54
55 ServiceWorkerVersion* waiting_version() const { 55 ServiceWorkerVersion* waiting_version() const {
56 return waiting_version_.get(); 56 return waiting_version_.get();
57 } 57 }
58 58
59 ServiceWorkerVersion* installing_version() const { 59 ServiceWorkerVersion* installing_version() const {
60 return installing_version_.get(); 60 return installing_version_.get();
61 } 61 }
62 62
63 bool is_uninstalling() const { return is_uninstalling_; }
64
63 void AddListener(Listener* listener); 65 void AddListener(Listener* listener);
64 void RemoveListener(Listener* listener); 66 void RemoveListener(Listener* listener);
65 67
66 ServiceWorkerRegistrationInfo GetInfo(); 68 ServiceWorkerRegistrationInfo GetInfo();
67 69
68 // Sets the corresposding version attribute and resets the position 70 // Sets the corresposding version attribute and resets the position
69 // (if any) left vacant (ie. by a waiting version being promoted). 71 // (if any) left vacant (ie. by a waiting version being promoted).
70 // Also notifies listeners via OnVersionAttributesChanged. 72 // Also notifies listeners via OnVersionAttributesChanged.
71 void SetActiveVersion(ServiceWorkerVersion* version); 73 void SetActiveVersion(ServiceWorkerVersion* version);
72 void SetWaitingVersion(ServiceWorkerVersion* version); 74 void SetWaitingVersion(ServiceWorkerVersion* version);
73 void SetInstallingVersion(ServiceWorkerVersion* version); 75 void SetInstallingVersion(ServiceWorkerVersion* version);
74 76
75 // If version is the installing, waiting, active version of this 77 // If version is the installing, waiting, active version of this
76 // registation, the method will reset that field to NULL, and notify 78 // registation, the method will reset that field to NULL, and notify
77 // listeners via OnVersionAttributesChanged. 79 // listeners via OnVersionAttributesChanged.
78 void UnsetVersion(ServiceWorkerVersion* version); 80 void UnsetVersion(ServiceWorkerVersion* version);
79 81
80 // Triggers the [[Activate]] algorithm when the currently active version 82 // Triggers the [[Activate]] algorithm when the currently active version
81 // has no controllees. If there are no controllees at the time the method 83 // has no controllees. If there are no controllees at the time the method
82 // is called, activation is initiated immediately. 84 // is called, activation is initiated immediately.
83 void ActivateWaitingVersionWhenReady(); 85 void ActivateWaitingVersionWhenReady();
84 86
85 bool is_deleted() const { return is_deleted_; } 87 bool is_deleted() const { return is_deleted_; }
86 void set_is_deleted() { is_deleted_ = true; } 88 void set_is_deleted() { is_deleted_ = true; }
87 89
90 // Triggers the [[ClearRegistration]] algorithm when the currently
91 // active version has no controllees. Deletes this registration
92 // from storage immediately.
93 void ClearWhenReady();
94
95 // Restores this registration in storage and cancels the pending
96 // [[ClearRegistration]] algorithm. If the algorithm was already triggered,
97 // does nothing.
98 void AbortPendingClear();
99
88 private: 100 private:
89 friend class base::RefCounted<ServiceWorkerRegistration>; 101 friend class base::RefCounted<ServiceWorkerRegistration>;
90 102
91 virtual ~ServiceWorkerRegistration(); 103 virtual ~ServiceWorkerRegistration();
92 104
93 void SetVersionInternal( 105 void SetVersionInternal(
94 ServiceWorkerVersion* version, 106 ServiceWorkerVersion* version,
95 scoped_refptr<ServiceWorkerVersion>* data_member, 107 scoped_refptr<ServiceWorkerVersion>* data_member,
96 int change_flag); 108 int change_flag);
97 void UnsetVersionInternal( 109 void UnsetVersionInternal(
98 ServiceWorkerVersion* version, 110 ServiceWorkerVersion* version,
99 ChangedVersionAttributesMask* mask); 111 ChangedVersionAttributesMask* mask);
100 112
113 bool IsListeningForNoControllees();
114 void SetShouldActivateWhenReady(bool should_activate);
115 void SetUninstalling(bool is_uninstalling);
116
101 // ServiceWorkerVersion::Listener override. 117 // ServiceWorkerVersion::Listener override.
102 virtual void OnNoControllees(ServiceWorkerVersion* version) OVERRIDE; 118 virtual void OnNoControllees(ServiceWorkerVersion* version) OVERRIDE;
103 119
120 // This method corresponds to the [[ClearRegistration]] algorithm.
121 void Clear();
122
104 // This method corresponds to the [[Activate]] algorithm. 123 // This method corresponds to the [[Activate]] algorithm.
105 void ActivateWaitingVersion(); 124 void ActivateWaitingVersion();
106 void OnActivateEventFinished( 125 void OnActivateEventFinished(
107 ServiceWorkerVersion* activating_version, 126 ServiceWorkerVersion* activating_version,
108 ServiceWorkerStatusCode status); 127 ServiceWorkerStatusCode status);
109 void ResetShouldActivateWhenReady(); 128 void ResetShouldActivateWhenReady();
110 void OnDeleteFinished(ServiceWorkerStatusCode status); 129 void OnDeleteFinished(ServiceWorkerStatusCode status);
111 130
112 const GURL pattern_; 131 const GURL pattern_;
113 const GURL script_url_; 132 const GURL script_url_;
114 const int64 registration_id_; 133 const int64 registration_id_;
115 bool is_deleted_; 134 bool is_deleted_;
135 bool is_uninstalling_;
116 bool should_activate_when_ready_; 136 bool should_activate_when_ready_;
117 scoped_refptr<ServiceWorkerVersion> active_version_; 137 scoped_refptr<ServiceWorkerVersion> active_version_;
118 scoped_refptr<ServiceWorkerVersion> waiting_version_; 138 scoped_refptr<ServiceWorkerVersion> waiting_version_;
119 scoped_refptr<ServiceWorkerVersion> installing_version_; 139 scoped_refptr<ServiceWorkerVersion> installing_version_;
120 ObserverList<Listener> listeners_; 140 ObserverList<Listener> listeners_;
121 base::WeakPtr<ServiceWorkerContextCore> context_; 141 base::WeakPtr<ServiceWorkerContextCore> context_;
122 142
123 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration); 143 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration);
124 }; 144 };
145
125 } // namespace content 146 } // namespace content
147
126 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ 148 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698