OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ | 5 #ifndef CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ |
6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ | 6 #define CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/callback_forward.h" | 13 #include "base/callback_forward.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/scoped_vector.h" |
15 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
16 #include "content/browser/background_sync/background_sync.pb.h" | 17 #include "content/browser/background_sync/background_sync.pb.h" |
17 #include "content/browser/background_sync/background_sync_registration.h" | 18 #include "content/browser/background_sync/background_sync_registration.h" |
| 19 #include "content/browser/background_sync/background_sync_registration_handle.h" |
18 #include "content/browser/background_sync/background_sync_status.h" | 20 #include "content/browser/background_sync/background_sync_status.h" |
19 #include "content/browser/cache_storage/cache_storage_scheduler.h" | 21 #include "content/browser/cache_storage/cache_storage_scheduler.h" |
20 #include "content/browser/service_worker/service_worker_context_observer.h" | 22 #include "content/browser/service_worker/service_worker_context_observer.h" |
21 #include "content/browser/service_worker/service_worker_storage.h" | 23 #include "content/browser/service_worker/service_worker_storage.h" |
22 #include "content/common/content_export.h" | 24 #include "content/common/content_export.h" |
23 #include "content/common/service_worker/service_worker_status_code.h" | 25 #include "content/common/service_worker/service_worker_status_code.h" |
24 #include "url/gurl.h" | 26 #include "url/gurl.h" |
25 | 27 |
26 namespace content { | 28 namespace content { |
27 | 29 |
(...skipping 15 matching lines...) Expand all Loading... |
43 // TODO(jkarlin): Create a background sync scheduler to actually run the | 45 // TODO(jkarlin): Create a background sync scheduler to actually run the |
44 // registered events. | 46 // registered events. |
45 // TODO(jkarlin): Keep the browser alive if "Let Google Chrome Run in the | 47 // TODO(jkarlin): Keep the browser alive if "Let Google Chrome Run in the |
46 // Background" is true and a sync is registered. | 48 // Background" is true and a sync is registered. |
47 class CONTENT_EXPORT BackgroundSyncManager | 49 class CONTENT_EXPORT BackgroundSyncManager |
48 : NON_EXPORTED_BASE(public ServiceWorkerContextObserver) { | 50 : NON_EXPORTED_BASE(public ServiceWorkerContextObserver) { |
49 public: | 51 public: |
50 using StatusCallback = base::Callback<void(BackgroundSyncStatus)>; | 52 using StatusCallback = base::Callback<void(BackgroundSyncStatus)>; |
51 using StatusAndRegistrationCallback = | 53 using StatusAndRegistrationCallback = |
52 base::Callback<void(BackgroundSyncStatus, | 54 base::Callback<void(BackgroundSyncStatus, |
53 const BackgroundSyncRegistration&)>; | 55 scoped_ptr<BackgroundSyncRegistrationHandle>)>; |
54 using StatusAndRegistrationsCallback = | 56 using StatusAndRegistrationsCallback = base::Callback<void( |
55 base::Callback<void(BackgroundSyncStatus, | 57 BackgroundSyncStatus, |
56 const std::vector<BackgroundSyncRegistration>&)>; | 58 scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>>)>; |
57 | 59 |
58 static scoped_ptr<BackgroundSyncManager> Create( | 60 static scoped_ptr<BackgroundSyncManager> Create( |
59 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context); | 61 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context); |
60 ~BackgroundSyncManager() override; | 62 ~BackgroundSyncManager() override; |
61 | 63 |
62 // Stores the given background sync registration and adds it to the scheduling | 64 // Stores the given background sync registration and adds it to the scheduling |
63 // queue. It will overwrite an existing registration with the same tag and | 65 // queue. It will overwrite an existing registration with the same tag and |
64 // periodicity unless they're identical (save for the id). Calls |callback| | 66 // periodicity unless they're identical (save for the id). Calls |callback| |
65 // with BACKGROUND_SYNC_STATUS_OK and the accepted registration on success. | 67 // with BACKGROUND_SYNC_STATUS_OK and the accepted registration on success. |
66 // The accepted registration will have a unique id. It may also have altered | 68 // The accepted registration will have a unique id. It may also have altered |
67 // parameters if the user or UA chose different parameters than those | 69 // parameters if the user or UA chose different parameters than those |
68 // supplied. | 70 // supplied. |
69 void Register(int64 sw_registration_id, | 71 void Register(int64 sw_registration_id, |
70 const BackgroundSyncRegistrationOptions& options, | 72 const BackgroundSyncRegistrationOptions& options, |
71 bool requested_from_service_worker, | 73 bool requested_from_service_worker, |
72 const StatusAndRegistrationCallback& callback); | 74 const StatusAndRegistrationCallback& callback); |
73 | 75 |
74 // Removes the background sync with tag |sync_registration_tag|, periodicity | |
75 // |periodicity|, and id |sync_registration_id|. Calls |callback| with | |
76 // BACKGROUND_SYNC_STATUS_NOT_FOUND if no match is found. Calls |callback| | |
77 // with BACKGROUND_SYNC_STATUS_OK on success. | |
78 void Unregister( | |
79 int64 sw_registration_id, | |
80 const std::string& sync_registration_tag, | |
81 SyncPeriodicity periodicity, | |
82 BackgroundSyncRegistration::RegistrationId sync_registration_id, | |
83 const StatusCallback& callback); | |
84 | |
85 // Finds the background sync registration associated with | 76 // Finds the background sync registration associated with |
86 // |sw_registration_id| with periodicity |periodicity|. Calls | 77 // |sw_registration_id| with periodicity |periodicity|. Calls |
87 // |callback| with BACKGROUND_SYNC_STATUS_NOT_FOUND if it doesn't exist. Calls | 78 // |callback| with BACKGROUND_SYNC_STATUS_NOT_FOUND if it doesn't exist. Calls |
88 // |callback| with BACKGROUND_SYNC_STATUS_OK on success. | 79 // |callback| with BACKGROUND_SYNC_STATUS_OK on success. |
89 void GetRegistration(int64 sw_registration_id, | 80 void GetRegistration(int64 sw_registration_id, |
90 const std::string& sync_registration_tag, | 81 const std::string& sync_registration_tag, |
91 SyncPeriodicity periodicity, | 82 SyncPeriodicity periodicity, |
92 const StatusAndRegistrationCallback& callback); | 83 const StatusAndRegistrationCallback& callback); |
93 | 84 |
94 void GetRegistrations(int64 sw_registration_id, | 85 void GetRegistrations(int64 sw_registration_id, |
95 SyncPeriodicity periodicity, | 86 SyncPeriodicity periodicity, |
96 const StatusAndRegistrationsCallback& callback); | 87 const StatusAndRegistrationsCallback& callback); |
97 | 88 |
| 89 // Given a HandleId |handle_id|, return a new handle for the same |
| 90 // registration. |
| 91 scoped_ptr<BackgroundSyncRegistrationHandle> DuplicateRegistrationHandle( |
| 92 BackgroundSyncRegistrationHandle::HandleId handle_id); |
| 93 |
98 // ServiceWorkerContextObserver overrides. | 94 // ServiceWorkerContextObserver overrides. |
99 void OnRegistrationDeleted(int64 registration_id, | 95 void OnRegistrationDeleted(int64 registration_id, |
100 const GURL& pattern) override; | 96 const GURL& pattern) override; |
101 void OnStorageWiped() override; | 97 void OnStorageWiped() override; |
102 | 98 |
103 protected: | 99 protected: |
| 100 // A registration might be referenced by the client longer than |
| 101 // the BackgroundSyncManager needs to keep track of it (e.g., the event has |
| 102 // finished firing). The BackgroundSyncManager reference counts its |
| 103 // registrations internally and every BackgroundSyncRegistrationHandle has a |
| 104 // unique handle id which maps to a locally maintained (in |
| 105 // client_registration_ids_) scoped_refptr. |
| 106 class RefCountedRegistration; |
| 107 |
104 explicit BackgroundSyncManager( | 108 explicit BackgroundSyncManager( |
105 const scoped_refptr<ServiceWorkerContextWrapper>& context); | 109 const scoped_refptr<ServiceWorkerContextWrapper>& context); |
106 | 110 |
107 // Init must be called before any public member function. Only call it once. | 111 // Init must be called before any public member function. Only call it once. |
108 void Init(); | 112 void Init(); |
109 | 113 |
110 // The following methods are virtual for testing. | 114 // The following methods are virtual for testing. |
111 virtual void StoreDataInBackend( | 115 virtual void StoreDataInBackend( |
112 int64 sw_registration_id, | 116 int64 sw_registration_id, |
113 const GURL& origin, | 117 const GURL& origin, |
114 const std::string& backend_key, | 118 const std::string& backend_key, |
115 const std::string& data, | 119 const std::string& data, |
116 const ServiceWorkerStorage::StatusCallback& callback); | 120 const ServiceWorkerStorage::StatusCallback& callback); |
117 virtual void GetDataFromBackend( | 121 virtual void GetDataFromBackend( |
118 const std::string& backend_key, | 122 const std::string& backend_key, |
119 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& | 123 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& |
120 callback); | 124 callback); |
121 virtual void FireOneShotSync( | 125 virtual void FireOneShotSync( |
122 const BackgroundSyncRegistration& registration, | 126 BackgroundSyncRegistrationHandle::HandleId handle_id, |
123 const scoped_refptr<ServiceWorkerVersion>& active_version, | 127 const scoped_refptr<ServiceWorkerVersion>& active_version, |
124 const ServiceWorkerVersion::StatusCallback& callback); | 128 const ServiceWorkerVersion::StatusCallback& callback); |
125 | 129 |
126 private: | 130 private: |
| 131 friend class BackgroundSyncRegistrationHandle; |
| 132 |
127 class RegistrationKey { | 133 class RegistrationKey { |
128 public: | 134 public: |
129 explicit RegistrationKey(const BackgroundSyncRegistration& registration); | 135 explicit RegistrationKey(const BackgroundSyncRegistration& registration); |
130 explicit RegistrationKey(const BackgroundSyncRegistrationOptions& options); | 136 explicit RegistrationKey(const BackgroundSyncRegistrationOptions& options); |
131 RegistrationKey(const std::string& tag, SyncPeriodicity periodicity); | 137 RegistrationKey(const std::string& tag, SyncPeriodicity periodicity); |
132 RegistrationKey(const RegistrationKey& other) = default; | 138 RegistrationKey(const RegistrationKey& other) = default; |
133 RegistrationKey& operator=(const RegistrationKey& other) = default; | 139 RegistrationKey& operator=(const RegistrationKey& other) = default; |
134 | 140 |
135 bool operator<(const RegistrationKey& rhs) const { | 141 bool operator<(const RegistrationKey& rhs) const { |
136 return value_ < rhs.value_; | 142 return value_ < rhs.value_; |
137 } | 143 } |
138 | 144 |
139 private: | 145 private: |
140 std::string value_; | 146 std::string value_; |
141 }; | 147 }; |
142 | 148 |
143 struct BackgroundSyncRegistrations { | 149 struct BackgroundSyncRegistrations { |
144 using RegistrationMap = | 150 using RegistrationMap = |
145 std::map<RegistrationKey, BackgroundSyncRegistration>; | 151 std::map<RegistrationKey, scoped_refptr<RefCountedRegistration>>; |
146 | 152 |
147 BackgroundSyncRegistrations(); | 153 BackgroundSyncRegistrations(); |
148 ~BackgroundSyncRegistrations(); | 154 ~BackgroundSyncRegistrations(); |
149 | 155 |
150 RegistrationMap registration_map; | 156 RegistrationMap registration_map; |
151 BackgroundSyncRegistration::RegistrationId next_id; | 157 BackgroundSyncRegistration::RegistrationId next_id; |
152 GURL origin; | 158 GURL origin; |
153 }; | 159 }; |
154 | 160 |
155 using PermissionStatusCallback = base::Callback<void(bool)>; | 161 using PermissionStatusCallback = base::Callback<void(bool)>; |
156 using SWIdToRegistrationsMap = std::map<int64, BackgroundSyncRegistrations>; | 162 using SWIdToRegistrationsMap = std::map<int64, BackgroundSyncRegistrations>; |
157 | 163 |
| 164 scoped_ptr<BackgroundSyncRegistrationHandle> CreateRegistrationHandle( |
| 165 const scoped_refptr<RefCountedRegistration>& registration); |
| 166 |
| 167 // Returns the BackgroundSyncRegistration corresponding to |handle_id|. |
| 168 // Returns nullptr if the registration is not found. |
| 169 BackgroundSyncRegistration* GetRegistrationForHandle( |
| 170 BackgroundSyncRegistrationHandle::HandleId handle_id) const; |
| 171 |
| 172 // The BackgroundSyncManager holds references to registrations that have |
| 173 // active Handles. The handles must call this on destruction. |
| 174 void ReleaseRegistrationHandle( |
| 175 BackgroundSyncRegistrationHandle::HandleId handle_id); |
| 176 |
158 // Disable the manager. Already queued operations will abort once they start | 177 // Disable the manager. Already queued operations will abort once they start |
159 // to run (in their impl methods). Future operations will not queue. Any | 178 // to run (in their impl methods). Future operations will not queue. Any |
160 // registrations are cleared from memory and the backend (if it's still | 179 // registrations are cleared from memory and the backend (if it's still |
161 // functioning). The manager will reenable itself once it receives the | 180 // functioning). The manager will reenable itself once it receives the |
162 // OnStorageWiped message or on browser restart. | 181 // OnStorageWiped message or on browser restart. |
163 void DisableAndClearManager(const base::Closure& callback); | 182 void DisableAndClearManager(const base::Closure& callback); |
164 void DisableAndClearDidGetRegistrations( | 183 void DisableAndClearDidGetRegistrations( |
165 const base::Closure& callback, | 184 const base::Closure& callback, |
166 const std::vector<std::pair<int64, std::string>>& user_data, | 185 const std::vector<std::pair<int64, std::string>>& user_data, |
167 ServiceWorkerStatusCode status); | 186 ServiceWorkerStatusCode status); |
168 void DisableAndClearManagerClearedOne(const base::Closure& barrier_closure, | 187 void DisableAndClearManagerClearedOne(const base::Closure& barrier_closure, |
169 ServiceWorkerStatusCode status); | 188 ServiceWorkerStatusCode status); |
170 | 189 |
171 // Returns the existing registration in |existing_registration| if it is not | 190 // Returns the existing registration or nullptr if it cannot be found. |
172 // null. | 191 RefCountedRegistration* LookupActiveRegistration( |
173 BackgroundSyncRegistration* LookupRegistration( | |
174 int64 sw_registration_id, | 192 int64 sw_registration_id, |
175 const RegistrationKey& registration_key); | 193 const RegistrationKey& registration_key); |
176 | 194 |
177 // Store all registrations for a given |sw_registration_id|. | 195 // Write all registrations for a given |sw_registration_id| to persistent |
| 196 // storage. |
178 void StoreRegistrations(int64 sw_registration_id, | 197 void StoreRegistrations(int64 sw_registration_id, |
179 const ServiceWorkerStorage::StatusCallback& callback); | 198 const ServiceWorkerStorage::StatusCallback& callback); |
180 | 199 |
181 // Removes the registration if it is in the map. | 200 // Removes the active registration if it is in the map. |
182 void RemoveRegistrationFromMap(int64 sw_registration_id, | 201 void RemoveActiveRegistration(int64 sw_registration_id, |
183 const RegistrationKey& registration_key); | 202 const RegistrationKey& registration_key); |
184 | 203 |
185 void AddRegistrationToMap( | 204 void AddActiveRegistration( |
186 int64 sw_registration_id, | 205 int64 sw_registration_id, |
187 const GURL& origin, | 206 const GURL& origin, |
188 const BackgroundSyncRegistration& sync_registration); | 207 const scoped_refptr<RefCountedRegistration>& sync_registration); |
189 | 208 |
190 void InitImpl(const base::Closure& callback); | 209 void InitImpl(const base::Closure& callback); |
191 void InitDidGetDataFromBackend( | 210 void InitDidGetDataFromBackend( |
192 const base::Closure& callback, | 211 const base::Closure& callback, |
193 const std::vector<std::pair<int64, std::string>>& user_data, | 212 const std::vector<std::pair<int64, std::string>>& user_data, |
194 ServiceWorkerStatusCode status); | 213 ServiceWorkerStatusCode status); |
195 | 214 |
196 // Register callbacks | 215 // Register callbacks |
197 void RegisterImpl(int64 sw_registration_id, | 216 void RegisterImpl(int64 sw_registration_id, |
198 const BackgroundSyncRegistrationOptions& options, | 217 const BackgroundSyncRegistrationOptions& options, |
199 bool requested_from_service_worker, | 218 bool requested_from_service_worker, |
200 const StatusAndRegistrationCallback& callback); | 219 const StatusAndRegistrationCallback& callback); |
201 void RegisterDidStore(int64 sw_registration_id, | 220 void RegisterDidStore( |
202 const BackgroundSyncRegistration& sync_registration, | 221 int64 sw_registration_id, |
203 const StatusAndRegistrationCallback& callback, | 222 const scoped_refptr<RefCountedRegistration>& new_registration_ref, |
204 ServiceWorkerStatusCode status); | 223 const StatusAndRegistrationCallback& callback, |
| 224 ServiceWorkerStatusCode status); |
205 | 225 |
206 // Unregister callbacks | 226 // Removes the background sync with periodicity |periodicity| and id |
| 227 // |sync_registration_id|. Calls |callback| with |
| 228 // BACKGROUND_SYNC_STATUS_NOT_FOUND if no match is found. Calls |callback| |
| 229 // with BACKGROUND_SYNC_STATUS_OK on success. |
| 230 void Unregister(int64 sw_registration_id, |
| 231 SyncPeriodicity periodicity, |
| 232 BackgroundSyncRegistrationHandle::HandleId handle_id, |
| 233 const StatusCallback& callback); |
207 void UnregisterImpl( | 234 void UnregisterImpl( |
208 int64 sw_registration_id, | 235 int64 sw_registration_id, |
209 const RegistrationKey& registration_key, | 236 const RegistrationKey& key, |
210 BackgroundSyncRegistration::RegistrationId sync_registration_id, | 237 BackgroundSyncRegistration::RegistrationId sync_registration_id, |
211 SyncPeriodicity periodicity, | 238 SyncPeriodicity periodicity, |
212 const StatusCallback& callback); | 239 const StatusCallback& callback); |
213 void UnregisterDidStore(int64 sw_registration_id, | 240 void UnregisterDidStore(int64 sw_registration_id, |
214 SyncPeriodicity periodicity, | 241 SyncPeriodicity periodicity, |
215 const StatusCallback& callback, | 242 const StatusCallback& callback, |
216 ServiceWorkerStatusCode status); | 243 ServiceWorkerStatusCode status); |
217 | 244 |
218 // GetRegistration callbacks | 245 // GetRegistration callbacks |
219 void GetRegistrationImpl(int64 sw_registration_id, | 246 void GetRegistrationImpl(int64 sw_registration_id, |
(...skipping 25 matching lines...) Expand all Loading... |
245 const base::Closure& event_completed_callback, | 272 const base::Closure& event_completed_callback, |
246 ServiceWorkerStatusCode service_worker_status, | 273 ServiceWorkerStatusCode service_worker_status, |
247 const scoped_refptr<ServiceWorkerRegistration>& | 274 const scoped_refptr<ServiceWorkerRegistration>& |
248 service_worker_registration); | 275 service_worker_registration); |
249 | 276 |
250 // Called when a sync event has completed. | 277 // Called when a sync event has completed. |
251 void EventComplete( | 278 void EventComplete( |
252 const scoped_refptr<ServiceWorkerRegistration>& | 279 const scoped_refptr<ServiceWorkerRegistration>& |
253 service_worker_registration, | 280 service_worker_registration, |
254 int64 service_worker_id, | 281 int64 service_worker_id, |
255 const RegistrationKey& key, | 282 scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle, |
256 BackgroundSyncRegistration::RegistrationId sync_registration_id, | |
257 const base::Closure& callback, | 283 const base::Closure& callback, |
258 ServiceWorkerStatusCode status_code); | 284 ServiceWorkerStatusCode status_code); |
259 void EventCompleteImpl( | 285 void EventCompleteImpl( |
260 int64 service_worker_id, | 286 int64 service_worker_id, |
261 const RegistrationKey& key, | 287 scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle, |
262 BackgroundSyncRegistration::RegistrationId sync_registration_id, | |
263 ServiceWorkerStatusCode status_code, | 288 ServiceWorkerStatusCode status_code, |
264 const base::Closure& callback); | 289 const base::Closure& callback); |
265 void EventCompleteDidStore(int64 service_worker_id, | 290 void EventCompleteDidStore(int64 service_worker_id, |
266 const base::Closure& callback, | 291 const base::Closure& callback, |
267 ServiceWorkerStatusCode status_code); | 292 ServiceWorkerStatusCode status_code); |
268 | 293 |
269 // Called when all sync events have completed. | 294 // Called when all sync events have completed. |
270 static void OnAllSyncEventsCompleted(const base::TimeTicks& start_time, | 295 static void OnAllSyncEventsCompleted(const base::TimeTicks& start_time, |
271 int number_of_batched_sync_events); | 296 int number_of_batched_sync_events); |
272 | 297 |
273 // OnRegistrationDeleted callbacks | 298 // OnRegistrationDeleted callbacks |
274 void OnRegistrationDeletedImpl(int64 registration_id, | 299 void OnRegistrationDeletedImpl(int64 registration_id, |
275 const base::Closure& callback); | 300 const base::Closure& callback); |
276 | 301 |
277 // OnStorageWiped callbacks | 302 // OnStorageWiped callbacks |
278 void OnStorageWipedImpl(const base::Closure& callback); | 303 void OnStorageWipedImpl(const base::Closure& callback); |
279 | 304 |
280 void OnNetworkChanged(); | 305 void OnNetworkChanged(); |
281 void OnPowerChanged(); | 306 void OnPowerChanged(); |
282 | 307 |
283 // Operation Scheduling callback and convenience functions. | 308 // Operation Scheduling callback and convenience functions. |
284 template <typename CallbackT, typename... Params> | 309 template <typename CallbackT, typename... Params> |
285 void CompleteOperationCallback(const CallbackT& callback, | 310 void CompleteOperationCallback(const CallbackT& callback, |
286 Params... parameters); | 311 Params... parameters); |
| 312 void CompleteStatusAndRegistrationCallback( |
| 313 StatusAndRegistrationCallback callback, |
| 314 BackgroundSyncStatus status, |
| 315 scoped_ptr<BackgroundSyncRegistrationHandle> result); |
| 316 void CompleteStatusAndRegistrationsCallback( |
| 317 StatusAndRegistrationsCallback callback, |
| 318 BackgroundSyncStatus status, |
| 319 scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>> results); |
287 base::Closure MakeEmptyCompletion(); | 320 base::Closure MakeEmptyCompletion(); |
288 base::Closure MakeClosureCompletion(const base::Closure& callback); | 321 base::Closure MakeClosureCompletion(const base::Closure& callback); |
289 StatusAndRegistrationCallback MakeStatusAndRegistrationCompletion( | 322 StatusAndRegistrationCallback MakeStatusAndRegistrationCompletion( |
290 const StatusAndRegistrationCallback& callback); | 323 const StatusAndRegistrationCallback& callback); |
291 StatusAndRegistrationsCallback MakeStatusAndRegistrationsCompletion( | 324 StatusAndRegistrationsCallback MakeStatusAndRegistrationsCompletion( |
292 const StatusAndRegistrationsCallback& callback); | 325 const StatusAndRegistrationsCallback& callback); |
293 BackgroundSyncManager::StatusCallback MakeStatusCompletion( | 326 BackgroundSyncManager::StatusCallback MakeStatusCompletion( |
294 const StatusCallback& callback); | 327 const StatusCallback& callback); |
295 | 328 |
296 SWIdToRegistrationsMap sw_to_registrations_map_; | 329 SWIdToRegistrationsMap active_registrations_; |
297 CacheStorageScheduler op_scheduler_; | 330 CacheStorageScheduler op_scheduler_; |
298 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | 331 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; |
299 bool disabled_; | 332 bool disabled_; |
300 | 333 |
301 scoped_ptr<BackgroundSyncNetworkObserver> network_observer_; | 334 scoped_ptr<BackgroundSyncNetworkObserver> network_observer_; |
302 scoped_ptr<BackgroundSyncPowerObserver> power_observer_; | 335 scoped_ptr<BackgroundSyncPowerObserver> power_observer_; |
303 | 336 |
| 337 // The registrations that clients have handles to. |
| 338 IDMap<scoped_refptr<RefCountedRegistration>, IDMapOwnPointer> |
| 339 registration_handle_ids_; |
| 340 |
304 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; | 341 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; |
305 | 342 |
306 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); | 343 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); |
307 }; | 344 }; |
308 | 345 |
309 } // namespace content | 346 } // namespace content |
310 | 347 |
311 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ | 348 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ |
OLD | NEW |