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 EXTENSIONS_BROWSER_API_ALARMS_ALARMS_API_H_
6 #define EXTENSIONS_BROWSER_API_ALARMS_ALARMS_API_H_
10 #include "extensions/browser/extension_function.h"
16 namespace extensions
{
18 typedef std::vector
<Alarm
> AlarmList
;
20 class AlarmsCreateFunction
: public AsyncExtensionFunction
{
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
);
28 ~AlarmsCreateFunction() override
;
31 bool RunAsync() override
;
32 DECLARE_EXTENSION_FUNCTION("alarms.create", ALARMS_CREATE
)
36 base::Clock
* const clock_
;
37 // Whether or not we own |clock_|. This is needed because we own it
38 // when we create it ourselves, but not when it's passed in for
43 class AlarmsGetFunction
: public AsyncExtensionFunction
{
45 ~AlarmsGetFunction() override
{}
48 bool RunAsync() override
;
51 void Callback(const std::string
& name
, Alarm
* alarm
);
52 DECLARE_EXTENSION_FUNCTION("alarms.get", ALARMS_GET
)
55 class AlarmsGetAllFunction
: public AsyncExtensionFunction
{
57 ~AlarmsGetAllFunction() override
{}
60 bool RunAsync() override
;
63 void Callback(const AlarmList
* alarms
);
64 DECLARE_EXTENSION_FUNCTION("alarms.getAll", ALARMS_GETALL
)
67 class AlarmsClearFunction
: public AsyncExtensionFunction
{
69 ~AlarmsClearFunction() override
{}
72 bool RunAsync() override
;
75 void Callback(const std::string
& name
, bool success
);
76 DECLARE_EXTENSION_FUNCTION("alarms.clear", ALARMS_CLEAR
)
79 class AlarmsClearAllFunction
: public AsyncExtensionFunction
{
81 ~AlarmsClearAllFunction() override
{}
84 bool RunAsync() override
;
88 DECLARE_EXTENSION_FUNCTION("alarms.clearAll", ALARMS_CLEARALL
)
91 } // namespace extensions
93 #endif // EXTENSIONS_BROWSER_API_ALARMS_ALARMS_API_H_