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_impl.h" | 5 #include "content/browser/power_save_blocker_impl.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/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 ~Delegate() {} | 127 ~Delegate() {} |
128 | 128 |
129 PowerSaveBlockerType type_; | 129 PowerSaveBlockerType type_; |
130 const std::string description_; | 130 const std::string description_; |
131 base::win::ScopedHandle handle_; | 131 base::win::ScopedHandle handle_; |
132 | 132 |
133 DISALLOW_COPY_AND_ASSIGN(Delegate); | 133 DISALLOW_COPY_AND_ASSIGN(Delegate); |
134 }; | 134 }; |
135 | 135 |
136 void PowerSaveBlockerImpl::Delegate::ApplyBlock() { | 136 void PowerSaveBlockerImpl::Delegate::ApplyBlock() { |
137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 137 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
138 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 138 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
139 return ApplySimpleBlock(type_, 1); | 139 return ApplySimpleBlock(type_, 1); |
140 | 140 |
141 handle_.Set(CreatePowerRequest(RequestType(), description_)); | 141 handle_.Set(CreatePowerRequest(RequestType(), description_)); |
142 } | 142 } |
143 | 143 |
144 void PowerSaveBlockerImpl::Delegate::RemoveBlock() { | 144 void PowerSaveBlockerImpl::Delegate::RemoveBlock() { |
145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 145 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
146 if (base::win::GetVersion() < base::win::VERSION_WIN7) | 146 if (base::win::GetVersion() < base::win::VERSION_WIN7) |
147 return ApplySimpleBlock(type_, -1); | 147 return ApplySimpleBlock(type_, -1); |
148 | 148 |
149 DeletePowerRequest(RequestType(), handle_.Take()); | 149 DeletePowerRequest(RequestType(), handle_.Take()); |
150 } | 150 } |
151 | 151 |
152 POWER_REQUEST_TYPE PowerSaveBlockerImpl::Delegate::RequestType() { | 152 POWER_REQUEST_TYPE PowerSaveBlockerImpl::Delegate::RequestType() { |
153 if (type_ == kPowerSaveBlockPreventDisplaySleep) | 153 if (type_ == kPowerSaveBlockPreventDisplaySleep) |
154 return PowerRequestDisplayRequired; | 154 return PowerRequestDisplayRequired; |
155 | 155 |
(...skipping 12 matching lines...) Expand all Loading... |
168 base::Bind(&Delegate::ApplyBlock, delegate_)); | 168 base::Bind(&Delegate::ApplyBlock, delegate_)); |
169 } | 169 } |
170 | 170 |
171 PowerSaveBlockerImpl::~PowerSaveBlockerImpl() { | 171 PowerSaveBlockerImpl::~PowerSaveBlockerImpl() { |
172 BrowserThread::PostTask( | 172 BrowserThread::PostTask( |
173 BrowserThread::UI, FROM_HERE, | 173 BrowserThread::UI, FROM_HERE, |
174 base::Bind(&Delegate::RemoveBlock, delegate_)); | 174 base::Bind(&Delegate::RemoveBlock, delegate_)); |
175 } | 175 } |
176 | 176 |
177 } // namespace content | 177 } // namespace content |
OLD | NEW |