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