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