| 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 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <memory> | 12 #include <memory> |
| 13 #include <string> | 13 #include <string> |
| 14 #include <utility> | 14 #include <utility> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/callback_forward.h" | 17 #include "base/callback_forward.h" |
| 18 #include "base/cancelable_callback.h" | 18 #include "base/cancelable_callback.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/memory/scoped_vector.h" | |
| 21 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 22 #include "base/time/clock.h" | 21 #include "base/time/clock.h" |
| 23 #include "content/browser/background_sync/background_sync.pb.h" | 22 #include "content/browser/background_sync/background_sync.pb.h" |
| 24 #include "content/browser/background_sync/background_sync_registration.h" | 23 #include "content/browser/background_sync/background_sync_registration.h" |
| 25 #include "content/browser/background_sync/background_sync_status.h" | 24 #include "content/browser/background_sync/background_sync_status.h" |
| 26 #include "content/browser/cache_storage/cache_storage_scheduler.h" | 25 #include "content/browser/cache_storage/cache_storage_scheduler.h" |
| 27 #include "content/browser/service_worker/service_worker_context_observer.h" | 26 #include "content/browser/service_worker/service_worker_context_observer.h" |
| 28 #include "content/browser/service_worker/service_worker_storage.h" | 27 #include "content/browser/service_worker/service_worker_storage.h" |
| 29 #include "content/common/content_export.h" | 28 #include "content/common/content_export.h" |
| 30 #include "content/common/service_worker/service_worker_status_code.h" | 29 #include "content/common/service_worker/service_worker_status_code.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 52 // the sync registrations are removed. This class must be run on the IO | 51 // the sync registrations are removed. This class must be run on the IO |
| 53 // thread. The asynchronous methods are executed sequentially. | 52 // thread. The asynchronous methods are executed sequentially. |
| 54 class CONTENT_EXPORT BackgroundSyncManager | 53 class CONTENT_EXPORT BackgroundSyncManager |
| 55 : NON_EXPORTED_BASE(public ServiceWorkerContextObserver) { | 54 : NON_EXPORTED_BASE(public ServiceWorkerContextObserver) { |
| 56 public: | 55 public: |
| 57 using BoolCallback = base::Callback<void(bool)>; | 56 using BoolCallback = base::Callback<void(bool)>; |
| 58 using StatusCallback = base::Callback<void(BackgroundSyncStatus)>; | 57 using StatusCallback = base::Callback<void(BackgroundSyncStatus)>; |
| 59 using StatusAndRegistrationCallback = | 58 using StatusAndRegistrationCallback = |
| 60 base::Callback<void(BackgroundSyncStatus, | 59 base::Callback<void(BackgroundSyncStatus, |
| 61 std::unique_ptr<BackgroundSyncRegistration>)>; | 60 std::unique_ptr<BackgroundSyncRegistration>)>; |
| 62 using StatusAndRegistrationsCallback = base::Callback<void( | 61 using StatusAndRegistrationsCallback = |
| 63 BackgroundSyncStatus, | 62 base::Callback<void(BackgroundSyncStatus, |
| 64 std::unique_ptr<ScopedVector<BackgroundSyncRegistration>>)>; | 63 std::unique_ptr<std::vector< |
| 64 std::unique_ptr<BackgroundSyncRegistration>>>)>; |
| 65 | 65 |
| 66 static std::unique_ptr<BackgroundSyncManager> Create( | 66 static std::unique_ptr<BackgroundSyncManager> Create( |
| 67 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); | 67 scoped_refptr<ServiceWorkerContextWrapper> service_worker_context); |
| 68 ~BackgroundSyncManager() override; | 68 ~BackgroundSyncManager() override; |
| 69 | 69 |
| 70 // Stores the given background sync registration and adds it to the scheduling | 70 // Stores the given background sync registration and adds it to the scheduling |
| 71 // queue. It will overwrite an existing registration with the same tag unless | 71 // queue. It will overwrite an existing registration with the same tag unless |
| 72 // they're identical (save for the id). Calls |callback| with | 72 // they're identical (save for the id). Calls |callback| with |
| 73 // BACKGROUND_SYNC_STATUS_OK and the accepted registration on success. | 73 // BACKGROUND_SYNC_STATUS_OK and the accepted registration on success. |
| 74 // The accepted registration will have a unique id. It may also have altered | 74 // The accepted registration will have a unique id. It may also have altered |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 std::unique_ptr<base::Clock> clock_; | 305 std::unique_ptr<base::Clock> clock_; |
| 306 | 306 |
| 307 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; | 307 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; |
| 308 | 308 |
| 309 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); | 309 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); |
| 310 }; | 310 }; |
| 311 | 311 |
| 312 } // namespace content | 312 } // namespace content |
| 313 | 313 |
| 314 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ | 314 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ |
| OLD | NEW |