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 RunImpl() 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 RunImpl() 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 RunImpl() OVERRIDE;
61 void Callback(const AlarmList* alarms);
62 DECLARE_EXTENSION_FUNCTION("alarms.getAll", ALARMS_GETALL)
65 class AlarmsClearFunction : public ChromeAsyncExtensionFunction {
67 virtual ~AlarmsClearFunction() {}
70 virtual bool RunImpl() OVERRIDE;
72 void Callback(const std::string& name, bool success);
73 DECLARE_EXTENSION_FUNCTION("alarms.clear", ALARMS_CLEAR)
76 class AlarmsClearAllFunction : public ChromeAsyncExtensionFunction {
78 virtual ~AlarmsClearAllFunction() {}
81 virtual bool RunImpl() OVERRIDE;
84 DECLARE_EXTENSION_FUNCTION("alarms.clearAll", ALARMS_CLEARALL)
87 } // namespace extensions
89 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__