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

Unified Diff: chromeos/dbus/fake_power_manager_client.h

Issue 1206733002: ChromeOs Power Emulation Impl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved impl to exsiting FakePowerManagerClient class Created 5 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 | « no previous file | chromeos/dbus/fake_power_manager_client.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/dbus/fake_power_manager_client.h
diff --git a/chromeos/dbus/fake_power_manager_client.h b/chromeos/dbus/fake_power_manager_client.h
index d6cd0429f975b899ec2a64fc8f8158dce391a83d..72843fb67209a637579e4081c8d7194186ff993e 100644
--- a/chromeos/dbus/fake_power_manager_client.h
+++ b/chromeos/dbus/fake_power_manager_client.h
@@ -7,10 +7,16 @@
#include <string>
stevenjb 2015/06/26 20:42:19 We should keep <string> since we use it (even thou
-#include "base/basictypes.h"
-#include "base/macros.h"
+#include "base/command_line.h"
#include "base/observer_list.h"
+#include "base/power_monitor/power_monitor_device_source.h"
+#include "base/strings/string_number_conversions.h"
+#include "base/strings/string_split.h"
+#include "chromeos/chromeos_switches.h"
+#include "chromeos/dbus/power_manager/input_event.pb.h"
+#include "chromeos/dbus/power_manager/peripheral_battery_status.pb.h"
#include "chromeos/dbus/power_manager/policy.pb.h"
+#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
stevenjb 2015/06/25 17:03:47 It doesn't look like we need most of these in the
#include "chromeos/dbus/power_manager/suspend.pb.h"
#include "chromeos/dbus/power_manager_client.h"
@@ -67,16 +73,41 @@ class FakePowerManagerClient : public PowerManagerClient {
// Notifies observers that the power button has been pressed or released.
void SendPowerButtonEvent(bool down, const base::TimeTicks& timestamp);
+ // Emulates the changes in various power settings.
+ void UpdateBatteryPercentage(int percentage);
+ void UpdateBatteryFullTimeToEmpty(int time_in_hours);
+ void UpdateExternalPower(int external_power);
+ void UpdateIsBatteryCharging(bool is_charging);
+ void UpdateIsCalculatingBatteryTime(bool is_calculating);
+
+ // Called once any power states are changed to notify the observer of the
+ // change.
+ void UpdatePowerStatus();
+
private:
// Callback that will be run by asynchronous suspend delays to report
// readiness.
void HandleSuspendReadiness();
+ void ParseCommandLineSwitch();
+
+ void ParseOption(const std::string& arg0, const std::string& arg1);
+
base::ObserverList<Observer> observers_;
// Last policy passed to SetPolicy().
power_manager::PowerManagementPolicy policy_;
+ // The power properties set for for the UI.
+ power_manager::PowerSupplyProperties props_;
+
+ // Variables that handle states of the battery and power.
+ bool is_charging_;
+ bool is_calculating_;
+ int battery_percentage_;
+ int power_source_;
+ int hours_to_empty_full_battery = 4 * 60 * 60; // 4 hours. default value.
stevenjb 2015/06/25 17:03:47 We should use inline initialization for all of the
+
// Number of times that various methods have been called.
int num_request_restart_calls_;
int num_request_shutdown_calls_;
@@ -92,6 +123,10 @@ class FakePowerManagerClient : public PowerManagerClient {
// Delegate for managing power consumption of Chrome's renderer processes.
base::WeakPtr<RenderProcessManagerDelegate> render_process_manager_delegate_;
+ // Note: This should remain the last member so it'll be destroyed and
+ // invalidate its weak pointers before any other members are destroyed.
+ base::WeakPtrFactory<FakePowerManagerClient> weak_ptr_factory_;
+
DISALLOW_COPY_AND_ASSIGN(FakePowerManagerClient);
};
« no previous file with comments | « no previous file | chromeos/dbus/fake_power_manager_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698