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

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

Issue 2075153002: Reland of 'Move content/browser/power_save_blocker to //device/power_save_blocker' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missing libs for component mac 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
« no previous file with comments | « extensions/browser/DEPS ('k') | extensions/browser/api/power/power_api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
61 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner)>
60 CreateBlockerFunction; 62 CreateBlockerFunction;
61 63
62 static PowerAPI* Get(content::BrowserContext* context); 64 static PowerAPI* Get(content::BrowserContext* context);
63 65
64 // BrowserContextKeyedAPI implementation. 66 // BrowserContextKeyedAPI implementation.
65 static BrowserContextKeyedAPIFactory<PowerAPI>* GetFactoryInstance(); 67 static BrowserContextKeyedAPIFactory<PowerAPI>* GetFactoryInstance();
66 68
67 // Adds an extension lock at |level| for |extension_id|, replacing the 69 // Adds an extension lock at |level| for |extension_id|, replacing the
68 // extension's existing lock, if any. 70 // extension's existing lock, if any.
69 void AddRequest(const std::string& extension_id, api::power::Level level); 71 void AddRequest(const std::string& extension_id, api::power::Level level);
(...skipping 27 matching lines...) Expand all
97 static const bool kServiceIsCreatedWithBrowserContext = false; 99 static const bool kServiceIsCreatedWithBrowserContext = false;
98 void Shutdown() override; 100 void Shutdown() override;
99 101
100 content::BrowserContext* browser_context_; 102 content::BrowserContext* browser_context_;
101 103
102 // Function that should be called to create PowerSaveBlocker objects. 104 // Function that should be called to create PowerSaveBlocker objects.
103 // Tests can change this to record what would've been done instead of 105 // Tests can change this to record what would've been done instead of
104 // actually changing the system power-saving settings. 106 // actually changing the system power-saving settings.
105 CreateBlockerFunction create_blocker_function_; 107 CreateBlockerFunction create_blocker_function_;
106 108
107 std::unique_ptr<content::PowerSaveBlocker> power_save_blocker_; 109 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_;
108 110
109 // Current level used by |power_save_blocker_|. Meaningless if 111 // Current level used by |power_save_blocker_|. Meaningless if
110 // |power_save_blocker_| is NULL. 112 // |power_save_blocker_| is NULL.
111 api::power::Level current_level_; 113 api::power::Level current_level_;
112 114
113 // Map from extension ID to the corresponding level for each extension 115 // Map from extension ID to the corresponding level for each extension
114 // that has an outstanding request. 116 // that has an outstanding request.
115 typedef std::map<std::string, api::power::Level> ExtensionLevelMap; 117 typedef std::map<std::string, api::power::Level> ExtensionLevelMap;
116 ExtensionLevelMap extension_levels_; 118 ExtensionLevelMap extension_levels_;
117 119
118 DISALLOW_COPY_AND_ASSIGN(PowerAPI); 120 DISALLOW_COPY_AND_ASSIGN(PowerAPI);
119 }; 121 };
120 122
121 } // namespace extensions 123 } // namespace extensions
122 124
123 #endif // EXTENSIONS_BROWSER_API_POWER_POWER_API_H_ 125 #endif // EXTENSIONS_BROWSER_API_POWER_POWER_API_H_
OLDNEW
« no previous file with comments | « extensions/browser/DEPS ('k') | extensions/browser/api/power/power_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698