Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(275)

Side by Side Diff: content/browser/background_sync/background_sync_manager.h

Issue 1614063002: [BackgroundSync Cleanup] Remove periodic sync code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@purge_power
Patch Set: Address comments from PS3 Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 base::Callback<void(BackgroundSyncStatus, BackgroundSyncState)>; 57 base::Callback<void(BackgroundSyncStatus, BackgroundSyncState)>;
58 using StatusAndRegistrationsCallback = base::Callback<void( 58 using StatusAndRegistrationsCallback = base::Callback<void(
59 BackgroundSyncStatus, 59 BackgroundSyncStatus,
60 scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>>)>; 60 scoped_ptr<ScopedVector<BackgroundSyncRegistrationHandle>>)>;
61 61
62 static scoped_ptr<BackgroundSyncManager> Create( 62 static scoped_ptr<BackgroundSyncManager> Create(
63 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context); 63 const scoped_refptr<ServiceWorkerContextWrapper>& service_worker_context);
64 ~BackgroundSyncManager() override; 64 ~BackgroundSyncManager() override;
65 65
66 // Stores the given background sync registration and adds it to the scheduling 66 // Stores the given background sync registration and adds it to the scheduling
67 // queue. It will overwrite an existing registration with the same tag and 67 // queue. It will overwrite an existing registration with the same tag unless
68 // periodicity unless they're identical (save for the id). Calls |callback| 68 // they're identical (save for the id). Calls |callback| with
69 // with BACKGROUND_SYNC_STATUS_OK and the accepted registration on success. 69 // BACKGROUND_SYNC_STATUS_OK and the accepted registration on success.
70 // The accepted registration will have a unique id. It may also have altered 70 // The accepted registration will have a unique id. It may also have altered
71 // parameters if the user or UA chose different parameters than those 71 // parameters if the user or UA chose different parameters than those
72 // supplied. 72 // supplied.
73 void Register(int64_t sw_registration_id, 73 void Register(int64_t sw_registration_id,
74 const BackgroundSyncRegistrationOptions& options, 74 const BackgroundSyncRegistrationOptions& options,
75 bool requested_from_service_worker, 75 bool requested_from_service_worker,
76 const StatusAndRegistrationCallback& callback); 76 const StatusAndRegistrationCallback& callback);
77 77
78 // Finds the background sync registration associated with 78 // Finds the background sync registration associated with
79 // |sw_registration_id|, periodicity |periodicity|, and tag 79 // |sw_registration_id|, and tag |sync_registration_tag|. Calls |callback|
80 // |sync_registration_tag|. Calls |callback| with 80 // with BACKGROUND_SYNC_STATUS_NOT_FOUND if it doesn't exist. Calls |callback|
81 // BACKGROUND_SYNC_STATUS_NOT_FOUND if it doesn't exist. Calls |callback| with 81 // with BACKGROUND_SYNC_STATUS_OK on success. If the callback's status is not
82 // BACKGROUND_SYNC_STATUS_OK on success. If the callback's status 82 // BACKGROUND_SYNC_STATUS_OK then the callback's RegistrationHandle will be
83 // is not BACKGROUND_SYNC_STATUS_OK then the callback's RegistrationHandle 83 // nullptr.
84 // will be nullptr.
85 void GetRegistration(int64_t sw_registration_id, 84 void GetRegistration(int64_t sw_registration_id,
86 const std::string& sync_registration_tag, 85 const std::string& sync_registration_tag,
87 SyncPeriodicity periodicity,
88 const StatusAndRegistrationCallback& callback); 86 const StatusAndRegistrationCallback& callback);
89 87
90 // Finds the background sync registrations associated with 88 // Finds the background sync registrations associated with
91 // |sw_registration_id| and periodicity |periodicity|. Calls 89 // |sw_registration_id|. Calls |callback| with BACKGROUND_SYNC_STATUS_OK on
92 // |callback| with BACKGROUND_SYNC_STATUS_OK on success. 90 // success.
93 void GetRegistrations(int64_t sw_registration_id, 91 void GetRegistrations(int64_t sw_registration_id,
94 SyncPeriodicity periodicity,
95 const StatusAndRegistrationsCallback& callback); 92 const StatusAndRegistrationsCallback& callback);
96 93
97 // Given a HandleId |handle_id|, return a new handle for the same 94 // Given a HandleId |handle_id|, return a new handle for the same
98 // registration. 95 // registration.
99 scoped_ptr<BackgroundSyncRegistrationHandle> DuplicateRegistrationHandle( 96 scoped_ptr<BackgroundSyncRegistrationHandle> DuplicateRegistrationHandle(
100 BackgroundSyncRegistrationHandle::HandleId handle_id); 97 BackgroundSyncRegistrationHandle::HandleId handle_id);
101 98
102 // ServiceWorkerContextObserver overrides. 99 // ServiceWorkerContextObserver overrides.
103 void OnRegistrationDeleted(int64_t sw_registration_id, 100 void OnRegistrationDeleted(int64_t sw_registration_id,
104 const GURL& pattern) override; 101 const GURL& pattern) override;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 152
156 private: 153 private:
157 friend class TestBackgroundSyncManager; 154 friend class TestBackgroundSyncManager;
158 friend class BackgroundSyncManagerTest; 155 friend class BackgroundSyncManagerTest;
159 friend class BackgroundSyncRegistrationHandle; 156 friend class BackgroundSyncRegistrationHandle;
160 157
161 class RegistrationKey { 158 class RegistrationKey {
162 public: 159 public:
163 explicit RegistrationKey(const BackgroundSyncRegistration& registration); 160 explicit RegistrationKey(const BackgroundSyncRegistration& registration);
164 explicit RegistrationKey(const BackgroundSyncRegistrationOptions& options); 161 explicit RegistrationKey(const BackgroundSyncRegistrationOptions& options);
165 RegistrationKey(const std::string& tag, SyncPeriodicity periodicity); 162 RegistrationKey(const std::string& tag);
166 RegistrationKey(const RegistrationKey& other) = default; 163 RegistrationKey(const RegistrationKey& other) = default;
167 RegistrationKey& operator=(const RegistrationKey& other) = default; 164 RegistrationKey& operator=(const RegistrationKey& other) = default;
168 165
169 bool operator<(const RegistrationKey& rhs) const { 166 bool operator<(const RegistrationKey& rhs) const {
170 return value_ < rhs.value_; 167 return value_ < rhs.value_;
171 } 168 }
172 169
173 private: 170 private:
174 std::string value_; 171 std::string value_;
175 }; 172 };
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 bool has_main_frame_client); 256 bool has_main_frame_client);
260 void RegisterImpl(int64_t sw_registration_id, 257 void RegisterImpl(int64_t sw_registration_id,
261 const BackgroundSyncRegistrationOptions& options, 258 const BackgroundSyncRegistrationOptions& options,
262 const StatusAndRegistrationCallback& callback); 259 const StatusAndRegistrationCallback& callback);
263 void RegisterDidStore( 260 void RegisterDidStore(
264 int64_t sw_registration_id, 261 int64_t sw_registration_id,
265 const scoped_refptr<RefCountedRegistration>& new_registration_ref, 262 const scoped_refptr<RefCountedRegistration>& new_registration_ref,
266 const StatusAndRegistrationCallback& callback, 263 const StatusAndRegistrationCallback& callback,
267 ServiceWorkerStatusCode status); 264 ServiceWorkerStatusCode status);
268 265
269 // Removes the background sync with periodicity |periodicity| and id 266 // Removes the background sync with id |sync_registration_id|. Calls
270 // |sync_registration_id|. Calls |callback| with 267 // |callback| with BACKGROUND_SYNC_STATUS_NOT_FOUND if no match is found.
271 // BACKGROUND_SYNC_STATUS_NOT_FOUND if no match is found. Calls |callback| 268 // Calls |callback| with BACKGROUND_SYNC_STATUS_OK on success.
272 // with BACKGROUND_SYNC_STATUS_OK on success.
273 void Unregister(int64_t sw_registration_id, 269 void Unregister(int64_t sw_registration_id,
274 BackgroundSyncRegistrationHandle::HandleId handle_id, 270 BackgroundSyncRegistrationHandle::HandleId handle_id,
275 const StatusCallback& callback); 271 const StatusCallback& callback);
276 void UnregisterImpl( 272 void UnregisterImpl(
277 int64_t sw_registration_id, 273 int64_t sw_registration_id,
278 const RegistrationKey& key, 274 const RegistrationKey& key,
279 BackgroundSyncRegistration::RegistrationId sync_registration_id, 275 BackgroundSyncRegistration::RegistrationId sync_registration_id,
280 SyncPeriodicity periodicity,
281 const StatusCallback& callback); 276 const StatusCallback& callback);
282 void UnregisterDidStore(int64_t sw_registration_id, 277 void UnregisterDidStore(int64_t sw_registration_id,
283 SyncPeriodicity periodicity,
284 const StatusCallback& callback, 278 const StatusCallback& callback,
285 ServiceWorkerStatusCode status); 279 ServiceWorkerStatusCode status);
286 280
287 // NotifyWhenFinished and its callbacks. See 281 // NotifyWhenFinished and its callbacks. See
288 // BackgroundSyncRegistrationHandle::NotifyWhenFinished for detailed 282 // BackgroundSyncRegistrationHandle::NotifyWhenFinished for detailed
289 // documentation. 283 // documentation.
290 void NotifyWhenFinished(BackgroundSyncRegistrationHandle::HandleId handle_id, 284 void NotifyWhenFinished(BackgroundSyncRegistrationHandle::HandleId handle_id,
291 const StatusAndStateCallback& callback); 285 const StatusAndStateCallback& callback);
292 void NotifyWhenFinishedImpl( 286 void NotifyWhenFinishedImpl(
293 scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle, 287 scoped_ptr<BackgroundSyncRegistrationHandle> registration_handle,
294 const StatusAndStateCallback& callback); 288 const StatusAndStateCallback& callback);
295 void NotifyWhenFinishedInvokeCallback(const StatusAndStateCallback& callback, 289 void NotifyWhenFinishedInvokeCallback(const StatusAndStateCallback& callback,
296 BackgroundSyncState status); 290 BackgroundSyncState status);
297 291
298 // GetRegistration callbacks 292 // GetRegistration callbacks
299 void GetRegistrationImpl(int64_t sw_registration_id, 293 void GetRegistrationImpl(int64_t sw_registration_id,
300 const RegistrationKey& registration_key, 294 const RegistrationKey& registration_key,
301 const StatusAndRegistrationCallback& callback); 295 const StatusAndRegistrationCallback& callback);
302 296
303 // GetRegistrations callbacks 297 // GetRegistrations callbacks
304 void GetRegistrationsImpl(int64_t sw_registration_id, 298 void GetRegistrationsImpl(int64_t sw_registration_id,
305 SyncPeriodicity periodicity,
306 const StatusAndRegistrationsCallback& callback); 299 const StatusAndRegistrationsCallback& callback);
307 300
308 bool AreOptionConditionsMet(const BackgroundSyncRegistrationOptions& options); 301 bool AreOptionConditionsMet(const BackgroundSyncRegistrationOptions& options);
309 bool IsRegistrationReadyToFire( 302 bool IsRegistrationReadyToFire(
310 const BackgroundSyncRegistration& registration); 303 const BackgroundSyncRegistration& registration);
311 304
312 // Determines if the browser needs to be able to run in the background (e.g., 305 // Determines if the browser needs to be able to run in the background (e.g.,
313 // to run a pending registration or verify that a firing registration 306 // to run a pending registration or verify that a firing registration
314 // completed). If background processing is required it calls out to the 307 // completed). If background processing is required it calls out to the
315 // BackgroundSyncController to enable it. 308 // BackgroundSyncController to enable it.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 scoped_ptr<base::Clock> clock_; 404 scoped_ptr<base::Clock> clock_;
412 405
413 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; 406 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_;
414 407
415 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); 408 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager);
416 }; 409 };
417 410
418 } // namespace content 411 } // namespace content
419 412
420 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ 413 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698