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

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
« 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..bea6bd5fc81e3aa915587a46aef93b3e926b4d81 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:
Daniel Erat 2014/01/10 23:05:32 nit: comment was correct before; this just describ
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 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_|.
Daniel Erat 2014/01/10 23:05:32 nit: s/Add/Adds/
+ // 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);
};
« 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