Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Unified Diff: chromeos/dbus/power_manager_client.cc

Issue 18176013: chromeos: Refactor system tray code into PowerStatus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove virtual Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/system/chromeos/settings/tray_settings.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/power_manager_client.cc
diff --git a/chromeos/dbus/power_manager_client.cc b/chromeos/dbus/power_manager_client.cc
index 5998e5c8a3f457f54c7373d1111bf3f7db003457..1cab12b31d90471e88b74b8c376fb11a0d42e552 100644
--- a/chromeos/dbus/power_manager_client.cc
+++ b/chromeos/dbus/power_manager_client.cc
@@ -804,24 +804,28 @@ class PowerManagerClientStubImpl : public PowerManagerClient {
void UpdateStatus() {
if (pause_count_ > 0) {
pause_count_--;
+ if (pause_count_ == 2)
+ discharging_ = !discharging_;
} else {
- int discharge_amt = battery_percentage_ <= 10 ? 1 : 10;
- battery_percentage_ += (discharging_ ? -discharge_amt : discharge_amt);
+ if (discharging_)
+ battery_percentage_ -= (battery_percentage_ <= 10 ? 1 : 10);
+ else
+ battery_percentage_ += (battery_percentage_ >= 10 ? 10 : 1);
battery_percentage_ = std::min(std::max(battery_percentage_, 0), 100);
// We pause at 0 and 100% so that it's easier to check those conditions.
if (battery_percentage_ == 0 || battery_percentage_ == 100) {
- discharging_ = !discharging_;
pause_count_ = 4;
if (battery_percentage_ == 100)
cycle_count_ = (cycle_count_ + 1) % 3;
}
}
- const int kSecondsToEmptyFullBattery(3 * 60 * 60); // 3 hours.
+ const int kSecondsToEmptyFullBattery = 3 * 60 * 60; // 3 hours.
status_.is_calculating_battery_time = (pause_count_ > 1);
status_.line_power_on = !discharging_;
status_.battery_is_present = true;
status_.battery_percentage = battery_percentage_;
+ status_.battery_is_full = battery_percentage_ == 100 && !discharging_;
if (cycle_count_ != 2) {
status_.battery_state = discharging_ ?
PowerSupplyStatus::DISCHARGING : PowerSupplyStatus::CHARGING;
« no previous file with comments | « ash/system/chromeos/settings/tray_settings.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698