Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: extensions/browser/api/alarms/alarms_api.h

Issue 789643004: Move chrome.alarms API from chrome/ to extensions/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 EXTENSIONS_BROWSER_API_ALARMS_ALARMS_API_H__
James Cook 2015/01/05 19:22:43 same comment
babu 2015/01/16 19:32:37 Done.
6 #define CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__ 6 #define EXTENSIONS_BROWSER_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 "extensions/browser/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 AsyncExtensionFunction {
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
26 protected: 27 protected:
27 ~AlarmsCreateFunction() override; 28 ~AlarmsCreateFunction() override;
28 29
29 // ExtensionFunction: 30 // ExtensionFunction:
30 bool RunAsync() override; 31 bool RunAsync() override;
31 DECLARE_EXTENSION_FUNCTION("alarms.create", ALARMS_CREATE) 32 DECLARE_EXTENSION_FUNCTION("alarms.create", ALARMS_CREATE)
32 private: 33 private:
33 void Callback(); 34 void Callback();
34 35
35 base::Clock* const clock_; 36 base::Clock* const clock_;
36 // Whether or not we own |clock_|. This is needed because we own it 37 // 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 // when we create it ourselves, but not when it's passed in for
38 // testing. 39 // testing.
39 bool owns_clock_; 40 bool owns_clock_;
40 }; 41 };
41 42
42 class AlarmsGetFunction : public ChromeAsyncExtensionFunction { 43 class AlarmsGetFunction : public AsyncExtensionFunction {
43 protected: 44 protected:
44 ~AlarmsGetFunction() override {} 45 ~AlarmsGetFunction() override {}
45 46
46 // ExtensionFunction: 47 // ExtensionFunction:
47 bool RunAsync() override; 48 bool RunAsync() override;
48 49
49 private: 50 private:
50 void Callback(const std::string& name, Alarm* alarm); 51 void Callback(const std::string& name, Alarm* alarm);
51 DECLARE_EXTENSION_FUNCTION("alarms.get", ALARMS_GET) 52 DECLARE_EXTENSION_FUNCTION("alarms.get", ALARMS_GET)
52 }; 53 };
53 54
54 class AlarmsGetAllFunction : public ChromeAsyncExtensionFunction { 55 class AlarmsGetAllFunction : public AsyncExtensionFunction {
55 protected: 56 protected:
56 ~AlarmsGetAllFunction() override {} 57 ~AlarmsGetAllFunction() override {}
57 58
58 // ExtensionFunction: 59 // ExtensionFunction:
59 bool RunAsync() override; 60 bool RunAsync() override;
60 61
61 private: 62 private:
62 void Callback(const AlarmList* alarms); 63 void Callback(const AlarmList* alarms);
63 DECLARE_EXTENSION_FUNCTION("alarms.getAll", ALARMS_GETALL) 64 DECLARE_EXTENSION_FUNCTION("alarms.getAll", ALARMS_GETALL)
64 }; 65 };
65 66
66 class AlarmsClearFunction : public ChromeAsyncExtensionFunction { 67 class AlarmsClearFunction : public AsyncExtensionFunction {
67 protected: 68 protected:
68 ~AlarmsClearFunction() override {} 69 ~AlarmsClearFunction() override {}
69 70
70 // ExtensionFunction: 71 // ExtensionFunction:
71 bool RunAsync() override; 72 bool RunAsync() override;
72 73
73 private: 74 private:
74 void Callback(const std::string& name, bool success); 75 void Callback(const std::string& name, bool success);
75 DECLARE_EXTENSION_FUNCTION("alarms.clear", ALARMS_CLEAR) 76 DECLARE_EXTENSION_FUNCTION("alarms.clear", ALARMS_CLEAR)
76 }; 77 };
77 78
78 class AlarmsClearAllFunction : public ChromeAsyncExtensionFunction { 79 class AlarmsClearAllFunction : public AsyncExtensionFunction {
79 protected: 80 protected:
80 ~AlarmsClearAllFunction() override {} 81 ~AlarmsClearAllFunction() override {}
81 82
82 // ExtensionFunction: 83 // ExtensionFunction:
83 bool RunAsync() override; 84 bool RunAsync() override;
84 85
85 private: 86 private:
86 void Callback(); 87 void Callback();
87 DECLARE_EXTENSION_FUNCTION("alarms.clearAll", ALARMS_CLEARALL) 88 DECLARE_EXTENSION_FUNCTION("alarms.clearAll", ALARMS_CLEARALL)
88 }; 89 };
89 90
90 } // namespace extensions 91 } // namespace extensions
91 92
92 #endif // CHROME_BROWSER_EXTENSIONS_API_ALARMS_ALARMS_API_H__ 93 #endif // EXTENSIONS_BROWSER_API_ALARMS_ALARMS_API_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698