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

Side by Side Diff: extensions/browser/api/power/power_api.h

Issue 2261313002: [Extensions] Convert some SyncExtensionFunctions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ready Created 4 years, 4 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 EXTENSIONS_BROWSER_API_POWER_POWER_API_H_ 5 #ifndef EXTENSIONS_BROWSER_API_POWER_POWER_API_H_
6 #define EXTENSIONS_BROWSER_API_POWER_POWER_API_H_ 6 #define EXTENSIONS_BROWSER_API_POWER_POWER_API_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 11
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/macros.h" 13 #include "base/macros.h"
14 #include "device/power_save_blocker/power_save_blocker.h" 14 #include "device/power_save_blocker/power_save_blocker.h"
15 #include "extensions/browser/browser_context_keyed_api_factory.h" 15 #include "extensions/browser/browser_context_keyed_api_factory.h"
16 #include "extensions/browser/extension_function.h" 16 #include "extensions/browser/extension_function.h"
17 #include "extensions/browser/extension_registry_observer.h" 17 #include "extensions/browser/extension_registry_observer.h"
18 #include "extensions/common/api/power.h" 18 #include "extensions/common/api/power.h"
19 19
20 namespace content { 20 namespace content {
21 class BrowserContext; 21 class BrowserContext;
22 } 22 }
23 23
24 namespace extensions { 24 namespace extensions {
25 25
26 // Implementation of the chrome.power.requestKeepAwake API. 26 // Implementation of the chrome.power.requestKeepAwake API.
27 class PowerRequestKeepAwakeFunction : public SyncExtensionFunction { 27 class PowerRequestKeepAwakeFunction : public UIThreadExtensionFunction {
28 public: 28 public:
29 DECLARE_EXTENSION_FUNCTION("power.requestKeepAwake", POWER_REQUESTKEEPAWAKE) 29 DECLARE_EXTENSION_FUNCTION("power.requestKeepAwake", POWER_REQUESTKEEPAWAKE)
30 30
31 protected: 31 protected:
32 ~PowerRequestKeepAwakeFunction() override {} 32 ~PowerRequestKeepAwakeFunction() override {}
33 33
34 // ExtensionFunction: 34 // ExtensionFunction:
35 bool RunSync() override; 35 ResponseAction Run() override;
36 }; 36 };
37 37
38 // Implementation of the chrome.power.releaseKeepAwake API. 38 // Implementation of the chrome.power.releaseKeepAwake API.
39 class PowerReleaseKeepAwakeFunction : public SyncExtensionFunction { 39 class PowerReleaseKeepAwakeFunction : public UIThreadExtensionFunction {
40 public: 40 public:
41 DECLARE_EXTENSION_FUNCTION("power.releaseKeepAwake", POWER_RELEASEKEEPAWAKE) 41 DECLARE_EXTENSION_FUNCTION("power.releaseKeepAwake", POWER_RELEASEKEEPAWAKE)
42 42
43 protected: 43 protected:
44 ~PowerReleaseKeepAwakeFunction() override {} 44 ~PowerReleaseKeepAwakeFunction() override {}
45 45
46 // ExtensionFunction: 46 // ExtensionFunction:
47 bool RunSync() override; 47 ResponseAction Run() override;
48 }; 48 };
49 49
50 // Handles calls made via the chrome.power API. There is a separate instance of 50 // Handles calls made via the chrome.power API. There is a separate instance of
51 // this class for each profile, as requests are tracked by extension ID, but a 51 // this class for each profile, as requests are tracked by extension ID, but a
52 // regular and incognito profile will share the same instance. 52 // regular and incognito profile will share the same instance.
53 class PowerAPI : public BrowserContextKeyedAPI, 53 class PowerAPI : public BrowserContextKeyedAPI,
54 public extensions::ExtensionRegistryObserver { 54 public extensions::ExtensionRegistryObserver {
55 public: 55 public:
56 typedef base::Callback<std::unique_ptr<device::PowerSaveBlocker>( 56 typedef base::Callback<std::unique_ptr<device::PowerSaveBlocker>(
57 device::PowerSaveBlocker::PowerSaveBlockerType, 57 device::PowerSaveBlocker::PowerSaveBlockerType,
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // that has an outstanding request. 117 // that has an outstanding request.
118 typedef std::map<std::string, api::power::Level> ExtensionLevelMap; 118 typedef std::map<std::string, api::power::Level> ExtensionLevelMap;
119 ExtensionLevelMap extension_levels_; 119 ExtensionLevelMap extension_levels_;
120 120
121 DISALLOW_COPY_AND_ASSIGN(PowerAPI); 121 DISALLOW_COPY_AND_ASSIGN(PowerAPI);
122 }; 122 };
123 123
124 } // namespace extensions 124 } // namespace extensions
125 125
126 #endif // EXTENSIONS_BROWSER_API_POWER_POWER_API_H_ 126 #endif // EXTENSIONS_BROWSER_API_POWER_POWER_API_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/networking_private/networking_private_api.cc ('k') | extensions/browser/api/power/power_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698