Chromium Code Reviews| 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 const StatusAndRegistrationCallback& callback); | 73 const StatusAndRegistrationCallback& callback); |
| 72 | 74 |
| 73 // Removes the background sync with tag |sync_registration_tag|, periodicity | |
| 74 // |periodicity|, and id |sync_registration_id|. Calls |callback| with | |
| 75 // BACKGROUND_SYNC_STATUS_NOT_FOUND if no match is found. Calls |callback| | |
| 76 // with BACKGROUND_SYNC_STATUS_OK on success. | |
| 77 void Unregister( | |
| 78 int64 sw_registration_id, | |
| 79 const std::string& sync_registration_tag, | |
| 80 SyncPeriodicity periodicity, | |
| 81 BackgroundSyncRegistration::RegistrationId sync_registration_id, | |
| 82 const StatusCallback& callback); | |
| 83 | |
| 84 // Finds the background sync registration associated with | 75 // Finds the background sync registration associated with |
| 85 // |sw_registration_id| with periodicity |periodicity|. Calls | 76 // |sw_registration_id| with periodicity |periodicity|. Calls |
| 86 // |callback| with BACKGROUND_SYNC_STATUS_NOT_FOUND if it doesn't exist. Calls | 77 // |callback| with BACKGROUND_SYNC_STATUS_NOT_FOUND if it doesn't exist. Calls |
| 87 // |callback| with BACKGROUND_SYNC_STATUS_OK on success. | 78 // |callback| with BACKGROUND_SYNC_STATUS_OK on success. |
| 88 void GetRegistration(int64 sw_registration_id, | 79 void GetRegistration(int64 sw_registration_id, |
| 89 const std::string& sync_registration_tag, | 80 const std::string& sync_registration_tag, |
| 90 SyncPeriodicity periodicity, | 81 SyncPeriodicity periodicity, |
| 91 const StatusAndRegistrationCallback& callback); | 82 const StatusAndRegistrationCallback& callback); |
| 92 | 83 |
| 93 void GetRegistrations(int64 sw_registration_id, | 84 void GetRegistrations(int64 sw_registration_id, |
| 94 SyncPeriodicity periodicity, | 85 SyncPeriodicity periodicity, |
| 95 const StatusAndRegistrationsCallback& callback); | 86 const StatusAndRegistrationsCallback& callback); |
| 96 | 87 |
| 88 // Given a HandleId |handle_id|, return a new handle for the same | |
| 89 // registration. | |
| 90 scoped_ptr<BackgroundSyncRegistrationHandle> DuplicateRegistrationHandle( | |
| 91 int64 sw_registration_id, | |
| 92 BackgroundSyncRegistrationHandle::HandleId handle_id); | |
| 93 | |
| 97 // ServiceWorkerContextObserver overrides. | 94 // ServiceWorkerContextObserver overrides. |
| 98 void OnRegistrationDeleted(int64 registration_id, | 95 void OnRegistrationDeleted(int64 registration_id, |
| 99 const GURL& pattern) override; | 96 const GURL& pattern) override; |
| 100 void OnStorageWiped() override; | 97 void OnStorageWiped() override; |
| 101 | 98 |
| 102 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 | |
| 103 explicit BackgroundSyncManager( | 108 explicit BackgroundSyncManager( |
| 104 const scoped_refptr<ServiceWorkerContextWrapper>& context); | 109 const scoped_refptr<ServiceWorkerContextWrapper>& context); |
| 105 | 110 |
| 106 // 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. |
| 107 void Init(); | 112 void Init(); |
| 108 | 113 |
| 109 // The following methods are virtual for testing. | 114 // The following methods are virtual for testing. |
| 110 virtual void StoreDataInBackend( | 115 virtual void StoreDataInBackend( |
| 111 int64 sw_registration_id, | 116 int64 sw_registration_id, |
| 112 const GURL& origin, | 117 const GURL& origin, |
| 113 const std::string& backend_key, | 118 const std::string& backend_key, |
| 114 const std::string& data, | 119 const std::string& data, |
| 115 const ServiceWorkerStorage::StatusCallback& callback); | 120 const ServiceWorkerStorage::StatusCallback& callback); |
| 116 virtual void GetDataFromBackend( | 121 virtual void GetDataFromBackend( |
| 117 const std::string& backend_key, | 122 const std::string& backend_key, |
| 118 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& | 123 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& |
| 119 callback); | 124 callback); |
| 120 virtual void FireOneShotSync( | 125 virtual void FireOneShotSync( |
| 121 const BackgroundSyncRegistration& registration, | 126 BackgroundSyncRegistrationHandle::HandleId handle_id, |
| 122 const scoped_refptr<ServiceWorkerVersion>& active_version, | 127 const scoped_refptr<ServiceWorkerVersion>& active_version, |
| 123 const ServiceWorkerVersion::StatusCallback& callback); | 128 const ServiceWorkerVersion::StatusCallback& callback); |
| 124 | 129 |
| 125 private: | 130 private: |
| 131 friend class BackgroundSyncRegistrationHandle; | |
| 132 | |
| 126 class RegistrationKey { | 133 class RegistrationKey { |
| 127 public: | 134 public: |
| 128 explicit RegistrationKey(const BackgroundSyncRegistration& registration); | 135 explicit RegistrationKey(const BackgroundSyncRegistration& registration); |
| 129 explicit RegistrationKey(const BackgroundSyncRegistrationOptions& options); | 136 explicit RegistrationKey(const BackgroundSyncRegistrationOptions& options); |
| 130 RegistrationKey(const std::string& tag, SyncPeriodicity periodicity); | 137 RegistrationKey(const std::string& tag, SyncPeriodicity periodicity); |
| 131 RegistrationKey(const RegistrationKey& other) = default; | 138 RegistrationKey(const RegistrationKey& other) = default; |
| 132 RegistrationKey& operator=(const RegistrationKey& other) = default; | 139 RegistrationKey& operator=(const RegistrationKey& other) = default; |
| 133 | 140 |
| 134 bool operator<(const RegistrationKey& rhs) const { | 141 bool operator<(const RegistrationKey& rhs) const { |
| 135 return value_ < rhs.value_; | 142 return value_ < rhs.value_; |
| 136 } | 143 } |
| 137 | 144 |
| 138 private: | 145 private: |
| 139 std::string value_; | 146 std::string value_; |
| 140 }; | 147 }; |
| 141 | 148 |
| 142 struct BackgroundSyncRegistrations { | 149 struct BackgroundSyncRegistrations { |
| 143 using RegistrationMap = | 150 using RegistrationMap = |
| 144 std::map<RegistrationKey, BackgroundSyncRegistration>; | 151 std::map<RegistrationKey, scoped_refptr<RefCountedRegistration>>; |
| 145 | 152 |
| 146 BackgroundSyncRegistrations(); | 153 BackgroundSyncRegistrations(); |
| 147 ~BackgroundSyncRegistrations(); | 154 ~BackgroundSyncRegistrations(); |
| 148 | 155 |
| 149 RegistrationMap registration_map; | 156 RegistrationMap registration_map; |
| 150 BackgroundSyncRegistration::RegistrationId next_id; | 157 BackgroundSyncRegistration::RegistrationId next_id; |
| 151 GURL origin; | 158 GURL origin; |
| 152 }; | 159 }; |
| 153 | 160 |
| 154 using PermissionStatusCallback = base::Callback<void(bool)>; | 161 using PermissionStatusCallback = base::Callback<void(bool)>; |
| 155 using SWIdToRegistrationsMap = std::map<int64, BackgroundSyncRegistrations>; | 162 using SWIdToRegistrationsMap = std::map<int64, BackgroundSyncRegistrations>; |
| 156 | 163 |
| 164 scoped_ptr<BackgroundSyncRegistrationHandle> CreateRegistrationHandle( | |
| 165 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 | |
| 157 // Disable the manager. Already queued operations will abort once they start | 177 // Disable the manager. Already queued operations will abort once they start |
| 158 // 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 |
| 159 // 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 |
| 160 // functioning). The manager will reenable itself once it receives the | 180 // functioning). The manager will reenable itself once it receives the |
| 161 // OnStorageWiped message or on browser restart. | 181 // OnStorageWiped message or on browser restart. |
| 162 void DisableAndClearManager(const base::Closure& callback); | 182 void DisableAndClearManager(const base::Closure& callback); |
| 163 void DisableAndClearDidGetRegistrations( | 183 void DisableAndClearDidGetRegistrations( |
| 164 const base::Closure& callback, | 184 const base::Closure& callback, |
| 165 const std::vector<std::pair<int64, std::string>>& user_data, | 185 const std::vector<std::pair<int64, std::string>>& user_data, |
| 166 ServiceWorkerStatusCode status); | 186 ServiceWorkerStatusCode status); |
| 167 void DisableAndClearManagerClearedOne(const base::Closure& barrier_closure, | 187 void DisableAndClearManagerClearedOne(const base::Closure& barrier_closure, |
| 168 ServiceWorkerStatusCode status); | 188 ServiceWorkerStatusCode status); |
| 169 | 189 |
| 170 // Returns the existing registration in |existing_registration| if it is not | 190 // Returns the existing registration in |existing_registration| if it is not |
| 171 // null. | 191 // null. |
| 172 BackgroundSyncRegistration* LookupRegistration( | 192 RefCountedRegistration* LookupActiveRegistration( |
| 173 int64 sw_registration_id, | 193 int64 sw_registration_id, |
| 174 const RegistrationKey& registration_key); | 194 const RegistrationKey& registration_key); |
| 175 | 195 |
| 176 // Store all registrations for a given |sw_registration_id|. | 196 // Store all registrations for a given |sw_registration_id|. |
| 177 void StoreRegistrations(int64 sw_registration_id, | 197 void StoreRegistrations(int64 sw_registration_id, |
| 178 const ServiceWorkerStorage::StatusCallback& callback); | 198 const ServiceWorkerStorage::StatusCallback& callback); |
| 179 | 199 |
| 180 // Removes the registration if it is in the map. | 200 // Removes the registration if it is in the map. |
| 181 void RemoveRegistrationFromMap(int64 sw_registration_id, | 201 void RemoveActiveRegistration(int64 sw_registration_id, |
| 182 const RegistrationKey& registration_key); | 202 const RegistrationKey& registration_key); |
| 183 | 203 |
| 184 void AddRegistrationToMap( | 204 void AddActiveRegistration( |
|
michaeln
2015/08/28 02:53:11
thnx for making the subtle name changes
jkarlin
2015/09/02 23:51:40
Acknowledged.
| |
| 185 int64 sw_registration_id, | 205 int64 sw_registration_id, |
| 186 const GURL& origin, | 206 const GURL& origin, |
| 187 const BackgroundSyncRegistration& sync_registration); | 207 const scoped_refptr<RefCountedRegistration>& sync_registration); |
| 188 | 208 |
| 189 void InitImpl(const base::Closure& callback); | 209 void InitImpl(const base::Closure& callback); |
| 190 void InitDidGetDataFromBackend( | 210 void InitDidGetDataFromBackend( |
| 191 const base::Closure& callback, | 211 const base::Closure& callback, |
| 192 const std::vector<std::pair<int64, std::string>>& user_data, | 212 const std::vector<std::pair<int64, std::string>>& user_data, |
| 193 ServiceWorkerStatusCode status); | 213 ServiceWorkerStatusCode status); |
| 194 | 214 |
| 195 // Register callbacks | 215 // Register callbacks |
| 196 void RegisterImpl(int64 sw_registration_id, | 216 void RegisterImpl(int64 sw_registration_id, |
| 197 const BackgroundSyncRegistrationOptions& options, | 217 const BackgroundSyncRegistrationOptions& options, |
| 198 const StatusAndRegistrationCallback& callback); | 218 const StatusAndRegistrationCallback& callback); |
| 199 void RegisterDidStore(int64 sw_registration_id, | 219 void RegisterDidStore( |
| 200 const BackgroundSyncRegistration& sync_registration, | 220 int64 sw_registration_id, |
| 201 const StatusAndRegistrationCallback& callback, | 221 const scoped_refptr<RefCountedRegistration>& new_registration_ref, |
| 202 ServiceWorkerStatusCode status); | 222 const StatusAndRegistrationCallback& callback, |
| 223 ServiceWorkerStatusCode status); | |
| 203 | 224 |
| 204 // Unregister callbacks | 225 // Removes the background sync with periodicity |periodicity| and id |
| 226 // |sync_registration_id|. Calls |callback| with | |
| 227 // BACKGROUND_SYNC_STATUS_NOT_FOUND if no match is found. Calls |callback| | |
| 228 // with BACKGROUND_SYNC_STATUS_OK on success. | |
| 229 void Unregister(int64 sw_registration_id, | |
| 230 SyncPeriodicity periodicity, | |
| 231 BackgroundSyncRegistrationHandle::HandleId handle_id, | |
| 232 const StatusCallback& callback); | |
| 205 void UnregisterImpl( | 233 void UnregisterImpl( |
| 206 int64 sw_registration_id, | 234 int64 sw_registration_id, |
| 207 const RegistrationKey& registration_key, | 235 const RegistrationKey& key, |
| 208 BackgroundSyncRegistration::RegistrationId sync_registration_id, | 236 BackgroundSyncRegistration::RegistrationId sync_registration_id, |
| 209 SyncPeriodicity periodicity, | 237 SyncPeriodicity periodicity, |
| 210 const StatusCallback& callback); | 238 const StatusCallback& callback); |
| 211 void UnregisterDidStore(int64 sw_registration_id, | 239 void UnregisterDidStore(int64 sw_registration_id, |
| 212 SyncPeriodicity periodicity, | 240 SyncPeriodicity periodicity, |
| 213 const StatusCallback& callback, | 241 const StatusCallback& callback, |
| 214 ServiceWorkerStatusCode status); | 242 ServiceWorkerStatusCode status); |
| 215 | 243 |
| 216 // GetRegistration callbacks | 244 // GetRegistration callbacks |
| 217 void GetRegistrationImpl(int64 sw_registration_id, | 245 void GetRegistrationImpl(int64 sw_registration_id, |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 243 const base::Closure& event_completed_callback, | 271 const base::Closure& event_completed_callback, |
| 244 ServiceWorkerStatusCode service_worker_status, | 272 ServiceWorkerStatusCode service_worker_status, |
| 245 const scoped_refptr<ServiceWorkerRegistration>& | 273 const scoped_refptr<ServiceWorkerRegistration>& |
| 246 service_worker_registration); | 274 service_worker_registration); |
| 247 | 275 |
| 248 // Called when a sync event has completed. | 276 // Called when a sync event has completed. |
| 249 void EventComplete( | 277 void EventComplete( |
| 250 const scoped_refptr<ServiceWorkerRegistration>& | 278 const scoped_refptr<ServiceWorkerRegistration>& |
| 251 service_worker_registration, | 279 service_worker_registration, |
| 252 int64 service_worker_id, | 280 int64 service_worker_id, |
| 253 const RegistrationKey& key, | 281 scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle, |
| 254 BackgroundSyncRegistration::RegistrationId sync_registration_id, | |
| 255 const base::Closure& callback, | 282 const base::Closure& callback, |
| 256 ServiceWorkerStatusCode status_code); | 283 ServiceWorkerStatusCode status_code); |
| 257 void EventCompleteImpl( | 284 void EventCompleteImpl( |
| 258 int64 service_worker_id, | 285 int64 service_worker_id, |
| 259 const RegistrationKey& key, | 286 scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle, |
| 260 BackgroundSyncRegistration::RegistrationId sync_registration_id, | |
| 261 ServiceWorkerStatusCode status_code, | 287 ServiceWorkerStatusCode status_code, |
| 262 const base::Closure& callback); | 288 const base::Closure& callback); |
| 263 void EventCompleteDidStore(int64 service_worker_id, | 289 void EventCompleteDidStore(int64 service_worker_id, |
| 264 const base::Closure& callback, | 290 const base::Closure& callback, |
| 265 ServiceWorkerStatusCode status_code); | 291 ServiceWorkerStatusCode status_code); |
| 266 | 292 |
| 267 // Called when all sync events have completed. | 293 // Called when all sync events have completed. |
| 268 static void OnAllSyncEventsCompleted(const base::TimeTicks& start_time, | 294 static void OnAllSyncEventsCompleted(const base::TimeTicks& start_time, |
| 269 int number_of_batched_sync_events); | 295 int number_of_batched_sync_events); |
| 270 | 296 |
| 271 // OnRegistrationDeleted callbacks | 297 // OnRegistrationDeleted callbacks |
| 272 void OnRegistrationDeletedImpl(int64 registration_id, | 298 void OnRegistrationDeletedImpl(int64 registration_id, |
| 273 const base::Closure& callback); | 299 const base::Closure& callback); |
| 274 | 300 |
| 275 // OnStorageWiped callbacks | 301 // OnStorageWiped callbacks |
| 276 void OnStorageWipedImpl(const base::Closure& callback); | 302 void OnStorageWipedImpl(const base::Closure& callback); |
| 277 | 303 |
| 278 void OnNetworkChanged(); | 304 void OnNetworkChanged(); |
| 279 void OnPowerChanged(); | 305 void OnPowerChanged(); |
| 280 | 306 |
| 281 // Operation Scheduling callback and convenience functions. | 307 // Operation Scheduling callback and convenience functions. |
| 282 template <typename CallbackT, typename... Params> | 308 template <typename CallbackT, typename... Params> |
| 283 void CompleteOperationCallback(const CallbackT& callback, | 309 void CompleteOperationCallback(const CallbackT& callback, |
| 284 Params... parameters); | 310 Params... parameters); |
| 311 void CompleteStatusAndRegistrationCallback( | |
| 312 StatusAndRegistrationCallback callback, | |
| 313 BackgroundSyncStatus status, | |
| 314 scoped_ptr<BackgroundSyncRegistrationHandle> result); | |
| 315 void CompleteStatusAndRegistrationsCallback( | |
| 316 StatusAndRegistrationsCallback callback, | |
| 317 BackgroundSyncStatus status, | |
| 318 scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>> results); | |
| 285 base::Closure MakeEmptyCompletion(); | 319 base::Closure MakeEmptyCompletion(); |
| 286 base::Closure MakeClosureCompletion(const base::Closure& callback); | 320 base::Closure MakeClosureCompletion(const base::Closure& callback); |
| 287 StatusAndRegistrationCallback MakeStatusAndRegistrationCompletion( | 321 StatusAndRegistrationCallback MakeStatusAndRegistrationCompletion( |
| 288 const StatusAndRegistrationCallback& callback); | 322 const StatusAndRegistrationCallback& callback); |
| 289 StatusAndRegistrationsCallback MakeStatusAndRegistrationsCompletion( | 323 StatusAndRegistrationsCallback MakeStatusAndRegistrationsCompletion( |
| 290 const StatusAndRegistrationsCallback& callback); | 324 const StatusAndRegistrationsCallback& callback); |
| 291 BackgroundSyncManager::StatusCallback MakeStatusCompletion( | 325 BackgroundSyncManager::StatusCallback MakeStatusCompletion( |
| 292 const StatusCallback& callback); | 326 const StatusCallback& callback); |
| 293 | 327 |
| 294 SWIdToRegistrationsMap sw_to_registrations_map_; | 328 SWIdToRegistrationsMap active_registrations_; |
| 295 CacheStorageScheduler op_scheduler_; | 329 CacheStorageScheduler op_scheduler_; |
| 296 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; | 330 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context_; |
| 297 bool disabled_; | 331 bool disabled_; |
| 298 | 332 |
| 299 scoped_ptr<BackgroundSyncNetworkObserver> network_observer_; | 333 scoped_ptr<BackgroundSyncNetworkObserver> network_observer_; |
| 300 scoped_ptr<BackgroundSyncPowerObserver> power_observer_; | 334 scoped_ptr<BackgroundSyncPowerObserver> power_observer_; |
| 301 | 335 |
| 336 // The registrations that clients have handles to. | |
| 337 IDMap<scoped_refptr<RefCountedRegistration>, IDMapOwnPointer> | |
| 338 registration_handle_ids_; | |
| 339 | |
| 302 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; | 340 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; |
| 303 | 341 |
| 304 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); | 342 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); |
| 305 }; | 343 }; |
| 306 | 344 |
| 307 } // namespace content | 345 } // namespace content |
| 308 | 346 |
| 309 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ | 347 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ |
| OLD | NEW |