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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_ 5 #ifndef CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_
6 #define CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_ 6 #define CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_
7 7
8 #include <vector> 8 #include <deque>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "chromeos/chromeos_export.h" 14 #include "chromeos/chromeos_export.h"
14 #include "chromeos/dbus/power_manager_client.h" 15 #include "chromeos/dbus/power_manager_client.h"
15 16
16 namespace power_manager { 17 namespace power_manager {
17 class PowerSupplyProperties; 18 class PowerSupplyProperties;
18 } 19 }
19 20
20 namespace chromeos { 21 namespace chromeos {
21 22
(...skipping 10 matching lines...) Expand all
32 // Time when the snapshot was captured. 33 // Time when the snapshot was captured.
33 base::TimeTicks time; 34 base::TimeTicks time;
34 35
35 // True if connected to external power at the time of the snapshot. 36 // True if connected to external power at the time of the snapshot.
36 bool external_power; 37 bool external_power;
37 38
38 // The battery charge as a percentage of full charge in range [0.0, 100.00]. 39 // The battery charge as a percentage of full charge in range [0.0, 100.00].
39 double battery_percent; 40 double battery_percent;
40 }; 41 };
41 42
42 const std::vector<PowerSupplySnapshot>& power_supply_data() const { 43 const std::deque<PowerSupplySnapshot>& power_supply_data() const {
43 return power_supply_data_; 44 return power_supply_data_;
44 } 45 }
45 46
46 // Can be called only after DBusThreadManager is initialized. 47 // Can be called only after DBusThreadManager is initialized.
47 static void Initialize(); 48 static void Initialize();
48 49
49 // Can be called only if initialized via Initialize, and before 50 // Can be called only if initialized via Initialize, and before
50 // DBusThreadManager is destroyed. 51 // DBusThreadManager is destroyed.
51 static void Shutdown(); 52 static void Shutdown();
52 53
53 // Returns the global instance of PowerDataCollector. 54 // Returns the global instance of PowerDataCollector.
54 static PowerDataCollector* Get(); 55 static PowerDataCollector* Get();
55 56
56 // PowerManagerClient::Observer implementation: 57 // PowerManagerClient::Observer::PowerChanged implementation:
57 virtual void PowerChanged( 58 virtual void PowerChanged(
58 const power_manager::PowerSupplyProperties& prop) OVERRIDE; 59 const power_manager::PowerSupplyProperties& prop) OVERRIDE;
59 60
61 // Only those power data samples which fall within the last
62 // |kSampleCountTimeLimitSec| are stored in memory.
Daniel Erat 2014/01/10 21:44:14 nit: kSampleTimeLimitSec
Siva Chandra 2014/01/10 22:18:09 Done.
63 static const unsigned int kSampleTimeLimitSec;
64
60 private: 65 private:
66 FRIEND_TEST_ALL_PREFIXES(PowerDataCollectorTest, AddSnapshot);
67
61 PowerDataCollector(); 68 PowerDataCollector();
62 69
63 virtual ~PowerDataCollector(); 70 virtual ~PowerDataCollector();
64 71
65 std::vector<PowerSupplySnapshot> power_supply_data_; 72 // Add a snapshot to |power_supply_data_|.
73 // 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.
74 // |snapshot|.
75 void AddSnapshot(const PowerSupplySnapshot& snapshot);
76
77 std::deque<PowerSupplySnapshot> power_supply_data_;
66 78
67 DISALLOW_COPY_AND_ASSIGN(PowerDataCollector); 79 DISALLOW_COPY_AND_ASSIGN(PowerDataCollector);
68 }; 80 };
69 81
70 } // namespace chromeos 82 } // namespace chromeos
71 83
72 #endif // CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_ 84 #endif // CHROMEOS_POWER_POWER_DATA_COLLECTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698