OLD | NEW |
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 26 matching lines...) Expand all Loading... |
37 base::Time now); | 37 base::Time now); |
38 ~Alarm(); | 38 ~Alarm(); |
39 | 39 |
40 linked_ptr<api::alarms::Alarm> js_alarm; | 40 linked_ptr<api::alarms::Alarm> js_alarm; |
41 // The granularity isn't exposed to the extension's javascript, but we poll at | 41 // The granularity isn't exposed to the extension's javascript, but we poll at |
42 // least as often as the shortest alarm's granularity. It's initialized as | 42 // least as often as the shortest alarm's granularity. It's initialized as |
43 // the relative delay requested in creation, even if creation uses an absolute | 43 // the relative delay requested in creation, even if creation uses an absolute |
44 // time. This will always be at least as large as the min_granularity | 44 // time. This will always be at least as large as the min_granularity |
45 // constructor argument. | 45 // constructor argument. |
46 base::TimeDelta granularity; | 46 base::TimeDelta granularity; |
| 47 // The minimum granularity is the minimum allowed polling rate. This stops |
| 48 // alarms from polling too often. |
| 49 base::TimeDelta minimum_granularity; |
47 }; | 50 }; |
48 | 51 |
49 // Manages the currently pending alarms for every extension in a profile. | 52 // Manages the currently pending alarms for every extension in a profile. |
50 // There is one manager per virtual Profile. | 53 // There is one manager per virtual Profile. |
51 class AlarmManager | 54 class AlarmManager |
52 : public ProfileKeyedAPI, | 55 : public ProfileKeyedAPI, |
53 public content::NotificationObserver, | 56 public content::NotificationObserver, |
54 public base::SupportsWeakPtr<AlarmManager> { | 57 public base::SupportsWeakPtr<AlarmManager> { |
55 public: | 58 public: |
56 typedef std::vector<Alarm> AlarmList; | 59 typedef std::vector<Alarm> AlarmList; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 223 |
221 // Next poll's time. Used only by unit tests. | 224 // Next poll's time. Used only by unit tests. |
222 base::Time test_next_poll_time_; | 225 base::Time test_next_poll_time_; |
223 | 226 |
224 DISALLOW_COPY_AND_ASSIGN(AlarmManager); | 227 DISALLOW_COPY_AND_ASSIGN(AlarmManager); |
225 }; | 228 }; |
226 | 229 |
227 } // namespace extensions | 230 } // namespace extensions |
228 | 231 |
229 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__ | 232 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__ |
OLD | NEW |