| 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 "chromeos/dbus/power_manager_client.h" | 5 #include "chromeos/dbus/power_manager_client.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 protobuf.set_disable_lid_suspend(overrides & DISABLE_IDLE_LID_SUSPEND); | 266 protobuf.set_disable_lid_suspend(overrides & DISABLE_IDLE_LID_SUSPEND); |
| 267 | 267 |
| 268 writer.AppendProtoAsArrayOfBytes(protobuf); | 268 writer.AppendProtoAsArrayOfBytes(protobuf); |
| 269 power_manager_proxy_->CallMethod( | 269 power_manager_proxy_->CallMethod( |
| 270 &method_call, | 270 &method_call, |
| 271 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 271 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 272 base::Bind(&PowerManagerClientImpl::OnPowerStateOverride, | 272 base::Bind(&PowerManagerClientImpl::OnPowerStateOverride, |
| 273 weak_ptr_factory_.GetWeakPtr(), callback)); | 273 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 274 } | 274 } |
| 275 | 275 |
| 276 virtual void SetIsProjecting(bool is_projecting) OVERRIDE { |
| 277 dbus::MethodCall method_call( |
| 278 power_manager::kPowerManagerInterface, |
| 279 power_manager::kSetIsProjectingMethod); |
| 280 dbus::MessageWriter writer(&method_call); |
| 281 writer.AppendBool(is_projecting); |
| 282 power_manager_proxy_->CallMethod( |
| 283 &method_call, |
| 284 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 285 dbus::ObjectProxy::EmptyResponseCallback()); |
| 286 } |
| 287 |
| 276 virtual void NotifyScreenLockCompleted() OVERRIDE { | 288 virtual void NotifyScreenLockCompleted() OVERRIDE { |
| 277 SimpleMethodCallToPowerManager(power_manager::kScreenIsLockedMethod); | 289 SimpleMethodCallToPowerManager(power_manager::kScreenIsLockedMethod); |
| 278 } | 290 } |
| 279 | 291 |
| 280 virtual void NotifyScreenUnlockCompleted() OVERRIDE { | 292 virtual void NotifyScreenUnlockCompleted() OVERRIDE { |
| 281 SimpleMethodCallToPowerManager(power_manager::kScreenIsUnlockedMethod); | 293 SimpleMethodCallToPowerManager(power_manager::kScreenIsUnlockedMethod); |
| 282 } | 294 } |
| 283 | 295 |
| 284 private: | 296 private: |
| 285 // Called when a dbus signal is initially connected. | 297 // Called when a dbus signal is initially connected. |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 virtual void RequestActiveNotification() OVERRIDE {} | 615 virtual void RequestActiveNotification() OVERRIDE {} |
| 604 virtual void NotifyUserActivity( | 616 virtual void NotifyUserActivity( |
| 605 const base::TimeTicks& last_activity_time) OVERRIDE {} | 617 const base::TimeTicks& last_activity_time) OVERRIDE {} |
| 606 virtual void NotifyVideoActivity( | 618 virtual void NotifyVideoActivity( |
| 607 const base::TimeTicks& last_activity_time) OVERRIDE {} | 619 const base::TimeTicks& last_activity_time) OVERRIDE {} |
| 608 virtual void RequestPowerStateOverrides( | 620 virtual void RequestPowerStateOverrides( |
| 609 uint32 request_id, | 621 uint32 request_id, |
| 610 uint32 duration, | 622 uint32 duration, |
| 611 int overrides, | 623 int overrides, |
| 612 const PowerStateRequestIdCallback& callback) OVERRIDE {} | 624 const PowerStateRequestIdCallback& callback) OVERRIDE {} |
| 625 virtual void SetIsProjecting(bool is_projecting) OVERRIDE {} |
| 613 | 626 |
| 614 virtual void NotifyScreenLockCompleted() OVERRIDE {} | 627 virtual void NotifyScreenLockCompleted() OVERRIDE {} |
| 615 virtual void NotifyScreenUnlockCompleted() OVERRIDE {} | 628 virtual void NotifyScreenUnlockCompleted() OVERRIDE {} |
| 616 | 629 |
| 617 private: | 630 private: |
| 618 void Update() { | 631 void Update() { |
| 619 if (pause_count_ > 0) { | 632 if (pause_count_ > 0) { |
| 620 pause_count_--; | 633 pause_count_--; |
| 621 } else { | 634 } else { |
| 622 int discharge_amt = battery_percentage_ <= 10 ? 1 : 10; | 635 int discharge_amt = battery_percentage_ <= 10 ? 1 : 10; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 PowerManagerClient* PowerManagerClient::Create( | 684 PowerManagerClient* PowerManagerClient::Create( |
| 672 DBusClientImplementationType type, | 685 DBusClientImplementationType type, |
| 673 dbus::Bus* bus) { | 686 dbus::Bus* bus) { |
| 674 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 687 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 675 return new PowerManagerClientImpl(bus); | 688 return new PowerManagerClientImpl(bus); |
| 676 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 689 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 677 return new PowerManagerClientStubImpl(); | 690 return new PowerManagerClientStubImpl(); |
| 678 } | 691 } |
| 679 | 692 |
| 680 } // namespace chromeos | 693 } // namespace chromeos |
| OLD | NEW |