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

Unified Diff: ash/system/chromeos/emulator/battery_emulation_controller.h

Issue 1206733002: ChromeOs Power Emulation Impl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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: ash/system/chromeos/emulator/battery_emulation_controller.h
diff --git a/ash/system/chromeos/emulator/battery_emulation_controller.h b/ash/system/chromeos/emulator/battery_emulation_controller.h
new file mode 100644
index 0000000000000000000000000000000000000000..427b444d0aa9cde1a0f882663b0d67ed89674665
--- /dev/null
+++ b/ash/system/chromeos/emulator/battery_emulation_controller.h
@@ -0,0 +1,104 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef ASH_SYSTEM_CHROMEOS_EMULATOR_BATTERY_EMULATION_CONTROLLER_H_
+#define ASH_SYSTEM_CHROMEOS_EMULATOR_BATTERY_EMULATION_CONTROLLER_H_
+
+#include "ash/ash_export.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"
+#include "chromeos/dbus/power_manager/suspend.pb.h"
+#include "chromeos/dbus/power_manager_client.h"
+
+namespace ash {
+class ASH_EXPORT BatteryEmulationController
+ : public chromeos::PowerManagerClient {
+ public:
+ BatteryEmulationController();
+
+ ~BatteryEmulationController() override;
+
+ int num_pending_suspend_readiness_callbacks() const {
+ return num_pending_suspend_readiness_callbacks_;
+ }
+
+ void Init(dbus::Bus* bus) override;
+
+ void AddObserver(Observer* observer) override;
+ void RemoveObserver(Observer* observer) override;
+ bool HasObserver(const Observer* observer) const override;
+ void SetRenderProcessManagerDelegate(
+ base::WeakPtr<RenderProcessManagerDelegate> delegate) override {}
+
+ void SetBatteryCharging(bool charge);
+ void SetBatteryPercentage(int percentage);
+ void SetBatteryFullTimeToEmpty(int time_in_hours);
+ void SetExternalPower(int power_source);
+ void SetIsCalculatingBatteryTime(bool calculating);
+
+ void DecreaseScreenBrightness(bool allow_off) override;
+ void IncreaseScreenBrightness() override;
+
+ void SetScreenBrightnessPercent(double percent, bool gradual) override;
+ void GetScreenBrightnessPercent(
+ const chromeos::GetScreenBrightnessPercentCallback& callback) override;
+
+ void DecreaseKeyboardBrightness() override;
+ void IncreaseKeyboardBrightness() override;
+
+ void RequestStatusUpdate() override;
+ void RequestSuspend() override {}
+ void RequestRestart() override {}
+ void RequestShutdown() override {}
+
+ void NotifyUserActivity(power_manager::UserActivityType type) override {}
+ void NotifyVideoActivity(bool is_fullscreen) override {}
+
+ void SetPolicy(const power_manager::PowerManagementPolicy& policy) override {}
+ void SetIsProjecting(bool is_projecting) override {}
+ base::Closure GetSuspendReadinessCallback() override;
+ int GetNumPendingSuspendReadinessCallbacks() override;
+
+ void UpdateStatus();
+
+ private:
+ void HandleSuspendReadiness();
+
+ void SetBrightness(double percent, bool user_initiated);
+
+ void ParseCommandLineSwitch();
+
+ void ParseOption(const std::string& arg0, const std::string& arg1);
+
+ base::TimeDelta power_cycle_delay_; // Time over which to cycle power state
+ bool discharging_;
+ double brightness_;
+ int battery_percentage_;
+ bool is_calculating_;
+ int power_source_;
+ base::ObserverList<Observer> observers_;
+ base::RepeatingTimer<BatteryEmulationController> update_timer_;
+ power_manager::PowerSupplyProperties props_;
+
+ int hours_to_empty_full_battery = 4 * 60 * 60; // 4 hours.
+
+ // Number of callbacks returned by GetSuspendReadinessCallback() but not yet
+ // invoked.
+ int num_pending_suspend_readiness_callbacks_;
+
+ // 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<BatteryEmulationController> weak_ptr_factory_;
+};
+}
+
+#endif // ASH_SYSTEM_CHROMEOS_EMULATOR_CHROMEOS_BATTERY_EMULATION_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698