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

Side by Side Diff: extensions/browser/api/alarms/alarm_manager.h

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 | extensions/browser/api/alarms/alarm_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 EXTENSIONS_BROWSER_API_ALARMS_ALARM_MANAGER_H_ 5 #ifndef EXTENSIONS_BROWSER_API_ALARMS_ALARM_MANAGER_H_
6 #define EXTENSIONS_BROWSER_API_ALARMS_ALARM_MANAGER_H_ 6 #define EXTENSIONS_BROWSER_API_ALARMS_ALARM_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <queue> 9 #include <queue>
10 #include <string> 10 #include <string>
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 177
178 // Callback for when an alarm fires. 178 // Callback for when an alarm fires.
179 void OnAlarm(AlarmIterator iter); 179 void OnAlarm(AlarmIterator iter);
180 180
181 // Internal helper to add an alarm and start the timer with the given delay. 181 // Internal helper to add an alarm and start the timer with the given delay.
182 void AddAlarmImpl(const std::string& extension_id, const Alarm& alarm); 182 void AddAlarmImpl(const std::string& extension_id, const Alarm& alarm);
183 183
184 // Syncs our alarm data for the given extension to/from the state storage. 184 // Syncs our alarm data for the given extension to/from the state storage.
185 void WriteToStorage(const std::string& extension_id); 185 void WriteToStorage(const std::string& extension_id);
186 void ReadFromStorage(const std::string& extension_id, 186 void ReadFromStorage(const std::string& extension_id,
187 scoped_ptr<base::Value> value); 187 std::unique_ptr<base::Value> value);
188 188
189 // Set the timer to go off at the specified |time|, and set |next_poll_time| 189 // Set the timer to go off at the specified |time|, and set |next_poll_time|
190 // appropriately. 190 // appropriately.
191 void SetNextPollTime(const base::Time& time); 191 void SetNextPollTime(const base::Time& time);
192 192
193 // Schedules the next poll of alarms for when the next soonest alarm runs, 193 // Schedules the next poll of alarms for when the next soonest alarm runs,
194 // but not more often than the minimum granularity of all alarms. 194 // but not more often than the minimum granularity of all alarms.
195 void ScheduleNextPoll(); 195 void ScheduleNextPoll();
196 196
197 // Polls the alarms, running any that have elapsed. After running them and 197 // Polls the alarms, running any that have elapsed. After running them and
198 // rescheduling repeating alarms, schedule the next poll. 198 // rescheduling repeating alarms, schedule the next poll.
199 void PollAlarms(); 199 void PollAlarms();
200 200
201 // Executes |action| for given extension, making sure that the extension's 201 // Executes |action| for given extension, making sure that the extension's
202 // alarm data has been synced from the storage. 202 // alarm data has been synced from the storage.
203 void RunWhenReady(const std::string& extension_id, const ReadyAction& action); 203 void RunWhenReady(const std::string& extension_id, const ReadyAction& action);
204 204
205 // ExtensionRegistryObserver implementation. 205 // ExtensionRegistryObserver implementation.
206 void OnExtensionLoaded(content::BrowserContext* browser_context, 206 void OnExtensionLoaded(content::BrowserContext* browser_context,
207 const Extension* extension) override; 207 const Extension* extension) override;
208 void OnExtensionUninstalled(content::BrowserContext* browser_context, 208 void OnExtensionUninstalled(content::BrowserContext* browser_context,
209 const Extension* extension, 209 const Extension* extension,
210 extensions::UninstallReason reason) override; 210 extensions::UninstallReason reason) override;
211 211
212 // BrowserContextKeyedAPI implementation. 212 // BrowserContextKeyedAPI implementation.
213 static const char* service_name() { return "AlarmManager"; } 213 static const char* service_name() { return "AlarmManager"; }
214 static const bool kServiceHasOwnInstanceInIncognito = true; 214 static const bool kServiceHasOwnInstanceInIncognito = true;
215 215
216 content::BrowserContext* const browser_context_; 216 content::BrowserContext* const browser_context_;
217 scoped_ptr<base::Clock> clock_; 217 std::unique_ptr<base::Clock> clock_;
218 scoped_ptr<Delegate> delegate_; 218 std::unique_ptr<Delegate> delegate_;
219 219
220 // Listen to extension load notifications. 220 // Listen to extension load notifications.
221 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> 221 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
222 extension_registry_observer_; 222 extension_registry_observer_;
223 223
224 // The timer for this alarm manager. 224 // The timer for this alarm manager.
225 base::OneShotTimer timer_; 225 base::OneShotTimer timer_;
226 226
227 // A map of our pending alarms, per extension. 227 // A map of our pending alarms, per extension.
228 // Invariant: None of the AlarmLists are empty. 228 // Invariant: None of the AlarmLists are empty.
229 AlarmMap alarms_; 229 AlarmMap alarms_;
230 230
231 // A map of actions waiting for alarm data to be synced from storage, per 231 // A map of actions waiting for alarm data to be synced from storage, per
232 // extension. 232 // extension.
233 ReadyMap ready_actions_; 233 ReadyMap ready_actions_;
234 234
235 // The previous time that alarms were run. 235 // The previous time that alarms were run.
236 base::Time last_poll_time_; 236 base::Time last_poll_time_;
237 237
238 // Next poll's time. 238 // Next poll's time.
239 base::Time next_poll_time_; 239 base::Time next_poll_time_;
240 240
241 DISALLOW_COPY_AND_ASSIGN(AlarmManager); 241 DISALLOW_COPY_AND_ASSIGN(AlarmManager);
242 }; 242 };
243 243
244 } // namespace extensions 244 } // namespace extensions
245 245
246 #endif // EXTENSIONS_BROWSER_API_ALARMS_ALARM_MANAGER_H_ 246 #endif // EXTENSIONS_BROWSER_API_ALARMS_ALARM_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | extensions/browser/api/alarms/alarm_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698