| 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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 if (pause_count_) { | 568 if (pause_count_) { |
| 569 pause_count_ = 0; | 569 pause_count_ = 0; |
| 570 discharging_ = !discharging_; | 570 discharging_ = !discharging_; |
| 571 } else { | 571 } else { |
| 572 // Pause twice (i.e. skip updating the menu), including the current | 572 // Pause twice (i.e. skip updating the menu), including the current |
| 573 // call to this function. | 573 // call to this function. |
| 574 pause_count_ = 2; | 574 pause_count_ = 2; |
| 575 return; | 575 return; |
| 576 } | 576 } |
| 577 } | 577 } |
| 578 battery_percentage_ += (discharging_ ? -1 : 1); | 578 battery_percentage_ += (discharging_ ? -5 : 5); |
| 579 battery_percentage_ = std::min(std::max(battery_percentage_, 0), 100); |
| 579 | 580 |
| 580 const int kSecondsToEmptyFullBattery(3 * 60 * 60); // 3 hours. | 581 const int kSecondsToEmptyFullBattery(3 * 60 * 60); // 3 hours. |
| 581 | 582 |
| 582 PowerSupplyStatus status; | 583 PowerSupplyStatus status; |
| 583 status.line_power_on = !discharging_; | 584 status.line_power_on = !discharging_; |
| 584 status.battery_is_present = true; | 585 status.battery_is_present = true; |
| 585 status.battery_percentage = battery_percentage_; | 586 status.battery_percentage = battery_percentage_; |
| 586 status.battery_seconds_to_empty = | 587 status.battery_seconds_to_empty = |
| 587 std::max(1, battery_percentage_ * kSecondsToEmptyFullBattery / 100); | 588 std::max(1, battery_percentage_ * kSecondsToEmptyFullBattery / 100); |
| 588 status.battery_seconds_to_full = | 589 status.battery_seconds_to_full = |
| (...skipping 19 matching lines...) Expand all Loading... |
| 608 PowerManagerClient* PowerManagerClient::Create( | 609 PowerManagerClient* PowerManagerClient::Create( |
| 609 DBusClientImplementationType type, | 610 DBusClientImplementationType type, |
| 610 dbus::Bus* bus) { | 611 dbus::Bus* bus) { |
| 611 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 612 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) |
| 612 return new PowerManagerClientImpl(bus); | 613 return new PowerManagerClientImpl(bus); |
| 613 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 614 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
| 614 return new PowerManagerClientStubImpl(); | 615 return new PowerManagerClientStubImpl(); |
| 615 } | 616 } |
| 616 | 617 |
| 617 } // namespace chromeos | 618 } // namespace chromeos |
| OLD | NEW |