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 <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
8 #include <X11/extensions/dpms.h> | 8 #include <X11/extensions/dpms.h> |
9 // Xlib #defines Status, but we can't have that for some of our headers. | 9 // Xlib #defines Status, but we can't have that for some of our headers. |
10 #ifdef Status | 10 #ifdef Status |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 CommandLine::ForCurrentProcess()->GetProgram().value()); | 235 CommandLine::ForCurrentProcess()->GetProgram().value()); |
236 message_writer->AppendString(reason_); | 236 message_writer->AppendString(reason_); |
237 break; | 237 break; |
238 } | 238 } |
239 | 239 |
240 // We could do this method call asynchronously, but if we did, we'd need to | 240 // We could do this method call asynchronously, but if we did, we'd need to |
241 // handle the case where we want to cancel the block before we get a reply. | 241 // handle the case where we want to cancel the block before we get a reply. |
242 // We're on the FILE thread so it should be OK to block briefly here. | 242 // We're on the FILE thread so it should be OK to block briefly here. |
243 scoped_ptr<dbus::Response> response(object_proxy->CallMethodAndBlock( | 243 scoped_ptr<dbus::Response> response(object_proxy->CallMethodAndBlock( |
244 method_call.get(), dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); | 244 method_call.get(), dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); |
245 if (response.get()) { | 245 if (response) { |
246 // The method returns an inhibit_cookie, used to uniquely identify | 246 // The method returns an inhibit_cookie, used to uniquely identify |
247 // this request. It should be used as an argument to Uninhibit() | 247 // this request. It should be used as an argument to Uninhibit() |
248 // in order to remove the request. | 248 // in order to remove the request. |
249 dbus::MessageReader message_reader(response.get()); | 249 dbus::MessageReader message_reader(response.get()); |
250 if (!message_reader.PopUint32(&inhibit_cookie_)) | 250 if (!message_reader.PopUint32(&inhibit_cookie_)) |
251 LOG(ERROR) << "Invalid Inhibit() response: " << response->ToString(); | 251 LOG(ERROR) << "Invalid Inhibit() response: " << response->ToString(); |
252 } else { | 252 } else { |
253 LOG(ERROR) << "No response to Inhibit() request!"; | 253 LOG(ERROR) << "No response to Inhibit() request!"; |
254 } | 254 } |
255 } | 255 } |
(...skipping 22 matching lines...) Expand all Loading... |
278 dbus::ObjectPath(kFreeDesktopAPIObjectPath)); | 278 dbus::ObjectPath(kFreeDesktopAPIObjectPath)); |
279 method_call.reset( | 279 method_call.reset( |
280 new dbus::MethodCall(kFreeDesktopAPIInterfaceName, "UnInhibit")); | 280 new dbus::MethodCall(kFreeDesktopAPIInterfaceName, "UnInhibit")); |
281 break; | 281 break; |
282 } | 282 } |
283 | 283 |
284 dbus::MessageWriter message_writer(method_call.get()); | 284 dbus::MessageWriter message_writer(method_call.get()); |
285 message_writer.AppendUint32(inhibit_cookie_); | 285 message_writer.AppendUint32(inhibit_cookie_); |
286 scoped_ptr<dbus::Response> response(object_proxy->CallMethodAndBlock( | 286 scoped_ptr<dbus::Response> response(object_proxy->CallMethodAndBlock( |
287 method_call.get(), dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); | 287 method_call.get(), dbus::ObjectProxy::TIMEOUT_USE_DEFAULT)); |
288 if (!response.get()) | 288 if (!response) |
289 LOG(ERROR) << "No response to Uninhibit() request!"; | 289 LOG(ERROR) << "No response to Uninhibit() request!"; |
290 // We don't care about checking the result. We assume it works; we can't | 290 // We don't care about checking the result. We assume it works; we can't |
291 // really do anything about it anyway if it fails. | 291 // really do anything about it anyway if it fails. |
292 inhibit_cookie_ = 0; | 292 inhibit_cookie_ = 0; |
293 | 293 |
294 bus_->ShutdownAndBlock(); | 294 bus_->ShutdownAndBlock(); |
295 bus_ = NULL; | 295 bus_ = NULL; |
296 } | 296 } |
297 | 297 |
298 // static | 298 // static |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 PowerSaveBlockerType type, const std::string& reason) | 333 PowerSaveBlockerType type, const std::string& reason) |
334 : delegate_(new Delegate(type, reason)) { | 334 : delegate_(new Delegate(type, reason)) { |
335 delegate_->Init(); | 335 delegate_->Init(); |
336 } | 336 } |
337 | 337 |
338 PowerSaveBlockerImpl::~PowerSaveBlockerImpl() { | 338 PowerSaveBlockerImpl::~PowerSaveBlockerImpl() { |
339 delegate_->CleanUp(); | 339 delegate_->CleanUp(); |
340 } | 340 } |
341 | 341 |
342 } // namespace content | 342 } // namespace content |
OLD | NEW |