| 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> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "content/common/background_sync_service.mojom.h" | 30 #include "content/common/background_sync_service.mojom.h" |
| 31 #include "content/common/content_export.h" | 31 #include "content/common/content_export.h" |
| 32 #include "content/common/service_worker/service_worker_status_code.h" | 32 #include "content/common/service_worker/service_worker_status_code.h" |
| 33 #include "content/public/browser/background_sync_parameters.h" | 33 #include "content/public/browser/background_sync_parameters.h" |
| 34 #include "content/public/browser/browser_thread.h" | 34 #include "content/public/browser/browser_thread.h" |
| 35 #include "url/gurl.h" | 35 #include "url/gurl.h" |
| 36 | 36 |
| 37 namespace content { | 37 namespace content { |
| 38 | 38 |
| 39 class BackgroundSyncNetworkObserver; | 39 class BackgroundSyncNetworkObserver; |
| 40 class BackgroundSyncPowerObserver; | |
| 41 class ServiceWorkerContextWrapper; | 40 class ServiceWorkerContextWrapper; |
| 42 | 41 |
| 43 // BackgroundSyncManager manages and stores the set of background sync | 42 // BackgroundSyncManager manages and stores the set of background sync |
| 44 // registrations across all registered service workers for a profile. | 43 // registrations across all registered service workers for a profile. |
| 45 // Registrations are stored along with their associated Service Worker | 44 // Registrations are stored along with their associated Service Worker |
| 46 // registration in ServiceWorkerStorage. If the ServiceWorker is unregistered, | 45 // registration in ServiceWorkerStorage. If the ServiceWorker is unregistered, |
| 47 // the sync registrations are removed. This class must be run on the IO | 46 // the sync registrations are removed. This class must be run on the IO |
| 48 // thread. The asynchronous methods are executed sequentially. | 47 // thread. The asynchronous methods are executed sequentially. |
| 49 class CONTENT_EXPORT BackgroundSyncManager | 48 class CONTENT_EXPORT BackgroundSyncManager |
| 50 : NON_EXPORTED_BASE(public ServiceWorkerContextObserver) { | 49 : NON_EXPORTED_BASE(public ServiceWorkerContextObserver) { |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 int number_of_batched_sync_events); | 354 int number_of_batched_sync_events); |
| 356 | 355 |
| 357 // OnRegistrationDeleted callbacks | 356 // OnRegistrationDeleted callbacks |
| 358 void OnRegistrationDeletedImpl(int64_t sw_registration_id, | 357 void OnRegistrationDeletedImpl(int64_t sw_registration_id, |
| 359 const base::Closure& callback); | 358 const base::Closure& callback); |
| 360 | 359 |
| 361 // OnStorageWiped callbacks | 360 // OnStorageWiped callbacks |
| 362 void OnStorageWipedImpl(const base::Closure& callback); | 361 void OnStorageWipedImpl(const base::Closure& callback); |
| 363 | 362 |
| 364 void OnNetworkChanged(); | 363 void OnNetworkChanged(); |
| 365 void OnPowerChanged(); | |
| 366 | 364 |
| 367 // SetMaxSyncAttempts callback | 365 // SetMaxSyncAttempts callback |
| 368 void SetMaxSyncAttemptsImpl(int max_sync_attempts, | 366 void SetMaxSyncAttemptsImpl(int max_sync_attempts, |
| 369 const base::Closure& callback); | 367 const base::Closure& callback); |
| 370 | 368 |
| 371 // Operation Scheduling callback and convenience functions. | 369 // Operation Scheduling callback and convenience functions. |
| 372 template <typename CallbackT, typename... Params> | 370 template <typename CallbackT, typename... Params> |
| 373 void CompleteOperationCallback(const CallbackT& callback, | 371 void CompleteOperationCallback(const CallbackT& callback, |
| 374 Params... parameters); | 372 Params... parameters); |
| 375 void CompleteStatusAndRegistrationCallback( | 373 void CompleteStatusAndRegistrationCallback( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 397 | 395 |
| 398 // True if the manager is disabled and registrations should fail. | 396 // True if the manager is disabled and registrations should fail. |
| 399 bool disabled_; | 397 bool disabled_; |
| 400 | 398 |
| 401 // The number of registrations currently in the firing state. | 399 // The number of registrations currently in the firing state. |
| 402 int num_firing_registrations_; | 400 int num_firing_registrations_; |
| 403 | 401 |
| 404 base::CancelableCallback<void()> delayed_sync_task_; | 402 base::CancelableCallback<void()> delayed_sync_task_; |
| 405 | 403 |
| 406 scoped_ptr<BackgroundSyncNetworkObserver> network_observer_; | 404 scoped_ptr<BackgroundSyncNetworkObserver> network_observer_; |
| 407 scoped_ptr<BackgroundSyncPowerObserver> power_observer_; | |
| 408 | 405 |
| 409 // The registrations that clients have handles to. | 406 // The registrations that clients have handles to. |
| 410 IDMap<scoped_refptr<RefCountedRegistration>, | 407 IDMap<scoped_refptr<RefCountedRegistration>, |
| 411 IDMapOwnPointer, | 408 IDMapOwnPointer, |
| 412 BackgroundSyncRegistrationHandle::HandleId> registration_handle_ids_; | 409 BackgroundSyncRegistrationHandle::HandleId> registration_handle_ids_; |
| 413 | 410 |
| 414 scoped_ptr<base::Clock> clock_; | 411 scoped_ptr<base::Clock> clock_; |
| 415 | 412 |
| 416 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; | 413 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; |
| 417 | 414 |
| 418 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); | 415 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); |
| 419 }; | 416 }; |
| 420 | 417 |
| 421 } // namespace content | 418 } // namespace content |
| 422 | 419 |
| 423 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ | 420 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ |
| OLD | NEW |