OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__ | |
6 #define CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "chrome/browser/extensions/chrome_extension_function.h" | |
11 | |
12 namespace base { | |
13 class Clock; | |
14 } // namespace base | |
15 | |
16 namespace extensions { | |
17 struct Alarm; | |
18 typedef std::vector<Alarm> AlarmList; | |
19 | |
20 class AlarmsCreateFunction : public ChromeAsyncExtensionFunction { | |
21 public: | |
22 AlarmsCreateFunction(); | |
23 // Use |clock| instead of the default clock. Does not take ownership | |
24 // of |clock|. Used for testing. | |
25 explicit AlarmsCreateFunction(base::Clock* clock); | |
26 protected: | |
27 ~AlarmsCreateFunction() override; | |
28 | |
29 // ExtensionFunction: | |
30 bool RunAsync() override; | |
31 DECLARE_EXTENSION_FUNCTION("alarms.create", ALARMS_CREATE) | |
32 private: | |
33 void Callback(); | |
34 | |
35 base::Clock* const clock_; | |
36 // Whether or not we own |clock_|. This is needed because we own it | |
37 // when we create it ourselves, but not when it's passed in for | |
38 // testing. | |
39 bool owns_clock_; | |
40 }; | |
41 | |
42 class AlarmsGetFunction : public ChromeAsyncExtensionFunction { | |
43 protected: | |
44 ~AlarmsGetFunction() override {} | |
45 | |
46 // ExtensionFunction: | |
47 bool RunAsync() override; | |
48 | |
49 private: | |
50 void Callback(const std::string& name, Alarm* alarm); | |
51 DECLARE_EXTENSION_FUNCTION("alarms.get", ALARMS_GET) | |
52 }; | |
53 | |
54 class AlarmsGetAllFunction : public ChromeAsyncExtensionFunction { | |
55 protected: | |
56 ~AlarmsGetAllFunction() override {} | |
57 | |
58 // ExtensionFunction: | |
59 bool RunAsync() override; | |
60 | |
61 private: | |
62 void Callback(const AlarmList* alarms); | |
63 DECLARE_EXTENSION_FUNCTION("alarms.getAll", ALARMS_GETALL) | |
64 }; | |
65 | |
66 class AlarmsClearFunction : public ChromeAsyncExtensionFunction { | |
67 protected: | |
68 ~AlarmsClearFunction() override {} | |
69 | |
70 // ExtensionFunction: | |
71 bool RunAsync() override; | |
72 | |
73 private: | |
74 void Callback(const std::string& name, bool success); | |
75 DECLARE_EXTENSION_FUNCTION("alarms.clear", ALARMS_CLEAR) | |
76 }; | |
77 | |
78 class AlarmsClearAllFunction : public ChromeAsyncExtensionFunction { | |
79 protected: | |
80 ~AlarmsClearAllFunction() override {} | |
81 | |
82 // ExtensionFunction: | |
83 bool RunAsync() override; | |
84 | |
85 private: | |
86 void Callback(); | |
87 DECLARE_EXTENSION_FUNCTION("alarms.clearAll", ALARMS_CLEARALL) | |
88 }; | |
89 | |
90 } // namespace extensions | |
91 | |
92 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__ | |
OLD | NEW |