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/scoped_vector.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "content/browser/background_sync/background_sync.pb.h" | 17 #include "content/browser/background_sync/background_sync.pb.h" |
18 #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" | 19 #include "content/browser/background_sync/background_sync_registration_handle.h" |
20 #include "content/browser/background_sync/background_sync_status.h" | 20 #include "content/browser/background_sync/background_sync_status.h" |
21 #include "content/browser/cache_storage/cache_storage_scheduler.h" | 21 #include "content/browser/cache_storage/cache_storage_scheduler.h" |
22 #include "content/browser/service_worker/service_worker_context_observer.h" | 22 #include "content/browser/service_worker/service_worker_context_observer.h" |
23 #include "content/browser/service_worker/service_worker_storage.h" | 23 #include "content/browser/service_worker/service_worker_storage.h" |
24 #include "content/common/background_sync_service.mojom.h" | |
24 #include "content/common/content_export.h" | 25 #include "content/common/content_export.h" |
25 #include "content/common/service_worker/service_worker_status_code.h" | 26 #include "content/common/service_worker/service_worker_status_code.h" |
26 #include "url/gurl.h" | 27 #include "url/gurl.h" |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 | 30 |
30 class BackgroundSyncNetworkObserver; | 31 class BackgroundSyncNetworkObserver; |
31 class BackgroundSyncPowerObserver; | 32 class BackgroundSyncPowerObserver; |
32 class ServiceWorkerContextWrapper; | 33 class ServiceWorkerContextWrapper; |
33 | 34 |
(...skipping 12 matching lines...) Expand all Loading... | |
46 // registered events. | 47 // registered events. |
47 // TODO(jkarlin): Keep the browser alive if "Let Google Chrome Run in the | 48 // TODO(jkarlin): Keep the browser alive if "Let Google Chrome Run in the |
48 // Background" is true and a sync is registered. | 49 // Background" is true and a sync is registered. |
49 class CONTENT_EXPORT BackgroundSyncManager | 50 class CONTENT_EXPORT BackgroundSyncManager |
50 : NON_EXPORTED_BASE(public ServiceWorkerContextObserver) { | 51 : NON_EXPORTED_BASE(public ServiceWorkerContextObserver) { |
51 public: | 52 public: |
52 using StatusCallback = base::Callback<void(BackgroundSyncStatus)>; | 53 using StatusCallback = base::Callback<void(BackgroundSyncStatus)>; |
53 using StatusAndRegistrationCallback = | 54 using StatusAndRegistrationCallback = |
54 base::Callback<void(BackgroundSyncStatus, | 55 base::Callback<void(BackgroundSyncStatus, |
55 scoped_ptr<BackgroundSyncRegistrationHandle>)>; | 56 scoped_ptr<BackgroundSyncRegistrationHandle>)>; |
57 using StatusAndStateCallback = | |
58 base::Callback<void(BackgroundSyncStatus, BackgroundSyncState)>; | |
56 using StatusAndRegistrationsCallback = base::Callback<void( | 59 using StatusAndRegistrationsCallback = base::Callback<void( |
57 BackgroundSyncStatus, | 60 BackgroundSyncStatus, |
58 scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>>)>; | 61 scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>>)>; |
59 | 62 |
60 static scoped_ptr<BackgroundSyncManager> Create( | 63 static scoped_ptr<BackgroundSyncManager> Create( |
61 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context); | 64 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context); |
62 ~BackgroundSyncManager() override; | 65 ~BackgroundSyncManager() override; |
63 | 66 |
64 // 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 |
65 // 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 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
235 int64 sw_registration_id, | 238 int64 sw_registration_id, |
236 const RegistrationKey& key, | 239 const RegistrationKey& key, |
237 BackgroundSyncRegistration::RegistrationId sync_registration_id, | 240 BackgroundSyncRegistration::RegistrationId sync_registration_id, |
238 SyncPeriodicity periodicity, | 241 SyncPeriodicity periodicity, |
239 const StatusCallback& callback); | 242 const StatusCallback& callback); |
240 void UnregisterDidStore(int64 sw_registration_id, | 243 void UnregisterDidStore(int64 sw_registration_id, |
241 SyncPeriodicity periodicity, | 244 SyncPeriodicity periodicity, |
242 const StatusCallback& callback, | 245 const StatusCallback& callback, |
243 ServiceWorkerStatusCode status); | 246 ServiceWorkerStatusCode status); |
244 | 247 |
248 // NotifyWhenDone and its callbacks. See | |
249 // BackgroundSyncRegistrationHandle::NotifyWhenDone for detailed | |
michaeln
2015/09/17 21:44:12
this ptr to the doc comments was very helpful
jkarlin
2015/09/18 12:03:19
Acknowledged.
| |
250 // documentation. | |
251 void NotifyWhenDone(BackgroundSyncRegistrationHandle::HandleId handle_id, | |
252 const StatusAndStateCallback& callback); | |
253 void NotifyWhenDoneImpl( | |
254 scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle, | |
255 const StatusAndStateCallback& callback); | |
256 void NotifyWhenDoneDidFinish(const StatusAndStateCallback& callback, | |
257 BackgroundSyncState status); | |
258 | |
245 // GetRegistration callbacks | 259 // GetRegistration callbacks |
246 void GetRegistrationImpl(int64 sw_registration_id, | 260 void GetRegistrationImpl(int64 sw_registration_id, |
247 const RegistrationKey& registration_key, | 261 const RegistrationKey& registration_key, |
248 const StatusAndRegistrationCallback& callback); | 262 const StatusAndRegistrationCallback& callback); |
249 | 263 |
250 // GetRegistrations callbacks | 264 // GetRegistrations callbacks |
251 void GetRegistrationsImpl(int64 sw_registration_id, | 265 void GetRegistrationsImpl(int64 sw_registration_id, |
252 SyncPeriodicity periodicity, | 266 SyncPeriodicity periodicity, |
253 const StatusAndRegistrationsCallback& callback); | 267 const StatusAndRegistrationsCallback& callback); |
254 | 268 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
339 registration_handle_ids_; | 353 registration_handle_ids_; |
340 | 354 |
341 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; | 355 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; |
342 | 356 |
343 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); | 357 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); |
344 }; | 358 }; |
345 | 359 |
346 } // namespace content | 360 } // namespace content |
347 | 361 |
348 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ | 362 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ |
OLD | NEW |