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

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: Use deque instead of list 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..3199a7e44bdcc2cb0d458d424d6303410d7fc9da 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,27 @@ 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
+ // |kSampleCountTimeLimitSec| are stored in memory.
Daniel Erat 2014/01/10 21:44:14 nit: kSampleTimeLimitSec
Siva Chandra 2014/01/10 22:18:09 Done.
+ static const unsigned int kSampleTimeLimitSec;
+
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 |kSampleCountTimeLimitSec| or more older than
Daniel Erat 2014/01/10 21:44:14 nit: kSampleTimeLimitSec
Siva Chandra 2014/01/10 22:18:09 Done.
+ // |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