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

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

Issue 145353013: Do not reschedule all alarms when adding a new alarm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Yoyo's Created 6 years, 10 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 | chrome/browser/extensions/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 CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__ 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__ 6 #define CHROME_BROWSER_EXTENSIONS_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 // Internal helper to add an alarm and start the timer with the given delay. 178 // Internal helper to add an alarm and start the timer with the given delay.
179 void AddAlarmImpl(const std::string& extension_id, 179 void AddAlarmImpl(const std::string& extension_id,
180 const Alarm& alarm); 180 const Alarm& alarm);
181 181
182 // Syncs our alarm data for the given extension to/from the state storage. 182 // Syncs our alarm data for the given extension to/from the state storage.
183 void WriteToStorage(const std::string& extension_id); 183 void WriteToStorage(const std::string& extension_id);
184 void ReadFromStorage(const std::string& extension_id, 184 void ReadFromStorage(const std::string& extension_id,
185 scoped_ptr<base::Value> value); 185 scoped_ptr<base::Value> value);
186 186
187 // Set the timer to go off at the specified |time|, and set |next_poll_time|
188 // appropriately.
189 void SetNextPollTime(const base::Time& time);
190
187 // Schedules the next poll of alarms for when the next soonest alarm runs, 191 // Schedules the next poll of alarms for when the next soonest alarm runs,
188 // but not more often than the minimum granularity of all alarms. 192 // but not more often than the minimum granularity of all alarms.
189 void ScheduleNextPoll(); 193 void ScheduleNextPoll();
190 194
191 // Polls the alarms, running any that have elapsed. After running them and 195 // Polls the alarms, running any that have elapsed. After running them and
192 // rescheduling repeating alarms, schedule the next poll. 196 // rescheduling repeating alarms, schedule the next poll.
193 void PollAlarms(); 197 void PollAlarms();
194 198
195 // Executes |action| for given extension, making sure that the extension's 199 // Executes |action| for given extension, making sure that the extension's
196 // alarm data has been synced from the storage. 200 // alarm data has been synced from the storage.
(...skipping 22 matching lines...) Expand all
219 // Invariant: None of the AlarmLists are empty. 223 // Invariant: None of the AlarmLists are empty.
220 AlarmMap alarms_; 224 AlarmMap alarms_;
221 225
222 // A map of actions waiting for alarm data to be synced from storage, per 226 // A map of actions waiting for alarm data to be synced from storage, per
223 // extension. 227 // extension.
224 ReadyMap ready_actions_; 228 ReadyMap ready_actions_;
225 229
226 // The previous time that alarms were run. 230 // The previous time that alarms were run.
227 base::Time last_poll_time_; 231 base::Time last_poll_time_;
228 232
229 // Next poll's time. Used only by unit tests. 233 // Next poll's time.
230 base::Time test_next_poll_time_; 234 base::Time next_poll_time_;
231 235
232 DISALLOW_COPY_AND_ASSIGN(AlarmManager); 236 DISALLOW_COPY_AND_ASSIGN(AlarmManager);
233 }; 237 };
234 238
235 } // namespace extensions 239 } // namespace extensions
236 240
237 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__ 241 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/alarms/alarm_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698