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

Unified Diff: extensions/browser/api/power/power_api.cc

Issue 2075973002: Revert of 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « extensions/browser/api/power/power_api.h ('k') | extensions/browser/api/power/power_api_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/api/power/power_api.cc
diff --git a/extensions/browser/api/power/power_api.cc b/extensions/browser/api/power/power_api.cc
index 819089699f56e95975e3536caa57e767a7fc232b..c12d86bb870379c94050f3ba58d831abecd6fd2f 100644
--- a/extensions/browser/api/power/power_api.cc
+++ b/extensions/browser/api/power/power_api.cc
@@ -6,8 +6,7 @@
#include "base/bind.h"
#include "base/lazy_instance.h"
-#include "content/public/browser/browser_thread.h"
-#include "device/power_save_blocker/power_save_blocker.h"
+#include "content/public/browser/power_save_blocker_factory.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/api/power.h"
#include "extensions/common/extension.h"
@@ -18,17 +17,17 @@
const char kPowerSaveBlockerDescription[] = "extension";
-device::PowerSaveBlocker::PowerSaveBlockerType LevelToPowerSaveBlockerType(
+content::PowerSaveBlocker::PowerSaveBlockerType LevelToPowerSaveBlockerType(
api::power::Level level) {
switch (level) {
case api::power::LEVEL_SYSTEM:
- return device::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension;
+ return content::PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension;
case api::power::LEVEL_DISPLAY: // fallthrough
case api::power::LEVEL_NONE:
- return device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep;
+ return content::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep;
}
NOTREACHED() << "Unhandled level " << level;
- return device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep;
+ return content::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep;
}
base::LazyInstance<BrowserContextKeyedAPIFactory<PowerAPI>> g_factory =
@@ -73,10 +72,9 @@
void PowerAPI::SetCreateBlockerFunctionForTesting(
CreateBlockerFunction function) {
- create_blocker_function_ =
- !function.is_null()
- ? function
- : base::Bind(&device::PowerSaveBlocker::CreateWithTaskRunners);
+ create_blocker_function_ = !function.is_null()
+ ? function
+ : base::Bind(&content::CreatePowerSaveBlocker);
}
void PowerAPI::OnExtensionUnloaded(content::BrowserContext* browser_context,
@@ -88,8 +86,7 @@
PowerAPI::PowerAPI(content::BrowserContext* context)
: browser_context_(context),
- create_blocker_function_(
- base::Bind(&device::PowerSaveBlocker::CreateWithTaskRunners)),
+ create_blocker_function_(base::Bind(&content::CreatePowerSaveBlocker)),
current_level_(api::power::LEVEL_SYSTEM) {
ExtensionRegistry::Get(browser_context_)->AddObserver(this);
}
@@ -114,16 +111,12 @@
// to ensure that there isn't a brief period where power management is
// unblocked.
if (!power_save_blocker_ || new_level != current_level_) {
- device::PowerSaveBlocker::PowerSaveBlockerType type =
+ content::PowerSaveBlocker::PowerSaveBlockerType type =
LevelToPowerSaveBlockerType(new_level);
- std::unique_ptr<device::PowerSaveBlocker> new_blocker(
- create_blocker_function_.Run(
- type, device::PowerSaveBlocker::kReasonOther,
- kPowerSaveBlockerDescription,
- content::BrowserThread::GetMessageLoopProxyForThread(
- content::BrowserThread::UI),
- content::BrowserThread::GetMessageLoopProxyForThread(
- content::BrowserThread::FILE)));
+ std::unique_ptr<content::PowerSaveBlocker> new_blocker(
+ create_blocker_function_.Run(type,
+ content::PowerSaveBlocker::kReasonOther,
+ kPowerSaveBlockerDescription));
power_save_blocker_.swap(new_blocker);
current_level_ = new_level;
}
« no previous file with comments | « extensions/browser/api/power/power_api.h ('k') | extensions/browser/api/power/power_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698