| 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 |
| 11 #undef Status | 11 #undef Status |
| 12 #endif | 12 #endif |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/bind.h" | 15 #include "base/bind.h" |
| 16 #include "base/callback.h" | 16 #include "base/callback.h" |
| 17 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 18 #include "base/environment.h" | 18 #include "base/environment.h" |
| 19 #include "base/files/file_path.h" | 19 #include "base/files/file_path.h" |
| 20 #include "base/logging.h" | 20 #include "base/logging.h" |
| 21 #include "base/memory/ref_counted.h" | 21 #include "base/memory/ref_counted.h" |
| 22 #include "base/memory/scoped_ptr.h" | 22 #include "base/memory/scoped_ptr.h" |
| 23 #include "base/memory/singleton.h" | 23 #include "base/memory/singleton.h" |
| 24 #include "base/message_loop/message_loop_proxy.h" | 24 #include "base/message_loop/message_loop_proxy.h" |
| 25 #include "base/message_loop/message_pump_x11.h" | |
| 26 #include "base/nix/xdg_util.h" | 25 #include "base/nix/xdg_util.h" |
| 27 #include "base/synchronization/lock.h" | 26 #include "base/synchronization/lock.h" |
| 28 #include "content/public/browser/browser_thread.h" | 27 #include "content/public/browser/browser_thread.h" |
| 29 #include "dbus/bus.h" | 28 #include "dbus/bus.h" |
| 30 #include "dbus/message.h" | 29 #include "dbus/message.h" |
| 31 #include "dbus/object_path.h" | 30 #include "dbus/object_path.h" |
| 32 #include "dbus/object_proxy.h" | 31 #include "dbus/object_proxy.h" |
| 33 #include "ui/gfx/x/x11_types.h" | 32 #include "ui/gfx/x/x11_types.h" |
| 34 | 33 |
| 35 namespace { | 34 namespace { |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 // We don't care about checking the result. We assume it works; we can't | 286 // We don't care about checking the result. We assume it works; we can't |
| 288 // really do anything about it anyway if it fails. | 287 // really do anything about it anyway if it fails. |
| 289 inhibit_cookie_ = 0; | 288 inhibit_cookie_ = 0; |
| 290 | 289 |
| 291 bus_->ShutdownAndBlock(); | 290 bus_->ShutdownAndBlock(); |
| 292 bus_ = NULL; | 291 bus_ = NULL; |
| 293 } | 292 } |
| 294 | 293 |
| 295 // static | 294 // static |
| 296 bool PowerSaveBlockerImpl::Delegate::DPMSEnabled() { | 295 bool PowerSaveBlockerImpl::Delegate::DPMSEnabled() { |
| 297 XDisplay* display = base::MessagePumpForUI::GetDefaultXDisplay(); | 296 XDisplay* display = gfx::GetXDisplay(); |
| 298 BOOL enabled = false; | 297 BOOL enabled = false; |
| 299 int dummy; | 298 int dummy; |
| 300 if (DPMSQueryExtension(display, &dummy, &dummy) && DPMSCapable(display)) { | 299 if (DPMSQueryExtension(display, &dummy, &dummy) && DPMSCapable(display)) { |
| 301 CARD16 state; | 300 CARD16 state; |
| 302 DPMSInfo(display, &state, &enabled); | 301 DPMSInfo(display, &state, &enabled); |
| 303 } | 302 } |
| 304 return enabled; | 303 return enabled; |
| 305 } | 304 } |
| 306 | 305 |
| 307 // static | 306 // static |
| (...skipping 22 matching lines...) Expand all Loading... |
| 330 PowerSaveBlockerType type, const std::string& reason) | 329 PowerSaveBlockerType type, const std::string& reason) |
| 331 : delegate_(new Delegate(type, reason)) { | 330 : delegate_(new Delegate(type, reason)) { |
| 332 delegate_->Init(); | 331 delegate_->Init(); |
| 333 } | 332 } |
| 334 | 333 |
| 335 PowerSaveBlockerImpl::~PowerSaveBlockerImpl() { | 334 PowerSaveBlockerImpl::~PowerSaveBlockerImpl() { |
| 336 delegate_->CleanUp(); | 335 delegate_->CleanUp(); |
| 337 } | 336 } |
| 338 | 337 |
| 339 } // namespace content | 338 } // namespace content |
| OLD | NEW |