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

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: 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
« no previous file with comments | « chrome/browser/ui/webui/chromeos/power_ui.cc ('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
index 581faa0edf9163088547f8ff823d96f8d4a410a2..73faff1e7ee62bd5c9ccb32bd52533c1ddcfadce 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 <list>
#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::list<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.
+ static const unsigned int kSampleCountTimeLimitSec;
Daniel Erat 2014/01/10 19:40:19 nit: remove "count" from the name? (at least, it d
Siva Chandra 2014/01/10 20:19:21 Done.
+
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
+ // |snapshot|.
+ void AddSnapshot(const PowerSupplySnapshot& snapshot);
+
+ std::list<PowerSupplySnapshot> power_supply_data_;
Daniel Erat 2014/01/10 19:40:19 using std::list (which is a double-linked list) wi
Daniel Erat 2014/01/10 19:50:32 actually, just using std::deque is probably the be
Siva Chandra 2014/01/10 20:19:21 I was about to ask you about deque! Your last com
Daniel Erat 2014/01/10 21:44:13 well, i meant not to stress about keeping one day
DISALLOW_COPY_AND_ASSIGN(PowerDataCollector);
};
« no previous file with comments | « chrome/browser/ui/webui/chromeos/power_ui.cc ('k') | chromeos/power/power_data_collector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698