| 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" |
| 11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/metrics/histogram.h" | |
| 14 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 15 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
| 16 #include "base/time.h" | 15 #include "base/time.h" |
| 17 #include "base/timer.h" | 16 #include "base/timer.h" |
| 18 #include "chromeos/dbus/power_state_control.pb.h" | 17 #include "chromeos/dbus/power_state_control.pb.h" |
| 19 #include "chromeos/dbus/power_supply_properties.pb.h" | 18 #include "chromeos/dbus/power_supply_properties.pb.h" |
| 20 #include "dbus/bus.h" | 19 #include "dbus/bus.h" |
| 21 #include "dbus/message.h" | 20 #include "dbus/message.h" |
| 22 #include "dbus/object_path.h" | 21 #include "dbus/object_path.h" |
| 23 #include "dbus/object_proxy.h" | 22 #include "dbus/object_proxy.h" |
| 24 #include "third_party/cros_system_api/dbus/service_constants.h" | 23 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 25 | 24 |
| 26 namespace chromeos { | 25 namespace chromeos { |
| 27 | 26 |
| 28 // The PowerManagerClient implementation used in production. | 27 // The PowerManagerClient implementation used in production. |
| 29 class PowerManagerClientImpl : public PowerManagerClient { | 28 class PowerManagerClientImpl : public PowerManagerClient { |
| 30 public: | 29 public: |
| 31 enum LockScreensState { | |
| 32 LOCK_SCREEN_REQUESTED, // Lock screen is requested. | |
| 33 LOCK_SCREEN_REQUEST_SUCCEEDED, // Method call succeeded. | |
| 34 LOCK_SCREEN_REQUEST_FAILED, // Method call failed. | |
| 35 LOCK_SCREEN_FINISHED, // Signal is received. | |
| 36 NUM_LOCK_SCREEN_STATES | |
| 37 }; | |
| 38 | |
| 39 enum UnlockScreensState { | |
| 40 UNLOCK_SCREEN_REQUESTED, // Unlock screen is requested. | |
| 41 UNLOCK_SCREEN_REQUEST_SUCCEEDED, // Method call succeeded. | |
| 42 UNLOCK_SCREEN_REQUEST_FAILED, // Method call failed. | |
| 43 UNLOCK_SCREEN_FINISHED, // Signal is received. | |
| 44 NUM_UNLOCK_SCREEN_STATES | |
| 45 }; | |
| 46 | |
| 47 explicit PowerManagerClientImpl(dbus::Bus* bus) | 30 explicit PowerManagerClientImpl(dbus::Bus* bus) |
| 48 : power_manager_proxy_(NULL), | 31 : power_manager_proxy_(NULL), |
| 49 screen_locked_(false), | |
| 50 weak_ptr_factory_(this) { | 32 weak_ptr_factory_(this) { |
| 51 power_manager_proxy_ = bus->GetObjectProxy( | 33 power_manager_proxy_ = bus->GetObjectProxy( |
| 52 power_manager::kPowerManagerServiceName, | 34 power_manager::kPowerManagerServiceName, |
| 53 dbus::ObjectPath(power_manager::kPowerManagerServicePath)); | 35 dbus::ObjectPath(power_manager::kPowerManagerServicePath)); |
| 54 | 36 |
| 55 session_manager_proxy_ = bus->GetObjectProxy( | 37 session_manager_proxy_ = bus->GetObjectProxy( |
| 56 login_manager::kSessionManagerServiceName, | 38 login_manager::kSessionManagerServiceName, |
| 57 dbus::ObjectPath(login_manager::kSessionManagerServicePath)); | 39 dbus::ObjectPath(login_manager::kSessionManagerServicePath)); |
| 58 | 40 |
| 59 // Monitor the D-Bus signal for brightness changes. Only the power | 41 // Monitor the D-Bus signal for brightness changes. Only the power |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 weak_ptr_factory_.GetWeakPtr())); | 74 weak_ptr_factory_.GetWeakPtr())); |
| 93 | 75 |
| 94 power_manager_proxy_->ConnectToSignal( | 76 power_manager_proxy_->ConnectToSignal( |
| 95 power_manager::kPowerManagerInterface, | 77 power_manager::kPowerManagerInterface, |
| 96 power_manager::kButtonEventSignal, | 78 power_manager::kButtonEventSignal, |
| 97 base::Bind(&PowerManagerClientImpl::ButtonEventSignalReceived, | 79 base::Bind(&PowerManagerClientImpl::ButtonEventSignalReceived, |
| 98 weak_ptr_factory_.GetWeakPtr()), | 80 weak_ptr_factory_.GetWeakPtr()), |
| 99 base::Bind(&PowerManagerClientImpl::SignalConnected, | 81 base::Bind(&PowerManagerClientImpl::SignalConnected, |
| 100 weak_ptr_factory_.GetWeakPtr())); | 82 weak_ptr_factory_.GetWeakPtr())); |
| 101 | 83 |
| 102 session_manager_proxy_->ConnectToSignal( | |
| 103 chromium::kChromiumInterface, | |
| 104 chromium::kLockScreenSignal, | |
| 105 base::Bind(&PowerManagerClientImpl::ScreenLockSignalReceived, | |
| 106 weak_ptr_factory_.GetWeakPtr()), | |
| 107 base::Bind(&PowerManagerClientImpl::SignalConnected, | |
| 108 weak_ptr_factory_.GetWeakPtr())); | |
| 109 | |
| 110 session_manager_proxy_->ConnectToSignal( | |
| 111 chromium::kChromiumInterface, | |
| 112 chromium::kUnlockScreenSignal, | |
| 113 base::Bind(&PowerManagerClientImpl::ScreenUnlockSignalReceived, | |
| 114 weak_ptr_factory_.GetWeakPtr()), | |
| 115 base::Bind(&PowerManagerClientImpl::SignalConnected, | |
| 116 weak_ptr_factory_.GetWeakPtr())); | |
| 117 | |
| 118 power_manager_proxy_->ConnectToSignal( | 84 power_manager_proxy_->ConnectToSignal( |
| 119 power_manager::kPowerManagerInterface, | 85 power_manager::kPowerManagerInterface, |
| 120 power_manager::kIdleNotifySignal, | 86 power_manager::kIdleNotifySignal, |
| 121 base::Bind(&PowerManagerClientImpl::IdleNotifySignalReceived, | 87 base::Bind(&PowerManagerClientImpl::IdleNotifySignalReceived, |
| 122 weak_ptr_factory_.GetWeakPtr()), | 88 weak_ptr_factory_.GetWeakPtr()), |
| 123 base::Bind(&PowerManagerClientImpl::SignalConnected, | 89 base::Bind(&PowerManagerClientImpl::SignalConnected, |
| 124 weak_ptr_factory_.GetWeakPtr())); | 90 weak_ptr_factory_.GetWeakPtr())); |
| 125 | 91 |
| 126 power_manager_proxy_->ConnectToSignal( | 92 power_manager_proxy_->ConnectToSignal( |
| 127 power_manager::kPowerManagerInterface, | 93 power_manager::kPowerManagerInterface, |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 protobuf.set_disable_lid_suspend(overrides & DISABLE_IDLE_LID_SUSPEND); | 258 protobuf.set_disable_lid_suspend(overrides & DISABLE_IDLE_LID_SUSPEND); |
| 293 | 259 |
| 294 writer.AppendProtoAsArrayOfBytes(protobuf); | 260 writer.AppendProtoAsArrayOfBytes(protobuf); |
| 295 power_manager_proxy_->CallMethod( | 261 power_manager_proxy_->CallMethod( |
| 296 &method_call, | 262 &method_call, |
| 297 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 263 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 298 base::Bind(&PowerManagerClientImpl::OnPowerStateOverride, | 264 base::Bind(&PowerManagerClientImpl::OnPowerStateOverride, |
| 299 weak_ptr_factory_.GetWeakPtr(), callback)); | 265 weak_ptr_factory_.GetWeakPtr(), callback)); |
| 300 } | 266 } |
| 301 | 267 |
| 302 virtual void NotifyScreenLockRequested() OVERRIDE { | |
| 303 dbus::MethodCall method_call(power_manager::kPowerManagerInterface, | |
| 304 power_manager::kRequestLockScreenMethod); | |
| 305 UMA_HISTOGRAM_ENUMERATION("LockScreen.LockScreenPath", | |
| 306 LOCK_SCREEN_REQUESTED, | |
| 307 NUM_LOCK_SCREEN_STATES); | |
| 308 power_manager_proxy_->CallMethodWithErrorCallback( | |
| 309 &method_call, | |
| 310 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | |
| 311 base::Bind(&PowerManagerClientImpl::OnScreenLockRequested, | |
| 312 weak_ptr_factory_.GetWeakPtr()), | |
| 313 base::Bind(&PowerManagerClientImpl::OnScreenLockRequestedError, | |
| 314 weak_ptr_factory_.GetWeakPtr())); | |
| 315 } | |
| 316 | |
| 317 virtual void NotifyScreenLockCompleted() OVERRIDE { | 268 virtual void NotifyScreenLockCompleted() OVERRIDE { |
| 318 SimpleMethodCallToPowerManager(power_manager::kScreenIsLockedMethod); | 269 SimpleMethodCallToPowerManager(power_manager::kScreenIsLockedMethod); |
| 319 } | 270 } |
| 320 | 271 |
| 321 virtual void NotifyScreenUnlockRequested() OVERRIDE { | |
| 322 dbus::MethodCall method_call(power_manager::kPowerManagerInterface, | |
| 323 power_manager::kRequestUnlockScreenMethod); | |
| 324 UMA_HISTOGRAM_ENUMERATION("LockScreen.UnlockScreenPath", | |
| 325 UNLOCK_SCREEN_REQUESTED, | |
| 326 NUM_UNLOCK_SCREEN_STATES); | |
| 327 power_manager_proxy_->CallMethodWithErrorCallback( | |
| 328 &method_call, | |
| 329 dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | |
| 330 base::Bind(&PowerManagerClientImpl::OnScreenUnlockRequested, | |
| 331 weak_ptr_factory_.GetWeakPtr()), | |
| 332 base::Bind(&PowerManagerClientImpl::OnScreenUnlockRequestedError, | |
| 333 weak_ptr_factory_.GetWeakPtr())); | |
| 334 } | |
| 335 | |
| 336 virtual void NotifyScreenUnlockCompleted() OVERRIDE { | 272 virtual void NotifyScreenUnlockCompleted() OVERRIDE { |
| 337 SimpleMethodCallToPowerManager(power_manager::kScreenIsUnlockedMethod); | 273 SimpleMethodCallToPowerManager(power_manager::kScreenIsUnlockedMethod); |
| 338 } | 274 } |
| 339 | 275 |
| 340 virtual bool GetIsScreenLocked() OVERRIDE { | |
| 341 return screen_locked_; | |
| 342 } | |
| 343 | |
| 344 private: | 276 private: |
| 345 // Called when a dbus signal is initially connected. | 277 // Called when a dbus signal is initially connected. |
| 346 void SignalConnected(const std::string& interface_name, | 278 void SignalConnected(const std::string& interface_name, |
| 347 const std::string& signal_name, | 279 const std::string& signal_name, |
| 348 bool success) { | 280 bool success) { |
| 349 LOG_IF(WARNING, !success) << "Failed to connect to signal " | 281 LOG_IF(WARNING, !success) << "Failed to connect to signal " |
| 350 << signal_name << "."; | 282 << signal_name << "."; |
| 351 } | 283 } |
| 352 | 284 |
| 353 // Make a method call to power manager with no arguments and no response. | 285 // Make a method call to power manager with no arguments and no response. |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 if (!reader.PopUint32(&request_id)) { | 428 if (!reader.PopUint32(&request_id)) { |
| 497 LOG(ERROR) << "Error reading response from powerd: " | 429 LOG(ERROR) << "Error reading response from powerd: " |
| 498 << response->ToString(); | 430 << response->ToString(); |
| 499 callback.Run(0); | 431 callback.Run(0); |
| 500 return; | 432 return; |
| 501 } | 433 } |
| 502 | 434 |
| 503 callback.Run(request_id); | 435 callback.Run(request_id); |
| 504 } | 436 } |
| 505 | 437 |
| 506 void OnScreenLockRequested(dbus::Response* response) { | |
| 507 UMA_HISTOGRAM_ENUMERATION("LockScreen.LockScreenPath", | |
| 508 LOCK_SCREEN_REQUEST_SUCCEEDED, | |
| 509 NUM_LOCK_SCREEN_STATES); | |
| 510 } | |
| 511 | |
| 512 void OnScreenLockRequestedError(dbus::ErrorResponse* error_response) { | |
| 513 if (error_response) { | |
| 514 dbus::MessageReader reader(error_response); | |
| 515 std::string error_message; | |
| 516 reader.PopString(&error_message); | |
| 517 LOG(ERROR) << "Failed to call ScreenLockRequested: " | |
| 518 << error_response->GetErrorName() | |
| 519 << ": " << error_message; | |
| 520 } | |
| 521 UMA_HISTOGRAM_ENUMERATION("LockScreen.LockScreenPath", | |
| 522 LOCK_SCREEN_REQUEST_FAILED, | |
| 523 NUM_LOCK_SCREEN_STATES); | |
| 524 } | |
| 525 | |
| 526 void OnScreenUnlockRequested(dbus::Response* response) { | |
| 527 UMA_HISTOGRAM_ENUMERATION("LockScreen.UnlockScreenPath", | |
| 528 UNLOCK_SCREEN_REQUEST_SUCCEEDED, | |
| 529 NUM_UNLOCK_SCREEN_STATES); | |
| 530 } | |
| 531 | |
| 532 void OnScreenUnlockRequestedError(dbus::ErrorResponse* error_response) { | |
| 533 if (error_response) { | |
| 534 dbus::MessageReader reader(error_response); | |
| 535 std::string error_message; | |
| 536 reader.PopString(&error_message); | |
| 537 LOG(ERROR) << "Failed to call ScreenUnlockRequested: " | |
| 538 << error_response->GetErrorName() | |
| 539 << ": " << error_message; | |
| 540 } | |
| 541 UMA_HISTOGRAM_ENUMERATION("LockScreen.UnlockScreenPath", | |
| 542 UNLOCK_SCREEN_REQUEST_FAILED, | |
| 543 NUM_UNLOCK_SCREEN_STATES); | |
| 544 } | |
| 545 | |
| 546 | |
| 547 void OnGetScreenBrightnessPercent( | 438 void OnGetScreenBrightnessPercent( |
| 548 const GetScreenBrightnessPercentCallback& callback, | 439 const GetScreenBrightnessPercentCallback& callback, |
| 549 dbus::Response* response) { | 440 dbus::Response* response) { |
| 550 if (!response) { | 441 if (!response) { |
| 551 LOG(ERROR) << "Error calling " | 442 LOG(ERROR) << "Error calling " |
| 552 << power_manager::kGetScreenBrightnessPercent; | 443 << power_manager::kGetScreenBrightnessPercent; |
| 553 return; | 444 return; |
| 554 } | 445 } |
| 555 dbus::MessageReader reader(response); | 446 dbus::MessageReader reader(response); |
| 556 double percent = 0.0; | 447 double percent = 0.0; |
| 557 if (!reader.PopDouble(&percent)) | 448 if (!reader.PopDouble(&percent)) |
| 558 LOG(ERROR) << "Error reading response from powerd: " | 449 LOG(ERROR) << "Error reading response from powerd: " |
| 559 << response->ToString(); | 450 << response->ToString(); |
| 560 callback.Run(percent); | 451 callback.Run(percent); |
| 561 } | 452 } |
| 562 | 453 |
| 563 void ScreenLockSignalReceived(dbus::Signal* signal) { | |
| 564 // TODO(flackr): This warning is actually a signal that things are working | |
| 565 // as expected. As per http://crbug.com/126217, this will help determine | |
| 566 // if the problem is with dbus or in chrome. | |
| 567 LOG(WARNING) << "LockScreen signal received from power manager."; | |
| 568 screen_locked_ = true; | |
| 569 UMA_HISTOGRAM_ENUMERATION("LockScreen.LockScreenPath", | |
| 570 LOCK_SCREEN_FINISHED, | |
| 571 NUM_LOCK_SCREEN_STATES); | |
| 572 FOR_EACH_OBSERVER(Observer, observers_, LockScreen()); | |
| 573 } | |
| 574 | |
| 575 void ScreenUnlockSignalReceived(dbus::Signal* signal) { | |
| 576 screen_locked_ = false; | |
| 577 UMA_HISTOGRAM_ENUMERATION("LockScreen.UnlockScreenPath", | |
| 578 UNLOCK_SCREEN_FINISHED, | |
| 579 NUM_UNLOCK_SCREEN_STATES); | |
| 580 FOR_EACH_OBSERVER(Observer, observers_, UnlockScreen()); | |
| 581 } | |
| 582 | |
| 583 void IdleNotifySignalReceived(dbus::Signal* signal) { | 454 void IdleNotifySignalReceived(dbus::Signal* signal) { |
| 584 dbus::MessageReader reader(signal); | 455 dbus::MessageReader reader(signal); |
| 585 int64 threshold = 0; | 456 int64 threshold = 0; |
| 586 if (!reader.PopInt64(&threshold)) { | 457 if (!reader.PopInt64(&threshold)) { |
| 587 LOG(ERROR) << "Idle Notify signal had incorrect parameters: " | 458 LOG(ERROR) << "Idle Notify signal had incorrect parameters: " |
| 588 << signal->ToString(); | 459 << signal->ToString(); |
| 589 return; | 460 return; |
| 590 } | 461 } |
| 591 DCHECK_GT(threshold, 0); | 462 DCHECK_GT(threshold, 0); |
| 592 | 463 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 break; | 498 break; |
| 628 default: | 499 default: |
| 629 LOG(ERROR) << "Unhandled screen dimming state " << signal_state; | 500 LOG(ERROR) << "Unhandled screen dimming state " << signal_state; |
| 630 } | 501 } |
| 631 FOR_EACH_OBSERVER(Observer, observers_, ScreenDimmingRequested(state)); | 502 FOR_EACH_OBSERVER(Observer, observers_, ScreenDimmingRequested(state)); |
| 632 } | 503 } |
| 633 | 504 |
| 634 dbus::ObjectProxy* power_manager_proxy_; | 505 dbus::ObjectProxy* power_manager_proxy_; |
| 635 dbus::ObjectProxy* session_manager_proxy_; | 506 dbus::ObjectProxy* session_manager_proxy_; |
| 636 ObserverList<Observer> observers_; | 507 ObserverList<Observer> observers_; |
| 637 bool screen_locked_; | |
| 638 base::WeakPtrFactory<PowerManagerClientImpl> weak_ptr_factory_; | 508 base::WeakPtrFactory<PowerManagerClientImpl> weak_ptr_factory_; |
| 639 | 509 |
| 640 DISALLOW_COPY_AND_ASSIGN(PowerManagerClientImpl); | 510 DISALLOW_COPY_AND_ASSIGN(PowerManagerClientImpl); |
| 641 }; | 511 }; |
| 642 | 512 |
| 643 // The PowerManagerClient implementation used on Linux desktop, | 513 // The PowerManagerClient implementation used on Linux desktop, |
| 644 // which does nothing. | 514 // which does nothing. |
| 645 class PowerManagerClientStubImpl : public PowerManagerClient { | 515 class PowerManagerClientStubImpl : public PowerManagerClient { |
| 646 public: | 516 public: |
| 647 PowerManagerClientStubImpl() | 517 PowerManagerClientStubImpl() |
| 648 : discharging_(true), | 518 : discharging_(true), |
| 649 battery_percentage_(40), | 519 battery_percentage_(40), |
| 650 brightness_(50.0), | 520 brightness_(50.0), |
| 651 pause_count_(2), | 521 pause_count_(2) { |
| 652 screen_locked_(false) { | |
| 653 } | 522 } |
| 654 | 523 |
| 655 virtual ~PowerManagerClientStubImpl() {} | 524 virtual ~PowerManagerClientStubImpl() {} |
| 656 | 525 |
| 657 // PowerManagerClient overrides: | 526 // PowerManagerClient overrides: |
| 658 | 527 |
| 659 virtual void AddObserver(Observer* observer) OVERRIDE { | 528 virtual void AddObserver(Observer* observer) OVERRIDE { |
| 660 observers_.AddObserver(observer); | 529 observers_.AddObserver(observer); |
| 661 } | 530 } |
| 662 | 531 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 virtual void NotifyUserActivity( | 588 virtual void NotifyUserActivity( |
| 720 const base::TimeTicks& last_activity_time) OVERRIDE {} | 589 const base::TimeTicks& last_activity_time) OVERRIDE {} |
| 721 virtual void NotifyVideoActivity( | 590 virtual void NotifyVideoActivity( |
| 722 const base::TimeTicks& last_activity_time) OVERRIDE {} | 591 const base::TimeTicks& last_activity_time) OVERRIDE {} |
| 723 virtual void RequestPowerStateOverrides( | 592 virtual void RequestPowerStateOverrides( |
| 724 uint32 request_id, | 593 uint32 request_id, |
| 725 uint32 duration, | 594 uint32 duration, |
| 726 int overrides, | 595 int overrides, |
| 727 const PowerStateRequestIdCallback& callback) OVERRIDE {} | 596 const PowerStateRequestIdCallback& callback) OVERRIDE {} |
| 728 | 597 |
| 729 virtual void NotifyScreenLockRequested() OVERRIDE { | |
| 730 screen_locked_ = true; | |
| 731 FOR_EACH_OBSERVER(Observer, observers_, LockScreen()); | |
| 732 } | |
| 733 virtual void NotifyScreenLockCompleted() OVERRIDE {} | 598 virtual void NotifyScreenLockCompleted() OVERRIDE {} |
| 734 virtual void NotifyScreenUnlockRequested() OVERRIDE { | |
| 735 screen_locked_ = false; | |
| 736 FOR_EACH_OBSERVER(Observer, observers_, UnlockScreen()); | |
| 737 } | |
| 738 virtual void NotifyScreenUnlockCompleted() OVERRIDE {} | 599 virtual void NotifyScreenUnlockCompleted() OVERRIDE {} |
| 739 virtual bool GetIsScreenLocked() OVERRIDE { | |
| 740 return screen_locked_; | |
| 741 } | |
| 742 | 600 |
| 743 private: | 601 private: |
| 744 void Update() { | 602 void Update() { |
| 745 if (pause_count_ > 0) { | 603 if (pause_count_ > 0) { |
| 746 pause_count_--; | 604 pause_count_--; |
| 747 } else { | 605 } else { |
| 748 int discharge_amt = battery_percentage_ <= 10 ? 1 : 10; | 606 int discharge_amt = battery_percentage_ <= 10 ? 1 : 10; |
| 749 battery_percentage_ += (discharging_ ? -discharge_amt : discharge_amt); | 607 battery_percentage_ += (discharging_ ? -discharge_amt : discharge_amt); |
| 750 battery_percentage_ = std::min(std::max(battery_percentage_, 0), 100); | 608 battery_percentage_ = std::min(std::max(battery_percentage_, 0), 100); |
| 751 // We pause at 0 and 100% so that it's easier to check those conditions. | 609 // We pause at 0 and 100% so that it's easier to check those conditions. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 779 BrightnessChanged(brightness_level, user_initiated)); | 637 BrightnessChanged(brightness_level, user_initiated)); |
| 780 } | 638 } |
| 781 | 639 |
| 782 bool discharging_; | 640 bool discharging_; |
| 783 int battery_percentage_; | 641 int battery_percentage_; |
| 784 double brightness_; | 642 double brightness_; |
| 785 int pause_count_; | 643 int pause_count_; |
| 786 ObserverList<Observer> observers_; | 644 ObserverList<Observer> observers_; |
| 787 base::RepeatingTimer<PowerManagerClientStubImpl> timer_; | 645 base::RepeatingTimer<PowerManagerClientStubImpl> timer_; |
| 788 PowerSupplyStatus status_; | 646 PowerSupplyStatus status_; |
| 789 bool screen_locked_; | |
| 790 }; | 647 }; |
| 791 | 648 |
| 792 PowerManagerClient::PowerManagerClient() { | 649 PowerManagerClient::PowerManagerClient() { |
| 793 } | 650 } |
| 794 | 651 |
| 795 PowerManagerClient::~PowerManagerClient() { | 652 PowerManagerClient::~PowerManagerClient() { |
| 796 } | 653 } |
| 797 | 654 |
| 798 PowerManagerClient* PowerManagerClient::Create( | 655 PowerManagerClient* PowerManagerClient::Create( |
| 799 DBusClientImplementationType type, | 656 DBusClientImplementationType type, |
| 800 dbus::Bus* bus) { | 657 dbus::Bus* bus) { |
| 801 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 658 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 802 return new PowerManagerClientImpl(bus); | 659 return new PowerManagerClientImpl(bus); |
| 803 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 660 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 804 return new PowerManagerClientStubImpl(); | 661 return new PowerManagerClientStubImpl(); |
| 805 } | 662 } |
| 806 | 663 |
| 807 } // namespace chromeos | 664 } // namespace chromeos |
| OLD | NEW |