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

Unified Diff: chromeos/power/power_data_collector.h

Issue 134623002: [chromeos] Limit the data samples stored by PowerDataCollector. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 6 years, 11 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/power/power_data_collector.h
diff --git a/chromeos/power/power_data_collector.h b/chromeos/power/power_data_collector.h
index 581faa0edf9163088547f8ff823d96f8d4a410a2..13b176ab8d6fc7e2fada1d99bc424b6f92af319d 100644
--- a/chromeos/power/power_data_collector.h
+++ b/chromeos/power/power_data_collector.h
@@ -5,10 +5,11 @@
#ifndef CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_
#define CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_
-#include <vector>
+#include <deque>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
+#include "base/gtest_prod_util.h"
#include "base/time/time.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/power_manager_client.h"
@@ -39,7 +40,7 @@ class CHROMEOS_EXPORT PowerDataCollector : public PowerManagerClient::Observer {
double battery_percent;
};
- const std::vector<PowerSupplySnapshot>& power_supply_data() const {
+ const std::deque<PowerSupplySnapshot>& power_supply_data() const {
return power_supply_data_;
}
@@ -53,16 +54,26 @@ class CHROMEOS_EXPORT PowerDataCollector : public PowerManagerClient::Observer {
// Returns the global instance of PowerDataCollector.
static PowerDataCollector* Get();
- // PowerManagerClient::Observer implementation:
+ // PowerManagerClient::Observer::PowerChanged implementation:
virtual void PowerChanged(
const power_manager::PowerSupplyProperties& prop) OVERRIDE;
+ // Only those power data samples which fall within the last
+ // |kSampleTimeLimitSec| are stored in memory.
+ static const unsigned int kSampleTimeLimitSec;
Daniel Erat 2014/01/10 22:28:47 nit: using 'static const int' here should be fine
Siva Chandra 2014/01/10 22:54:53 Done. I am assuming you are saying that the 'unsig
Daniel Erat 2014/01/10 23:05:32 yeah, that's correct
+
private:
+ FRIEND_TEST_ALL_PREFIXES(PowerDataCollectorTest, AddSnapshot);
+
PowerDataCollector();
virtual ~PowerDataCollector();
- std::vector<PowerSupplySnapshot> power_supply_data_;
+ // Add a snapshot to |power_supply_data_|.
+ // It dumps snapshots |kSampleTimeLimitSec| or more older than |snapshot|.
+ void AddSnapshot(const PowerSupplySnapshot& snapshot);
+
+ std::deque<PowerSupplySnapshot> power_supply_data_;
DISALLOW_COPY_AND_ASSIGN(PowerDataCollector);
};

Powered by Google App Engine
This is Rietveld 408576698