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

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

Issue 1999953002: Move content/browser/power_save_blocker to //device/power_save_blocker (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@power-save-next-2
Patch Set: . Created 4 years, 6 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 "content/public/browser/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 {
(...skipping 21 matching lines...) Expand all
46 // ExtensionFunction: 46 // ExtensionFunction:
47 bool RunSync() override; 47 bool RunSync() 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<content::PowerSaveBlocker>( 56 typedef base::Callback<std::unique_ptr<device::PowerSaveBlocker>(
57 content::PowerSaveBlocker::PowerSaveBlockerType, 57 device::PowerSaveBlocker::PowerSaveBlockerType,
58 content::PowerSaveBlocker::Reason, 58 device::PowerSaveBlocker::Reason,
59 const std::string&)> 59 const std::string&)>
60 CreateBlockerFunction; 60 CreateBlockerFunction;
61 61
62 static PowerAPI* Get(content::BrowserContext* context); 62 static PowerAPI* Get(content::BrowserContext* context);
63 63
64 // BrowserContextKeyedAPI implementation. 64 // BrowserContextKeyedAPI implementation.
65 static BrowserContextKeyedAPIFactory<PowerAPI>* GetFactoryInstance(); 65 static BrowserContextKeyedAPIFactory<PowerAPI>* GetFactoryInstance();
66 66
67 // Adds an extension lock at |level| for |extension_id|, replacing the 67 // Adds an extension lock at |level| for |extension_id|, replacing the
68 // extension's existing lock, if any. 68 // extension's existing lock, if any.
(...skipping 28 matching lines...) Expand all
97 static const bool kServiceIsCreatedWithBrowserContext = false; 97 static const bool kServiceIsCreatedWithBrowserContext = false;
98 void Shutdown() override; 98 void Shutdown() override;
99 99
100 content::BrowserContext* browser_context_; 100 content::BrowserContext* browser_context_;
101 101
102 // Function that should be called to create PowerSaveBlocker objects. 102 // Function that should be called to create PowerSaveBlocker objects.
103 // Tests can change this to record what would've been done instead of 103 // Tests can change this to record what would've been done instead of
104 // actually changing the system power-saving settings. 104 // actually changing the system power-saving settings.
105 CreateBlockerFunction create_blocker_function_; 105 CreateBlockerFunction create_blocker_function_;
106 106
107 std::unique_ptr<content::PowerSaveBlocker> power_save_blocker_; 107 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_;
108 108
109 // Current level used by |power_save_blocker_|. Meaningless if 109 // Current level used by |power_save_blocker_|. Meaningless if
110 // |power_save_blocker_| is NULL. 110 // |power_save_blocker_| is NULL.
111 api::power::Level current_level_; 111 api::power::Level current_level_;
112 112
113 // Map from extension ID to the corresponding level for each extension 113 // Map from extension ID to the corresponding level for each extension
114 // that has an outstanding request. 114 // that has an outstanding request.
115 typedef std::map<std::string, api::power::Level> ExtensionLevelMap; 115 typedef std::map<std::string, api::power::Level> ExtensionLevelMap;
116 ExtensionLevelMap extension_levels_; 116 ExtensionLevelMap extension_levels_;
117 117
118 DISALLOW_COPY_AND_ASSIGN(PowerAPI); 118 DISALLOW_COPY_AND_ASSIGN(PowerAPI);
119 }; 119 };
120 120
121 } // namespace extensions 121 } // namespace extensions
122 122
123 #endif // EXTENSIONS_BROWSER_API_POWER_POWER_API_H_ 123 #endif // EXTENSIONS_BROWSER_API_POWER_POWER_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698