summaryrefslogtreecommitdiffstats
path: root/chrome/browser/power_save_blocker_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/power_save_blocker_win.cc')
-rw-r--r--chrome/browser/power_save_blocker_win.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/chrome/browser/power_save_blocker_win.cc b/chrome/browser/power_save_blocker_win.cc
new file mode 100644
index 0000000..f7d3d8c
--- /dev/null
+++ b/chrome/browser/power_save_blocker_win.cc
@@ -0,0 +1,21 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/power_save_blocker.h"
+
+#include <windows.h>
+
+#include "chrome/browser/chrome_thread.h"
+
+// Runs on UI thread only.
+void PowerSaveBlocker::ApplyBlock(bool blocking) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+
+ DWORD flags = ES_CONTINUOUS;
+
+ if (blocking)
+ flags |= ES_SYSTEM_REQUIRED;
+
+ SetThreadExecutionState(flags);
+}