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

Side by Side Diff: device/power_save_blocker/power_save_blocker_win.cc

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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include <windows.h> 5 #include <windows.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "base/win/scoped_handle.h" 11 #include "base/win/scoped_handle.h"
12 #include "base/win/windows_version.h" 12 #include "base/win/windows_version.h"
13 #include "content/browser/power_save_blocker_impl.h" 13 #include "device/power_save_blocker/power_save_blocker_impl.h"
14 14
15 namespace content { 15 namespace device {
16 namespace { 16 namespace {
17 17
18 int g_blocker_count[2]; 18 int g_blocker_count[2];
19 19
20 HANDLE CreatePowerRequest(POWER_REQUEST_TYPE type, 20 HANDLE CreatePowerRequest(POWER_REQUEST_TYPE type,
21 const std::string& description) { 21 const std::string& description) {
22 if (type == PowerRequestExecutionRequired && 22 if (type == PowerRequestExecutionRequired &&
23 base::win::GetVersion() < base::win::VERSION_WIN8) { 23 base::win::GetVersion() < base::win::VERSION_WIN8) {
24 return INVALID_HANDLE_VALUE; 24 return INVALID_HANDLE_VALUE;
25 } 25 }
(...skipping 24 matching lines...) Expand all
50 50
51 if (type == PowerRequestExecutionRequired && 51 if (type == PowerRequestExecutionRequired &&
52 base::win::GetVersion() < base::win::VERSION_WIN8) { 52 base::win::GetVersion() < base::win::VERSION_WIN8) {
53 return; 53 return;
54 } 54 }
55 55
56 BOOL success = ::PowerClearRequest(request_handle.Get(), type); 56 BOOL success = ::PowerClearRequest(request_handle.Get(), type);
57 DCHECK(success); 57 DCHECK(success);
58 } 58 }
59 59
60 void ApplySimpleBlock(PowerSaveBlocker::PowerSaveBlockerType type, 60 void ApplySimpleBlock(PowerSaveBlocker::PowerSaveBlockerType type, int delta) {
61 int delta) {
62 g_blocker_count[type] += delta; 61 g_blocker_count[type] += delta;
63 DCHECK_GE(g_blocker_count[type], 0); 62 DCHECK_GE(g_blocker_count[type], 0);
64 63
65 if (g_blocker_count[type] > 1) 64 if (g_blocker_count[type] > 1)
66 return; 65 return;
67 66
68 DWORD this_flag = 0; 67 DWORD this_flag = 0;
69 if (type == PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension) 68 if (type == PowerSaveBlocker::kPowerSaveBlockPreventAppSuspension)
70 this_flag |= ES_SYSTEM_REQUIRED; 69 this_flag |= ES_SYSTEM_REQUIRED;
71 else 70 else
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 blocking_task_runner_(blocking_task_runner) { 149 blocking_task_runner_(blocking_task_runner) {
151 ui_task_runner_->PostTask(FROM_HERE, 150 ui_task_runner_->PostTask(FROM_HERE,
152 base::Bind(&Delegate::ApplyBlock, delegate_)); 151 base::Bind(&Delegate::ApplyBlock, delegate_));
153 } 152 }
154 153
155 PowerSaveBlockerImpl::~PowerSaveBlockerImpl() { 154 PowerSaveBlockerImpl::~PowerSaveBlockerImpl() {
156 ui_task_runner_->PostTask(FROM_HERE, 155 ui_task_runner_->PostTask(FROM_HERE,
157 base::Bind(&Delegate::RemoveBlock, delegate_)); 156 base::Bind(&Delegate::RemoveBlock, delegate_));
158 } 157 }
159 158
160 } // namespace content 159 } // namespace device
OLDNEW
« no previous file with comments | « device/power_save_blocker/power_save_blocker_ozone.cc ('k') | device/power_save_blocker/power_save_blocker_x11.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698