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

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

Issue 1774603002: [BackgroundSync] Remove RegistrationKey (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_reg_handle
Patch Set: Rebase Created 4 years, 9 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
« no previous file with comments | « no previous file | content/browser/background_sync/background_sync_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 const ServiceWorkerVersion::StatusCallback& callback); 121 const ServiceWorkerVersion::StatusCallback& callback);
122 virtual void ScheduleDelayedTask(const base::Closure& callback, 122 virtual void ScheduleDelayedTask(const base::Closure& callback,
123 base::TimeDelta delay); 123 base::TimeDelta delay);
124 virtual void HasMainFrameProviderHost(const GURL& origin, 124 virtual void HasMainFrameProviderHost(const GURL& origin,
125 const BoolCallback& callback); 125 const BoolCallback& callback);
126 126
127 private: 127 private:
128 friend class TestBackgroundSyncManager; 128 friend class TestBackgroundSyncManager;
129 friend class BackgroundSyncManagerTest; 129 friend class BackgroundSyncManagerTest;
130 130
131 class RegistrationKey {
132 public:
133 explicit RegistrationKey(const BackgroundSyncRegistration& registration);
134 explicit RegistrationKey(const BackgroundSyncRegistrationOptions& options);
135 RegistrationKey(const std::string& tag);
136 RegistrationKey(const RegistrationKey& other) = default;
137 RegistrationKey& operator=(const RegistrationKey& other) = default;
138
139 bool operator<(const RegistrationKey& rhs) const {
140 return value_ < rhs.value_;
141 }
142
143 private:
144 std::string value_;
145 };
146
147 struct BackgroundSyncRegistrations { 131 struct BackgroundSyncRegistrations {
148 using RegistrationMap = 132 using RegistrationMap = std::map<std::string, BackgroundSyncRegistration>;
149 std::map<RegistrationKey, BackgroundSyncRegistration>;
150 133
151 BackgroundSyncRegistrations(); 134 BackgroundSyncRegistrations();
152 BackgroundSyncRegistrations(const BackgroundSyncRegistrations& other); 135 BackgroundSyncRegistrations(const BackgroundSyncRegistrations& other);
153 ~BackgroundSyncRegistrations(); 136 ~BackgroundSyncRegistrations();
154 137
155 RegistrationMap registration_map; 138 RegistrationMap registration_map;
156 BackgroundSyncRegistration::RegistrationId next_id; 139 BackgroundSyncRegistration::RegistrationId next_id;
157 GURL origin; 140 GURL origin;
158 }; 141 };
159 142
(...skipping 11 matching lines...) Expand all
171 void DisableAndClearDidGetRegistrations( 154 void DisableAndClearDidGetRegistrations(
172 const base::Closure& callback, 155 const base::Closure& callback,
173 const std::vector<std::pair<int64_t, std::string>>& user_data, 156 const std::vector<std::pair<int64_t, std::string>>& user_data,
174 ServiceWorkerStatusCode status); 157 ServiceWorkerStatusCode status);
175 void DisableAndClearManagerClearedOne(const base::Closure& barrier_closure, 158 void DisableAndClearManagerClearedOne(const base::Closure& barrier_closure,
176 ServiceWorkerStatusCode status); 159 ServiceWorkerStatusCode status);
177 160
178 // Returns the existing registration or nullptr if it cannot be found. 161 // Returns the existing registration or nullptr if it cannot be found.
179 BackgroundSyncRegistration* LookupActiveRegistration( 162 BackgroundSyncRegistration* LookupActiveRegistration(
180 int64_t sw_registration_id, 163 int64_t sw_registration_id,
181 const RegistrationKey& registration_key); 164 const std::string& tag);
182 165
183 // Write all registrations for a given |sw_registration_id| to persistent 166 // Write all registrations for a given |sw_registration_id| to persistent
184 // storage. 167 // storage.
185 void StoreRegistrations(int64_t sw_registration_id, 168 void StoreRegistrations(int64_t sw_registration_id,
186 const ServiceWorkerStorage::StatusCallback& callback); 169 const ServiceWorkerStorage::StatusCallback& callback);
187 170
188 // Removes the active registration if it is in the map. 171 // Removes the active registration if it is in the map.
189 void RemoveActiveRegistration(int64_t sw_registration_id, 172 void RemoveActiveRegistration(int64_t sw_registration_id,
190 const RegistrationKey& registration_key); 173 const std::string& tag);
191 174
192 void AddActiveRegistration( 175 void AddActiveRegistration(
193 int64_t sw_registration_id, 176 int64_t sw_registration_id,
194 const GURL& origin, 177 const GURL& origin,
195 const BackgroundSyncRegistration& sync_registration); 178 const BackgroundSyncRegistration& sync_registration);
196 179
197 void InitImpl(const base::Closure& callback); 180 void InitImpl(const base::Closure& callback);
198 void InitDidGetControllerParameters( 181 void InitDidGetControllerParameters(
199 const base::Closure& callback, 182 const base::Closure& callback,
200 scoped_ptr<BackgroundSyncParameters> parameters); 183 scoped_ptr<BackgroundSyncParameters> parameters);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 // Assumes that all registrations in the pending state are not currently ready 219 // Assumes that all registrations in the pending state are not currently ready
237 // to fire. Therefore this should not be called directly and should only be 220 // to fire. Therefore this should not be called directly and should only be
238 // called by FireReadyEvents. 221 // called by FireReadyEvents.
239 void RunInBackgroundIfNecessary(); 222 void RunInBackgroundIfNecessary();
240 223
241 // FireReadyEvents scans the list of available events and fires those that are 224 // FireReadyEvents scans the list of available events and fires those that are
242 // ready to fire. For those that can't yet be fired, wakeup alarms are set. 225 // ready to fire. For those that can't yet be fired, wakeup alarms are set.
243 void FireReadyEvents(); 226 void FireReadyEvents();
244 void FireReadyEventsImpl(const base::Closure& callback); 227 void FireReadyEventsImpl(const base::Closure& callback);
245 void FireReadyEventsDidFindRegistration( 228 void FireReadyEventsDidFindRegistration(
246 const RegistrationKey& registration_key, 229 const std::string& tag,
247 BackgroundSyncRegistration::RegistrationId registration_id, 230 BackgroundSyncRegistration::RegistrationId registration_id,
248 const base::Closure& event_fired_callback, 231 const base::Closure& event_fired_callback,
249 const base::Closure& event_completed_callback, 232 const base::Closure& event_completed_callback,
250 ServiceWorkerStatusCode service_worker_status, 233 ServiceWorkerStatusCode service_worker_status,
251 const scoped_refptr<ServiceWorkerRegistration>& 234 const scoped_refptr<ServiceWorkerRegistration>&
252 service_worker_registration); 235 service_worker_registration);
253 void FireReadyEventsAllEventsFiring(const base::Closure& callback); 236 void FireReadyEventsAllEventsFiring(const base::Closure& callback);
254 237
255 // Called when a sync event has completed. 238 // Called when a sync event has completed.
256 void EventComplete(const scoped_refptr<ServiceWorkerRegistration>& 239 void EventComplete(const scoped_refptr<ServiceWorkerRegistration>&
257 service_worker_registration, 240 service_worker_registration,
258 int64_t service_worker_id, 241 int64_t service_worker_id,
259 const RegistrationKey& registration_key, 242 const std::string& tag,
260 const base::Closure& callback, 243 const base::Closure& callback,
261 ServiceWorkerStatusCode status_code); 244 ServiceWorkerStatusCode status_code);
262 void EventCompleteImpl(int64_t service_worker_id, 245 void EventCompleteImpl(int64_t service_worker_id,
263 const RegistrationKey& registration_key, 246 const std::string& tag,
264 ServiceWorkerStatusCode status_code, 247 ServiceWorkerStatusCode status_code,
265 const base::Closure& callback); 248 const base::Closure& callback);
266 void EventCompleteDidStore(int64_t service_worker_id, 249 void EventCompleteDidStore(int64_t service_worker_id,
267 const base::Closure& callback, 250 const base::Closure& callback,
268 ServiceWorkerStatusCode status_code); 251 ServiceWorkerStatusCode status_code);
269 252
270 // Called when all sync events have completed. 253 // Called when all sync events have completed.
271 static void OnAllSyncEventsCompleted(const base::TimeTicks& start_time, 254 static void OnAllSyncEventsCompleted(const base::TimeTicks& start_time,
272 int number_of_batched_sync_events); 255 int number_of_batched_sync_events);
273 256
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 scoped_ptr<base::Clock> clock_; 307 scoped_ptr<base::Clock> clock_;
325 308
326 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_; 309 base::WeakPtrFactory<BackgroundSyncManager> weak_ptr_factory_;
327 310
328 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager); 311 DISALLOW_COPY_AND_ASSIGN(BackgroundSyncManager);
329 }; 312 };
330 313
331 } // namespace content 314 } // namespace content
332 315
333 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_ 316 #endif // CONTENT_BROWSER_BACKGROUND_SYNC_BACKGROUND_SYNC_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/background_sync/background_sync_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698