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

Side by Side Diff: chromeos/dbus/power_manager_client.cc

Issue 9983002: Pass correct initial/user values when requesting power status (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add SystemTrayDelegate::RequestStatusUpdate Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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
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
OLDNEW
« ash/system/power/tray_power.cc ('K') | « chrome/browser/chromeos/system/ash_system_tray_delegate.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698