| 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 <string> | 8 #include <string> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 | 52 |
| 53 class Delegate { | 53 class Delegate { |
| 54 public: | 54 public: |
| 55 virtual ~Delegate() {} | 55 virtual ~Delegate() {} |
| 56 // Called when an alarm fires. | 56 // Called when an alarm fires. |
| 57 virtual void OnAlarm(const std::string& extension_id, | 57 virtual void OnAlarm(const std::string& extension_id, |
| 58 const Alarm& alarm) = 0; | 58 const Alarm& alarm) = 0; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // 'now' is usually &base::Time::Now. | 61 // 'now' is usually &base::Time::Now. |
| 62 explicit AlarmManager(Profile* profile, TimeProvider now); | 62 AlarmManager(Profile* profile, TimeProvider now); |
| 63 virtual ~AlarmManager(); | 63 virtual ~AlarmManager(); |
| 64 | 64 |
| 65 // Override the default delegate. Callee assumes onwership. Used for testing. | 65 // Override the default delegate. Callee assumes onwership. Used for testing. |
| 66 void set_delegate(Delegate* delegate) { delegate_.reset(delegate); } | 66 void set_delegate(Delegate* delegate) { delegate_.reset(delegate); } |
| 67 | 67 |
| 68 // Adds |alarm| for the given extension, and starts the timer. | 68 // Adds |alarm| for the given extension, and starts the timer. |
| 69 void AddAlarm(const std::string& extension_id, | 69 void AddAlarm(const std::string& extension_id, |
| 70 const Alarm& alarm); | 70 const Alarm& alarm); |
| 71 | 71 |
| 72 // Returns the alarm with the given name, or NULL if none exists. | 72 // Returns the alarm with the given name, or NULL if none exists. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 // The previous and next time that alarms were and will be run. | 150 // The previous and next time that alarms were and will be run. |
| 151 base::Time last_poll_time_; | 151 base::Time last_poll_time_; |
| 152 base::Time next_poll_time_; | 152 base::Time next_poll_time_; |
| 153 | 153 |
| 154 DISALLOW_COPY_AND_ASSIGN(AlarmManager); | 154 DISALLOW_COPY_AND_ASSIGN(AlarmManager); |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 } // namespace extensions | 157 } // namespace extensions |
| 158 | 158 |
| 159 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__ | 159 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARM_MANAGER_H__ |
| OLD | NEW |