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

Unified Diff: chromeos/power/power_data_collector.h

Issue 101963004: [chromeos] New PowerManagerClient observer to collect power data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | « chromeos/chromeos.gyp ('k') | chromeos/power/power_data_collector.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/power/power_data_collector.h
diff --git a/chromeos/power/power_data_collector.h b/chromeos/power/power_data_collector.h
new file mode 100644
index 0000000000000000000000000000000000000000..1eced6eb0a37e81665b24d8f72c14124d9d661f1
--- /dev/null
+++ b/chromeos/power/power_data_collector.h
@@ -0,0 +1,72 @@
+// Copyright (c) 2013 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 CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_
+#define CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "base/time/time.h"
+#include "chromeos/chromeos_export.h"
+#include "chromeos/dbus/power_manager_client.h"
+
+namespace power_manager {
+class PowerSupplyProperties;
+}
+
+namespace chromeos {
+
+// A class which starts collecting power metrics, like the battery charge, as
+// soon as it is initialized via Initialize().
+//
+// This class is implemented as a global singleton, initialized after
+// DBusThreadManager which it depends on.
+class CHROMEOS_EXPORT PowerDataCollector : public PowerManagerClient::Observer {
+ public:
+ struct PowerSupplySnapshot {
+ PowerSupplySnapshot();
+
+ // Time when the snapshot was captured.
+ base::TimeTicks time;
+
+ // True if connected to external power at the time of the snapshot.
+ bool external_power;
+
+ // The battery charge as a percentage of full charge in range [0.0, 100.00].
+ double battery_percent;
+ };
+
+ const std::vector<PowerSupplySnapshot>& power_supply_data() const {
+ return power_supply_data_;
+ }
+
+ // Can be called only after DBusThreadManager is initialized.
+ static void Initialize();
+
+ // Can be called only if initialized via Initialize, and before
+ // DBusThreadManager is destroyed.
+ static void Shutdown();
+
+ // Returns the global instance of PowerDataCollector.
+ static PowerDataCollector* Get();
+
+ // PowerManagerClient::Observer implementation:
+ virtual void PowerChanged(
+ const power_manager::PowerSupplyProperties& prop) OVERRIDE;
+
+ private:
+ PowerDataCollector();
+
+ virtual ~PowerDataCollector();
+
+ std::vector<PowerSupplySnapshot> power_supply_data_;
+
+ DISALLOW_COPY_AND_ASSIGN(PowerDataCollector);
+};
+
+} // namespace chromeos
+
+#endif // CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_
« no previous file with comments | « chromeos/chromeos.gyp ('k') | chromeos/power/power_data_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698