| 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 <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
| 8 #include <map> | 11 #include <map> |
| 9 #include <string> | 12 #include <string> |
| 10 #include <utility> | 13 #include <utility> |
| 11 #include <vector> | 14 #include <vector> |
| 12 | 15 |
| 13 #include "base/callback_forward.h" | 16 #include "base/callback_forward.h" |
| 14 #include "base/cancelable_callback.h" | 17 #include "base/cancelable_callback.h" |
| 18 #include "base/macros.h" |
| 15 #include "base/memory/scoped_ptr.h" | 19 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/memory/scoped_vector.h" | 20 #include "base/memory/scoped_vector.h" |
| 17 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 18 #include "base/time/clock.h" | 22 #include "base/time/clock.h" |
| 19 #include "content/browser/background_sync/background_sync.pb.h" | 23 #include "content/browser/background_sync/background_sync.pb.h" |
| 20 #include "content/browser/background_sync/background_sync_registration.h" | 24 #include "content/browser/background_sync/background_sync_registration.h" |
| 21 #include "content/browser/background_sync/background_sync_registration_handle.h" | 25 #include "content/browser/background_sync/background_sync_registration_handle.h" |
| 22 #include "content/browser/background_sync/background_sync_status.h" | 26 #include "content/browser/background_sync/background_sync_status.h" |
| 23 #include "content/browser/cache_storage/cache_storage_scheduler.h" | 27 #include "content/browser/cache_storage/cache_storage_scheduler.h" |
| 24 #include "content/browser/service_worker/service_worker_context_observer.h" | 28 #include "content/browser/service_worker/service_worker_context_observer.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context); | 64 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context); |
| 61 ~BackgroundSyncManager() override; | 65 ~BackgroundSyncManager() override; |
| 62 | 66 |
| 63 // Stores the given background sync registration and adds it to the scheduling | 67 // Stores the given background sync registration and adds it to the scheduling |
| 64 // queue. It will overwrite an existing registration with the same tag and | 68 // queue. It will overwrite an existing registration with the same tag and |
| 65 // periodicity unless they're identical (save for the id). Calls |callback| | 69 // periodicity unless they're identical (save for the id). Calls |callback| |
| 66 // with BACKGROUND_SYNC_STATUS_OK and the accepted registration on success. | 70 // with BACKGROUND_SYNC_STATUS_OK and the accepted registration on success. |
| 67 // The accepted registration will have a unique id. It may also have altered | 71 // The accepted registration will have a unique id. It may also have altered |
| 68 // parameters if the user or UA chose different parameters than those | 72 // parameters if the user or UA chose different parameters than those |
| 69 // supplied. | 73 // supplied. |
| 70 void Register(int64 sw_registration_id, | 74 void Register(int64_t sw_registration_id, |
| 71 const BackgroundSyncRegistrationOptions& options, | 75 const BackgroundSyncRegistrationOptions& options, |
| 72 bool requested_from_service_worker, | 76 bool requested_from_service_worker, |
| 73 const StatusAndRegistrationCallback& callback); | 77 const StatusAndRegistrationCallback& callback); |
| 74 | 78 |
| 75 // Finds the background sync registration associated with | 79 // Finds the background sync registration associated with |
| 76 // |sw_registration_id|, periodicity |periodicity|, and tag | 80 // |sw_registration_id|, periodicity |periodicity|, and tag |
| 77 // |sync_registration_tag|. Calls |callback| with | 81 // |sync_registration_tag|. Calls |callback| with |
| 78 // BACKGROUND_SYNC_STATUS_NOT_FOUND if it doesn't exist. Calls |callback| with | 82 // BACKGROUND_SYNC_STATUS_NOT_FOUND if it doesn't exist. Calls |callback| with |
| 79 // BACKGROUND_SYNC_STATUS_OK on success. If the callback's status | 83 // BACKGROUND_SYNC_STATUS_OK on success. If the callback's status |
| 80 // is not BACKGROUND_SYNC_STATUS_OK then the callback's RegistrationHandle | 84 // is not BACKGROUND_SYNC_STATUS_OK then the callback's RegistrationHandle |
| 81 // will be nullptr. | 85 // will be nullptr. |
| 82 void GetRegistration(int64 sw_registration_id, | 86 void GetRegistration(int64_t sw_registration_id, |
| 83 const std::string& sync_registration_tag, | 87 const std::string& sync_registration_tag, |
| 84 SyncPeriodicity periodicity, | 88 SyncPeriodicity periodicity, |
| 85 const StatusAndRegistrationCallback& callback); | 89 const StatusAndRegistrationCallback& callback); |
| 86 | 90 |
| 87 // Finds the background sync registrations associated with | 91 // Finds the background sync registrations associated with |
| 88 // |sw_registration_id| and periodicity |periodicity|. Calls | 92 // |sw_registration_id| and periodicity |periodicity|. Calls |
| 89 // |callback| with BACKGROUND_SYNC_STATUS_OK on success. | 93 // |callback| with BACKGROUND_SYNC_STATUS_OK on success. |
| 90 void GetRegistrations(int64 sw_registration_id, | 94 void GetRegistrations(int64_t sw_registration_id, |
| 91 SyncPeriodicity periodicity, | 95 SyncPeriodicity periodicity, |
| 92 const StatusAndRegistrationsCallback& callback); | 96 const StatusAndRegistrationsCallback& callback); |
| 93 | 97 |
| 94 // Given a HandleId |handle_id|, return a new handle for the same | 98 // Given a HandleId |handle_id|, return a new handle for the same |
| 95 // registration. | 99 // registration. |
| 96 scoped_ptr<BackgroundSyncRegistrationHandle> DuplicateRegistrationHandle( | 100 scoped_ptr<BackgroundSyncRegistrationHandle> DuplicateRegistrationHandle( |
| 97 BackgroundSyncRegistrationHandle::HandleId handle_id); | 101 BackgroundSyncRegistrationHandle::HandleId handle_id); |
| 98 | 102 |
| 99 // ServiceWorkerContextObserver overrides. | 103 // ServiceWorkerContextObserver overrides. |
| 100 void OnRegistrationDeleted(int64 sw_registration_id, | 104 void OnRegistrationDeleted(int64_t sw_registration_id, |
| 101 const GURL& pattern) override; | 105 const GURL& pattern) override; |
| 102 void OnStorageWiped() override; | 106 void OnStorageWiped() override; |
| 103 | 107 |
| 104 BackgroundSyncNetworkObserver* GetNetworkObserverForTesting() { | 108 BackgroundSyncNetworkObserver* GetNetworkObserverForTesting() { |
| 105 return network_observer_.get(); | 109 return network_observer_.get(); |
| 106 } | 110 } |
| 107 | 111 |
| 108 void set_clock(scoped_ptr<base::Clock> clock) { | 112 void set_clock(scoped_ptr<base::Clock> clock) { |
| 109 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 113 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 110 clock_ = clock.Pass(); | 114 clock_ = clock.Pass(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 124 class RefCountedRegistration; | 128 class RefCountedRegistration; |
| 125 | 129 |
| 126 explicit BackgroundSyncManager( | 130 explicit BackgroundSyncManager( |
| 127 const scoped_refptr<ServiceWorkerContextWrapper>& context); | 131 const scoped_refptr<ServiceWorkerContextWrapper>& context); |
| 128 | 132 |
| 129 // Init must be called before any public member function. Only call it once. | 133 // Init must be called before any public member function. Only call it once. |
| 130 void Init(); | 134 void Init(); |
| 131 | 135 |
| 132 // The following methods are virtual for testing. | 136 // The following methods are virtual for testing. |
| 133 virtual void StoreDataInBackend( | 137 virtual void StoreDataInBackend( |
| 134 int64 sw_registration_id, | 138 int64_t sw_registration_id, |
| 135 const GURL& origin, | 139 const GURL& origin, |
| 136 const std::string& backend_key, | 140 const std::string& backend_key, |
| 137 const std::string& data, | 141 const std::string& data, |
| 138 const ServiceWorkerStorage::StatusCallback& callback); | 142 const ServiceWorkerStorage::StatusCallback& callback); |
| 139 virtual void GetDataFromBackend( | 143 virtual void GetDataFromBackend( |
| 140 const std::string& backend_key, | 144 const std::string& backend_key, |
| 141 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& | 145 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& |
| 142 callback); | 146 callback); |
| 143 virtual void FireOneShotSync( | 147 virtual void FireOneShotSync( |
| 144 BackgroundSyncRegistrationHandle::HandleId handle_id, | 148 BackgroundSyncRegistrationHandle::HandleId handle_id, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 | 181 |
| 178 BackgroundSyncRegistrations(); | 182 BackgroundSyncRegistrations(); |
| 179 ~BackgroundSyncRegistrations(); | 183 ~BackgroundSyncRegistrations(); |
| 180 | 184 |
| 181 RegistrationMap registration_map; | 185 RegistrationMap registration_map; |
| 182 BackgroundSyncRegistration::RegistrationId next_id; | 186 BackgroundSyncRegistration::RegistrationId next_id; |
| 183 GURL origin; | 187 GURL origin; |
| 184 }; | 188 }; |
| 185 | 189 |
| 186 using PermissionStatusCallback = base::Callback<void(bool)>; | 190 using PermissionStatusCallback = base::Callback<void(bool)>; |
| 187 using SWIdToRegistrationsMap = std::map<int64, BackgroundSyncRegistrations>; | 191 using SWIdToRegistrationsMap = std::map<int64_t, BackgroundSyncRegistrations>; |
| 188 | 192 |
| 189 static const size_t kMaxTagLength = 10240; | 193 static const size_t kMaxTagLength = 10240; |
| 190 | 194 |
| 191 scoped_ptr<BackgroundSyncRegistrationHandle> CreateRegistrationHandle( | 195 scoped_ptr<BackgroundSyncRegistrationHandle> CreateRegistrationHandle( |
| 192 const scoped_refptr<RefCountedRegistration>& registration); | 196 const scoped_refptr<RefCountedRegistration>& registration); |
| 193 | 197 |
| 194 // Returns the BackgroundSyncRegistration corresponding to |handle_id|. | 198 // Returns the BackgroundSyncRegistration corresponding to |handle_id|. |
| 195 // Returns nullptr if the registration is not found. | 199 // Returns nullptr if the registration is not found. |
| 196 BackgroundSyncRegistration* GetRegistrationForHandle( | 200 BackgroundSyncRegistration* GetRegistrationForHandle( |
| 197 BackgroundSyncRegistrationHandle::HandleId handle_id) const; | 201 BackgroundSyncRegistrationHandle::HandleId handle_id) const; |
| 198 | 202 |
| 199 // The BackgroundSyncManager holds references to registrations that have | 203 // The BackgroundSyncManager holds references to registrations that have |
| 200 // active Handles. The handles must call this on destruction. | 204 // active Handles. The handles must call this on destruction. |
| 201 void ReleaseRegistrationHandle( | 205 void ReleaseRegistrationHandle( |
| 202 BackgroundSyncRegistrationHandle::HandleId handle_id); | 206 BackgroundSyncRegistrationHandle::HandleId handle_id); |
| 203 | 207 |
| 204 // Disable the manager. Already queued operations will abort once they start | 208 // Disable the manager. Already queued operations will abort once they start |
| 205 // to run (in their impl methods). Future operations will not queue. The one | 209 // to run (in their impl methods). Future operations will not queue. The one |
| 206 // exception is already firing events -- their responses will be processed in | 210 // exception is already firing events -- their responses will be processed in |
| 207 // order to notify their final state. | 211 // order to notify their final state. |
| 208 // The list of active registrations is cleared and the backend is also cleared | 212 // The list of active registrations is cleared and the backend is also cleared |
| 209 // (if it's still functioning). The manager will reenable itself once it | 213 // (if it's still functioning). The manager will reenable itself once it |
| 210 // receives the OnStorageWiped message or on browser restart. | 214 // receives the OnStorageWiped message or on browser restart. |
| 211 void DisableAndClearManager(const base::Closure& callback); | 215 void DisableAndClearManager(const base::Closure& callback); |
| 212 void DisableAndClearDidGetRegistrations( | 216 void DisableAndClearDidGetRegistrations( |
| 213 const base::Closure& callback, | 217 const base::Closure& callback, |
| 214 const std::vector<std::pair<int64, std::string>>& user_data, | 218 const std::vector<std::pair<int64_t, std::string>>& user_data, |
| 215 ServiceWorkerStatusCode status); | 219 ServiceWorkerStatusCode status); |
| 216 void DisableAndClearManagerClearedOne(const base::Closure& barrier_closure, | 220 void DisableAndClearManagerClearedOne(const base::Closure& barrier_closure, |
| 217 ServiceWorkerStatusCode status); | 221 ServiceWorkerStatusCode status); |
| 218 | 222 |
| 219 // Returns the existing registration or nullptr if it cannot be found. | 223 // Returns the existing registration or nullptr if it cannot be found. |
| 220 RefCountedRegistration* LookupActiveRegistration( | 224 RefCountedRegistration* LookupActiveRegistration( |
| 221 int64 sw_registration_id, | 225 int64_t sw_registration_id, |
| 222 const RegistrationKey& registration_key); | 226 const RegistrationKey& registration_key); |
| 223 | 227 |
| 224 // Write all registrations for a given |sw_registration_id| to persistent | 228 // Write all registrations for a given |sw_registration_id| to persistent |
| 225 // storage. | 229 // storage. |
| 226 void StoreRegistrations(int64 sw_registration_id, | 230 void StoreRegistrations(int64_t sw_registration_id, |
| 227 const ServiceWorkerStorage::StatusCallback& callback); | 231 const ServiceWorkerStorage::StatusCallback& callback); |
| 228 | 232 |
| 229 // Removes the active registration if it is in the map. | 233 // Removes the active registration if it is in the map. |
| 230 void RemoveActiveRegistration(int64 sw_registration_id, | 234 void RemoveActiveRegistration(int64_t sw_registration_id, |
| 231 const RegistrationKey& registration_key); | 235 const RegistrationKey& registration_key); |
| 232 | 236 |
| 233 void AddActiveRegistration( | 237 void AddActiveRegistration( |
| 234 int64 sw_registration_id, | 238 int64_t sw_registration_id, |
| 235 const GURL& origin, | 239 const GURL& origin, |
| 236 const scoped_refptr<RefCountedRegistration>& sync_registration); | 240 const scoped_refptr<RefCountedRegistration>& sync_registration); |
| 237 | 241 |
| 238 void InitImpl(const base::Closure& callback); | 242 void InitImpl(const base::Closure& callback); |
| 239 void InitDidGetControllerParameters( | 243 void InitDidGetControllerParameters( |
| 240 const base::Closure& callback, | 244 const base::Closure& callback, |
| 241 scoped_ptr<BackgroundSyncParameters> parameters); | 245 scoped_ptr<BackgroundSyncParameters> parameters); |
| 242 void InitDidGetDataFromBackend( | 246 void InitDidGetDataFromBackend( |
| 243 const base::Closure& callback, | 247 const base::Closure& callback, |
| 244 const std::vector<std::pair<int64, std::string>>& user_data, | 248 const std::vector<std::pair<int64_t, std::string>>& user_data, |
| 245 ServiceWorkerStatusCode status); | 249 ServiceWorkerStatusCode status); |
| 246 | 250 |
| 247 // Register callbacks | 251 // Register callbacks |
| 248 void RegisterCheckIfHasMainFrame( | 252 void RegisterCheckIfHasMainFrame( |
| 249 int64 sw_registration_id, | 253 int64_t sw_registration_id, |
| 250 const BackgroundSyncRegistrationOptions& options, | 254 const BackgroundSyncRegistrationOptions& options, |
| 251 const StatusAndRegistrationCallback& callback); | 255 const StatusAndRegistrationCallback& callback); |
| 252 void RegisterDidCheckIfMainFrame( | 256 void RegisterDidCheckIfMainFrame( |
| 253 int64 sw_registration_id, | 257 int64_t sw_registration_id, |
| 254 const BackgroundSyncRegistrationOptions& options, | 258 const BackgroundSyncRegistrationOptions& options, |
| 255 const StatusAndRegistrationCallback& callback, | 259 const StatusAndRegistrationCallback& callback, |
| 256 bool has_main_frame_client); | 260 bool has_main_frame_client); |
| 257 void RegisterImpl(int64 sw_registration_id, | 261 void RegisterImpl(int64_t sw_registration_id, |
| 258 const BackgroundSyncRegistrationOptions& options, | 262 const BackgroundSyncRegistrationOptions& options, |
| 259 const StatusAndRegistrationCallback& callback); | 263 const StatusAndRegistrationCallback& callback); |
| 260 void RegisterDidStore( | 264 void RegisterDidStore( |
| 261 int64 sw_registration_id, | 265 int64_t sw_registration_id, |
| 262 const scoped_refptr<RefCountedRegistration>& new_registration_ref, | 266 const scoped_refptr<RefCountedRegistration>& new_registration_ref, |
| 263 const StatusAndRegistrationCallback& callback, | 267 const StatusAndRegistrationCallback& callback, |
| 264 ServiceWorkerStatusCode status); | 268 ServiceWorkerStatusCode status); |
| 265 | 269 |
| 266 // Removes the background sync with periodicity |periodicity| and id | 270 // Removes the background sync with periodicity |periodicity| and id |
| 267 // |sync_registration_id|. Calls |callback| with | 271 // |sync_registration_id|. Calls |callback| with |
| 268 // BACKGROUND_SYNC_STATUS_NOT_FOUND if no match is found. Calls |callback| | 272 // BACKGROUND_SYNC_STATUS_NOT_FOUND if no match is found. Calls |callback| |
| 269 // with BACKGROUND_SYNC_STATUS_OK on success. | 273 // with BACKGROUND_SYNC_STATUS_OK on success. |
| 270 void Unregister(int64 sw_registration_id, | 274 void Unregister(int64_t sw_registration_id, |
| 271 BackgroundSyncRegistrationHandle::HandleId handle_id, | 275 BackgroundSyncRegistrationHandle::HandleId handle_id, |
| 272 const StatusCallback& callback); | 276 const StatusCallback& callback); |
| 273 void UnregisterImpl( | 277 void UnregisterImpl( |
| 274 int64 sw_registration_id, | 278 int64_t sw_registration_id, |
| 275 const RegistrationKey& key, | 279 const RegistrationKey& key, |
| 276 BackgroundSyncRegistration::RegistrationId sync_registration_id, | 280 BackgroundSyncRegistration::RegistrationId sync_registration_id, |
| 277 SyncPeriodicity periodicity, | 281 SyncPeriodicity periodicity, |
| 278 const StatusCallback& callback); | 282 const StatusCallback& callback); |
| 279 void UnregisterDidStore(int64 sw_registration_id, | 283 void UnregisterDidStore(int64_t sw_registration_id, |
| 280 SyncPeriodicity periodicity, | 284 SyncPeriodicity periodicity, |
| 281 const StatusCallback& callback, | 285 const StatusCallback& callback, |
| 282 ServiceWorkerStatusCode status); | 286 ServiceWorkerStatusCode status); |
| 283 | 287 |
| 284 // NotifyWhenFinished and its callbacks. See | 288 // NotifyWhenFinished and its callbacks. See |
| 285 // BackgroundSyncRegistrationHandle::NotifyWhenFinished for detailed | 289 // BackgroundSyncRegistrationHandle::NotifyWhenFinished for detailed |
| 286 // documentation. | 290 // documentation. |
| 287 void NotifyWhenFinished(BackgroundSyncRegistrationHandle::HandleId handle_id, | 291 void NotifyWhenFinished(BackgroundSyncRegistrationHandle::HandleId handle_id, |
| 288 const StatusAndStateCallback& callback); | 292 const StatusAndStateCallback& callback); |
| 289 void NotifyWhenFinishedImpl( | 293 void NotifyWhenFinishedImpl( |
| 290 scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle, | 294 scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle, |
| 291 const StatusAndStateCallback& callback); | 295 const StatusAndStateCallback& callback); |
| 292 void NotifyWhenFinishedInvokeCallback(const StatusAndStateCallback& callback, | 296 void NotifyWhenFinishedInvokeCallback(const StatusAndStateCallback& callback, |
| 293 BackgroundSyncState status); | 297 BackgroundSyncState status); |
| 294 | 298 |
| 295 // GetRegistration callbacks | 299 // GetRegistration callbacks |
| 296 void GetRegistrationImpl(int64 sw_registration_id, | 300 void GetRegistrationImpl(int64_t sw_registration_id, |
| 297 const RegistrationKey& registration_key, | 301 const RegistrationKey& registration_key, |
| 298 const StatusAndRegistrationCallback& callback); | 302 const StatusAndRegistrationCallback& callback); |
| 299 | 303 |
| 300 // GetRegistrations callbacks | 304 // GetRegistrations callbacks |
| 301 void GetRegistrationsImpl(int64 sw_registration_id, | 305 void GetRegistrationsImpl(int64_t sw_registration_id, |
| 302 SyncPeriodicity periodicity, | 306 SyncPeriodicity periodicity, |
| 303 const StatusAndRegistrationsCallback& callback); | 307 const StatusAndRegistrationsCallback& callback); |
| 304 | 308 |
| 305 bool AreOptionConditionsMet(const BackgroundSyncRegistrationOptions& options); | 309 bool AreOptionConditionsMet(const BackgroundSyncRegistrationOptions& options); |
| 306 bool IsRegistrationReadyToFire( | 310 bool IsRegistrationReadyToFire( |
| 307 const BackgroundSyncRegistration& registration); | 311 const BackgroundSyncRegistration& registration); |
| 308 | 312 |
| 309 // Determines if the browser needs to be able to run in the background (e.g., | 313 // Determines if the browser needs to be able to run in the background (e.g., |
| 310 // to run a pending registration or verify that a firing registration | 314 // to run a pending registration or verify that a firing registration |
| 311 // completed). If background processing is required it calls out to the | 315 // completed). If background processing is required it calls out to the |
| (...skipping 14 matching lines...) Expand all Loading... |
| 326 const base::Closure& event_completed_callback, | 330 const base::Closure& event_completed_callback, |
| 327 ServiceWorkerStatusCode service_worker_status, | 331 ServiceWorkerStatusCode service_worker_status, |
| 328 const scoped_refptr<ServiceWorkerRegistration>& | 332 const scoped_refptr<ServiceWorkerRegistration>& |
| 329 service_worker_registration); | 333 service_worker_registration); |
| 330 void FireReadyEventsAllEventsFiring(const base::Closure& callback); | 334 void FireReadyEventsAllEventsFiring(const base::Closure& callback); |
| 331 | 335 |
| 332 // Called when a sync event has completed. | 336 // Called when a sync event has completed. |
| 333 void EventComplete( | 337 void EventComplete( |
| 334 const scoped_refptr<ServiceWorkerRegistration>& | 338 const scoped_refptr<ServiceWorkerRegistration>& |
| 335 service_worker_registration, | 339 service_worker_registration, |
| 336 int64 service_worker_id, | 340 int64_t service_worker_id, |
| 337 scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle, | 341 scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle, |
| 338 const base::Closure& callback, | 342 const base::Closure& callback, |
| 339 ServiceWorkerStatusCode status_code); | 343 ServiceWorkerStatusCode status_code); |
| 340 void EventCompleteImpl( | 344 void EventCompleteImpl( |
| 341 int64 service_worker_id, | 345 int64_t service_worker_id, |
| 342 scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle, | 346 scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle, |
| 343 ServiceWorkerStatusCode status_code, | 347 ServiceWorkerStatusCode status_code, |
| 344 const base::Closure& callback); | 348 const base::Closure& callback); |
| 345 void EventCompleteDidStore(int64 service_worker_id, | 349 void EventCompleteDidStore(int64_t service_worker_id, |
| 346 const base::Closure& callback, | 350 const base::Closure& callback, |
| 347 ServiceWorkerStatusCode status_code); | 351 ServiceWorkerStatusCode status_code); |
| 348 | 352 |
| 349 // Called when all sync events have completed. | 353 // Called when all sync events have completed. |
| 350 static void OnAllSyncEventsCompleted(const base::TimeTicks& start_time, | 354 static void OnAllSyncEventsCompleted(const base::TimeTicks& start_time, |
| 351 int number_of_batched_sync_events); | 355 int number_of_batched_sync_events); |
| 352 | 356 |
| 353 // OnRegistrationDeleted callbacks | 357 // OnRegistrationDeleted callbacks |
| 354 void OnRegistrationDeletedImpl(int64 sw_registration_id, | 358 void OnRegistrationDeletedImpl(int64_t sw_registration_id, |
| 355 const base::Closure& callback); | 359 const base::Closure& callback); |
| 356 | 360 |
| 357 // OnStorageWiped callbacks | 361 // OnStorageWiped callbacks |
| 358 void OnStorageWipedImpl(const base::Closure& callback); | 362 void OnStorageWipedImpl(const base::Closure& callback); |
| 359 | 363 |
| 360 void OnNetworkChanged(); | 364 void OnNetworkChanged(); |
| 361 void OnPowerChanged(); | 365 void OnPowerChanged(); |
| 362 | 366 |
| 363 // Operation Scheduling callback and convenience functions. | 367 // Operation Scheduling callback and convenience functions. |
| 364 template <typename CallbackT, typename... Params> | 368 template <typename CallbackT, typename... Params> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 scoped_ptr<base::Clock> clock_; | 410 scoped_ptr<base::Clock> clock_; |
| 407 | 411 |
| 408 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; | 412 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; |
| 409 | 413 |
| 410 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); | 414 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); |
| 411 }; | 415 }; |
| 412 | 416 |
| 413 } // namespace content | 417 } // namespace content |
| 414 | 418 |
| 415 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ | 419 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ |
| OLD | NEW |