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

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: Updated init and includes. Fixed RequestUpdate 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
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..ae0a5e5f6260bb5c92fe6bf210677a9d91cf4274 100644
--- a/chromeos/dbus/fake_power_manager_client.h
+++ b/chromeos/dbus/fake_power_manager_client.h
@@ -5,12 +5,9 @@
#ifndef CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_
#define CHROMEOS_DBUS_FAKE_POWER_MANAGER_CLIENT_H_
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/macros.h"
#include "base/observer_list.h"
#include "chromeos/dbus/power_manager/policy.pb.h"
+#include "chromeos/dbus/power_manager/power_supply_properties.pb.h"
#include "chromeos/dbus/power_manager/suspend.pb.h"
#include "chromeos/dbus/power_manager_client.h"
@@ -67,16 +64,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 hours. default value.
stevenjb 2015/06/26 20:42:19 nit: Comment should be in the .cc file.
mozartalouis 2015/06/26 21:13:03 Done.
+
// Number of times that various methods have been called.
int num_request_restart_calls_;
int num_request_shutdown_calls_;
@@ -92,6 +114,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') | chromeos/dbus/fake_power_manager_client.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698