Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/dbus/power_manager_client.h" | 5 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 pause_count_ = 20; | 304 pause_count_ = 20; |
| 305 return; | 305 return; |
| 306 } | 306 } |
| 307 } | 307 } |
| 308 battery_percentage_ += (discharging_ ? -1 : 1); | 308 battery_percentage_ += (discharging_ ? -1 : 1); |
| 309 | 309 |
| 310 PowerSupplyStatus status; | 310 PowerSupplyStatus status; |
| 311 status.line_power_on = !discharging_; | 311 status.line_power_on = !discharging_; |
| 312 status.battery_is_present = true; | 312 status.battery_is_present = true; |
| 313 status.battery_percentage = battery_percentage_; | 313 status.battery_percentage = battery_percentage_; |
| 314 // We don't want to go to low because we don't want a low battery | |
| 315 // notification to pop up. | |
| 314 status.battery_seconds_to_empty = | 316 status.battery_seconds_to_empty = |
| 315 std::max(1, battery_percentage_ * 180 / 100); | 317 std::max(16, battery_percentage_ * 180 / 100); |
|
satorux1
2011/11/14 22:03:05
Why did we end up showing the low battery balloon
satorux1
2011/11/14 22:10:41
FWIW, it used to be 3 hours, but changed to 180 se
| |
| 316 status.battery_seconds_to_full = | 318 status.battery_seconds_to_full = |
| 317 std::max(static_cast<int64>(1), 180 - status.battery_seconds_to_empty); | 319 std::max(static_cast<int64>(1), 180 - status.battery_seconds_to_empty); |
| 318 | 320 |
| 319 FOR_EACH_OBSERVER(Observer, observers_, PowerChanged(status)); | 321 FOR_EACH_OBSERVER(Observer, observers_, PowerChanged(status)); |
| 320 } | 322 } |
| 321 | 323 |
| 322 bool discharging_; | 324 bool discharging_; |
| 323 int battery_percentage_; | 325 int battery_percentage_; |
| 324 int pause_count_; | 326 int pause_count_; |
| 325 ObserverList<Observer> observers_; | 327 ObserverList<Observer> observers_; |
| 326 base::RepeatingTimer<PowerManagerClientStubImpl> timer_; | 328 base::RepeatingTimer<PowerManagerClientStubImpl> timer_; |
| 327 }; | 329 }; |
| 328 | 330 |
| 329 PowerManagerClient::PowerManagerClient() { | 331 PowerManagerClient::PowerManagerClient() { |
| 330 } | 332 } |
| 331 | 333 |
| 332 PowerManagerClient::~PowerManagerClient() { | 334 PowerManagerClient::~PowerManagerClient() { |
| 333 } | 335 } |
| 334 | 336 |
| 335 PowerManagerClient* PowerManagerClient::Create(dbus::Bus* bus) { | 337 PowerManagerClient* PowerManagerClient::Create(dbus::Bus* bus) { |
| 336 if (system::runtime_environment::IsRunningOnChromeOS()) { | 338 if (system::runtime_environment::IsRunningOnChromeOS()) { |
| 337 return new PowerManagerClientImpl(bus); | 339 return new PowerManagerClientImpl(bus); |
| 338 } else { | 340 } else { |
| 339 return new PowerManagerClientStubImpl(); | 341 return new PowerManagerClientStubImpl(); |
| 340 } | 342 } |
| 341 } | 343 } |
| 342 | 344 |
| 343 } // namespace chromeos | 345 } // namespace chromeos |
| OLD | NEW |