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

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

Issue 2757083002: feedback: List extensions using the chrome.power API. (Closed)
Patch Set: Created 3 years, 9 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 | « chrome/browser/feedback/system_logs/log_sources/chrome_internal_log_source.cc ('k') | no next file » | 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>
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 const std::string&, 59 const std::string&,
60 scoped_refptr<base::SequencedTaskRunner> ui_task_runner, 60 scoped_refptr<base::SequencedTaskRunner> ui_task_runner,
61 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner)> 61 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner)>
62 CreateBlockerFunction; 62 CreateBlockerFunction;
63 63
64 static PowerAPI* Get(content::BrowserContext* context); 64 static PowerAPI* Get(content::BrowserContext* context);
65 65
66 // BrowserContextKeyedAPI implementation. 66 // BrowserContextKeyedAPI implementation.
67 static BrowserContextKeyedAPIFactory<PowerAPI>* GetFactoryInstance(); 67 static BrowserContextKeyedAPIFactory<PowerAPI>* GetFactoryInstance();
68 68
69 // Map from extension ID to the corresponding level for each extension
70 // that has an outstanding request.
71 using ExtensionLevelMap = std::map<std::string, api::power::Level>;
72 const ExtensionLevelMap& extension_levels() const {
73 return extension_levels_;
74 }
75
69 // Adds an extension lock at |level| for |extension_id|, replacing the 76 // Adds an extension lock at |level| for |extension_id|, replacing the
70 // extension's existing lock, if any. 77 // extension's existing lock, if any.
71 void AddRequest(const std::string& extension_id, api::power::Level level); 78 void AddRequest(const std::string& extension_id, api::power::Level level);
72 79
73 // Removes an extension lock for an extension. Calling this for an 80 // Removes an extension lock for an extension. Calling this for an
74 // extension id without a lock will do nothing. 81 // extension id without a lock will do nothing.
75 void RemoveRequest(const std::string& extension_id); 82 void RemoveRequest(const std::string& extension_id);
76 83
77 // Replaces the function that will be called to create PowerSaveBlocker 84 // Replaces the function that will be called to create PowerSaveBlocker
78 // objects. Passing an empty callback will revert to the default. 85 // objects. Passing an empty callback will revert to the default.
(...skipping 27 matching lines...) Expand all
106 // Tests can change this to record what would've been done instead of 113 // Tests can change this to record what would've been done instead of
107 // actually changing the system power-saving settings. 114 // actually changing the system power-saving settings.
108 CreateBlockerFunction create_blocker_function_; 115 CreateBlockerFunction create_blocker_function_;
109 116
110 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_; 117 std::unique_ptr<device::PowerSaveBlocker> power_save_blocker_;
111 118
112 // Current level used by |power_save_blocker_|. Meaningless if 119 // Current level used by |power_save_blocker_|. Meaningless if
113 // |power_save_blocker_| is NULL. 120 // |power_save_blocker_| is NULL.
114 api::power::Level current_level_; 121 api::power::Level current_level_;
115 122
116 // Map from extension ID to the corresponding level for each extension 123 // Outstanding requests.
117 // that has an outstanding request.
118 typedef std::map<std::string, api::power::Level> ExtensionLevelMap;
119 ExtensionLevelMap extension_levels_; 124 ExtensionLevelMap extension_levels_;
120 125
121 DISALLOW_COPY_AND_ASSIGN(PowerAPI); 126 DISALLOW_COPY_AND_ASSIGN(PowerAPI);
122 }; 127 };
123 128
124 } // namespace extensions 129 } // namespace extensions
125 130
126 #endif // EXTENSIONS_BROWSER_API_POWER_POWER_API_H_ 131 #endif // EXTENSIONS_BROWSER_API_POWER_POWER_API_H_
OLDNEW
« no previous file with comments | « chrome/browser/feedback/system_logs/log_sources/chrome_internal_log_source.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698