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

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: address comments 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 ServiceWorkerRegistration(const GURL& pattern, 44 ServiceWorkerRegistration(const GURL& pattern,
45 const GURL& script_url, 45 const GURL& script_url,
46 int64 registration_id, 46 int64 registration_id,
47 base::WeakPtr<ServiceWorkerContextCore> context); 47 base::WeakPtr<ServiceWorkerContextCore> context);
48 48
49 int64 id() const { return registration_id_; } 49 int64 id() const { return registration_id_; }
50 const GURL& script_url() const { return script_url_; } 50 const GURL& script_url() const { return script_url_; }
51 const GURL& pattern() const { return pattern_; } 51 const GURL& pattern() const { return pattern_; }
52 52
53 bool is_deleted() const { return is_deleted_; }
54 void set_is_deleted(bool deleted) { is_deleted_ = deleted; }
55
56 bool is_uninstalling() const { return is_uninstalling_; }
57
53 ServiceWorkerVersion* active_version() const { 58 ServiceWorkerVersion* active_version() const {
54 return active_version_.get(); 59 return active_version_.get();
55 } 60 }
56 61
57 ServiceWorkerVersion* waiting_version() const { 62 ServiceWorkerVersion* waiting_version() const {
58 return waiting_version_.get(); 63 return waiting_version_.get();
59 } 64 }
60 65
61 ServiceWorkerVersion* installing_version() const { 66 ServiceWorkerVersion* installing_version() const {
62 return installing_version_.get(); 67 return installing_version_.get();
(...skipping 15 matching lines...) Expand all
78 // If version is the installing, waiting, active version of this 83 // If version is the installing, waiting, active version of this
79 // registation, the method will reset that field to NULL, and notify 84 // registation, the method will reset that field to NULL, and notify
80 // listeners via OnVersionAttributesChanged. 85 // listeners via OnVersionAttributesChanged.
81 void UnsetVersion(ServiceWorkerVersion* version); 86 void UnsetVersion(ServiceWorkerVersion* version);
82 87
83 // Triggers the [[Activate]] algorithm when the currently active version 88 // Triggers the [[Activate]] algorithm when the currently active version
84 // has no controllees. If there are no controllees at the time the method 89 // has no controllees. If there are no controllees at the time the method
85 // is called, activation is initiated immediately. 90 // is called, activation is initiated immediately.
86 void ActivateWaitingVersionWhenReady(); 91 void ActivateWaitingVersionWhenReady();
87 92
88 bool is_deleted() const { return is_deleted_; } 93 // Triggers the [[ClearRegistration]] algorithm when the currently
89 void set_is_deleted() { is_deleted_ = true; } 94 // active version has no controllees. Deletes this registration
95 // from storage immediately.
96 void ClearWhenReady();
97
98 // Restores this registration in storage and cancels the pending
99 // [[ClearRegistration]] algorithm. If the algorithm was already triggered,
100 // does nothing.
101 void AbortPendingClear();
90 102
91 private: 103 private:
92 friend class base::RefCounted<ServiceWorkerRegistration>; 104 friend class base::RefCounted<ServiceWorkerRegistration>;
93 105
94 virtual ~ServiceWorkerRegistration(); 106 virtual ~ServiceWorkerRegistration();
95 107
96 void SetVersionInternal( 108 void SetVersionInternal(
97 ServiceWorkerVersion* version, 109 ServiceWorkerVersion* version,
98 scoped_refptr<ServiceWorkerVersion>* data_member, 110 scoped_refptr<ServiceWorkerVersion>* data_member,
99 int change_flag); 111 int change_flag);
100 void UnsetVersionInternal( 112 void UnsetVersionInternal(
101 ServiceWorkerVersion* version, 113 ServiceWorkerVersion* version,
102 ChangedVersionAttributesMask* mask); 114 ChangedVersionAttributesMask* mask);
103 115
104 // ServiceWorkerVersion::Listener override. 116 // ServiceWorkerVersion::Listener override.
105 virtual void OnNoControllees(ServiceWorkerVersion* version) OVERRIDE; 117 virtual void OnNoControllees(ServiceWorkerVersion* version) OVERRIDE;
106 118
107 // This method corresponds to the [[Activate]] algorithm. 119 // This method corresponds to the [[Activate]] algorithm.
108 void ActivateWaitingVersion(); 120 void ActivateWaitingVersion();
109 void OnActivateEventFinished( 121 void OnActivateEventFinished(
110 ServiceWorkerVersion* activating_version, 122 ServiceWorkerVersion* activating_version,
111 ServiceWorkerStatusCode status); 123 ServiceWorkerStatusCode status);
112 void ResetShouldActivateWhenReady();
113 void OnDeleteFinished(ServiceWorkerStatusCode status); 124 void OnDeleteFinished(ServiceWorkerStatusCode status);
114 125
126 // This method corresponds to the [[ClearRegistration]] algorithm.
127 void Clear();
128 void OnStoreFinished(scoped_refptr<ServiceWorkerVersion> version,
129 ServiceWorkerStatusCode status);
130
115 const GURL pattern_; 131 const GURL pattern_;
116 const GURL script_url_; 132 const GURL script_url_;
117 const int64 registration_id_; 133 const int64 registration_id_;
118 bool is_deleted_; 134 bool is_deleted_;
135 bool is_uninstalling_;
119 bool should_activate_when_ready_; 136 bool should_activate_when_ready_;
120 scoped_refptr<ServiceWorkerVersion> active_version_; 137 scoped_refptr<ServiceWorkerVersion> active_version_;
121 scoped_refptr<ServiceWorkerVersion> waiting_version_; 138 scoped_refptr<ServiceWorkerVersion> waiting_version_;
122 scoped_refptr<ServiceWorkerVersion> installing_version_; 139 scoped_refptr<ServiceWorkerVersion> installing_version_;
123 ObserverList<Listener> listeners_; 140 ObserverList<Listener> listeners_;
124 base::WeakPtr<ServiceWorkerContextCore> context_; 141 base::WeakPtr<ServiceWorkerContextCore> context_;
125 142
126 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration); 143 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration);
127 }; 144 };
145
128 } // namespace content 146 } // namespace content
147
129 #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