| OLD | NEW |
| 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 "content/browser/power_save_blocker.h" | 5 #include "content/browser/power_save_blocker.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/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/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 int g_blocker_count[2]; | 17 int g_blocker_count[2]; |
| 18 | 18 |
| 19 #if _WIN32_WINNT <= _WIN32_WINNT_WIN7 | |
| 20 POWER_REQUEST_TYPE PowerRequestExecutionRequired = | |
| 21 static_cast<POWER_REQUEST_TYPE>(PowerRequestAwayModeRequired + 1); | |
| 22 #endif | |
| 23 | |
| 24 HANDLE CreatePowerRequest(POWER_REQUEST_TYPE type, const std::string& reason) { | 19 HANDLE CreatePowerRequest(POWER_REQUEST_TYPE type, const std::string& reason) { |
| 25 typedef HANDLE (WINAPI* PowerCreateRequestPtr)(PREASON_CONTEXT); | 20 typedef HANDLE (WINAPI* PowerCreateRequestPtr)(PREASON_CONTEXT); |
| 26 typedef BOOL (WINAPI* PowerSetRequestPtr)(HANDLE, POWER_REQUEST_TYPE); | 21 typedef BOOL (WINAPI* PowerSetRequestPtr)(HANDLE, POWER_REQUEST_TYPE); |
| 27 | 22 |
| 28 if (type == PowerRequestExecutionRequired && | 23 if (type == PowerRequestExecutionRequired && |
| 29 base::win::GetVersion() < base::win::VERSION_WIN8) { | 24 base::win::GetVersion() < base::win::VERSION_WIN8) { |
| 30 return INVALID_HANDLE_VALUE; | 25 return INVALID_HANDLE_VALUE; |
| 31 } | 26 } |
| 32 | 27 |
| 33 static PowerCreateRequestPtr PowerCreateRequestFn = NULL; | 28 static PowerCreateRequestPtr PowerCreateRequestFn = NULL; |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 base::Bind(&Delegate::ApplyBlock, delegate_)); | 166 base::Bind(&Delegate::ApplyBlock, delegate_)); |
| 172 } | 167 } |
| 173 | 168 |
| 174 PowerSaveBlocker::~PowerSaveBlocker() { | 169 PowerSaveBlocker::~PowerSaveBlocker() { |
| 175 BrowserThread::PostTask( | 170 BrowserThread::PostTask( |
| 176 BrowserThread::UI, FROM_HERE, | 171 BrowserThread::UI, FROM_HERE, |
| 177 base::Bind(&Delegate::RemoveBlock, delegate_)); | 172 base::Bind(&Delegate::RemoveBlock, delegate_)); |
| 178 } | 173 } |
| 179 | 174 |
| 180 } // namespace content | 175 } // namespace content |
| OLD | NEW |