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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__
10 #include "chrome/browser/extensions/chrome_extension_function.h"
16 namespace extensions {
18 typedef std::vector<Alarm> AlarmList;
20 class AlarmsCreateFunction : public ChromeAsyncExtensionFunction {
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);
27 virtual ~AlarmsCreateFunction();
30 virtual bool RunAsync() OVERRIDE;
31 DECLARE_EXTENSION_FUNCTION("alarms.create", ALARMS_CREATE)
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
42 class AlarmsGetFunction : public ChromeAsyncExtensionFunction {
44 virtual ~AlarmsGetFunction() {}
47 virtual bool RunAsync() OVERRIDE;
50 void Callback(const std::string& name, Alarm* alarm);
51 DECLARE_EXTENSION_FUNCTION("alarms.get", ALARMS_GET)
54 class AlarmsGetAllFunction : public ChromeAsyncExtensionFunction {
56 virtual ~AlarmsGetAllFunction() {}
59 virtual bool RunAsync() OVERRIDE;
62 void Callback(const AlarmList* alarms);
63 DECLARE_EXTENSION_FUNCTION("alarms.getAll", ALARMS_GETALL)
66 class AlarmsClearFunction : public ChromeAsyncExtensionFunction {
68 virtual ~AlarmsClearFunction() {}
71 virtual bool RunAsync() OVERRIDE;
74 void Callback(const std::string& name, bool success);
75 DECLARE_EXTENSION_FUNCTION("alarms.clear", ALARMS_CLEAR)
78 class AlarmsClearAllFunction : public ChromeAsyncExtensionFunction {
80 virtual ~AlarmsClearAllFunction() {}
83 virtual bool RunAsync() OVERRIDE;
87 DECLARE_EXTENSION_FUNCTION("alarms.clearAll", ALARMS_CLEARALL)
90 } // namespace extensions
92 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__