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

Side by Side Diff: chrome/browser/performance_monitor/database.h

Issue 10915318: Revert 157168 - Add guards to metric values; erase bad events/metrics from db (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_BROWSER_PERFORMANCE_MONITOR_DATABASE_H_ 5 #ifndef CHROME_BROWSER_PERFORMANCE_MONITOR_DATABASE_H_
6 #define CHROME_BROWSER_PERFORMANCE_MONITOR_DATABASE_H_ 6 #define CHROME_BROWSER_PERFORMANCE_MONITOR_DATABASE_H_
7 7
8 #include <vector> 8 #include <vector>
9 #include <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 13 matching lines...) Expand all
24 struct TimeRange { 24 struct TimeRange {
25 TimeRange(); 25 TimeRange();
26 TimeRange(base::Time start_time, base::Time end_time); 26 TimeRange(base::Time start_time, base::Time end_time);
27 ~TimeRange(); 27 ~TimeRange();
28 28
29 base::Time start; 29 base::Time start;
30 base::Time end; 30 base::Time end;
31 }; 31 };
32 32
33 class KeyBuilder; 33 class KeyBuilder;
34 class DatabaseTestHelper;
35 34
36 // The class supporting all performance monitor storage. This class wraps 35 // The class supporting all performance monitor storage. This class wraps
37 // multiple leveldb::DB objects. All methods must be called from a background 36 // multiple leveldb::DB objects. All methods must be called from a background
38 // thread. Callers should use BrowserThread::PostBlockingPoolSequencedTask using 37 // thread. Callers should use BrowserThread::PostBlockingPoolSequencedTask using
39 // performance_monitor::kDBSequenceToken as the sequence token. 38 // performance_monitor::kDBSequenceToken as the sequence token.
40 // 39 //
41 // Different schemas are used for the different leveldb::DB's based off of the 40 // Different schemas are used for the different leveldb::DB's based off of the
42 // structure of the data and the common ways that it will need to be accessed. 41 // structure of the data and the common ways that it will need to be accessed.
43 // The following specifies the schema of each type of leveldb::DB. Delimiters 42 // The following specifies the schema of each type of leveldb::DB. Delimiters
44 // are denoted with a '-'. 43 // are denoted with a '-'.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 return GetEvents(EVENT_UNDEFINED, base::Time(), clock_->GetTime()); 145 return GetEvents(EVENT_UNDEFINED, base::Time(), clock_->GetTime());
147 } 146 }
148 147
149 EventTypeSet GetEventTypes(const base::Time& start, const base::Time& end); 148 EventTypeSet GetEventTypes(const base::Time& start, const base::Time& end);
150 149
151 EventTypeSet GetEventTypes() { 150 EventTypeSet GetEventTypes() {
152 return GetEventTypes(base::Time(), clock_->GetTime()); 151 return GetEventTypes(base::Time(), clock_->GetTime());
153 } 152 }
154 153
155 // Add a metric instance to the database. 154 // Add a metric instance to the database.
156 bool AddMetric(const std::string& activity, const Metric& metric); 155 bool AddMetric(const std::string& activity,
156 MetricType metric_type,
157 const std::string& value);
157 158
158 bool AddMetric(const Metric& metric) { 159 bool AddMetric(MetricType metric_type, const std::string& value) {
159 return AddMetric(kProcessChromeAggregate, metric); 160 return AddMetric(kProcessChromeAggregate, metric_type, value);
160 } 161 }
161 162
162 // Get the metrics that are active for the given process between |start| 163 // Get the metrics that are active for the given process between |start|
163 // (inclusive) and |end| (exclusive). 164 // (inclusive) and |end| (exclusive).
164 MetricTypeSet GetActiveMetrics(const base::Time& start, 165 MetricTypeSet GetActiveMetrics(const base::Time& start,
165 const base::Time& end); 166 const base::Time& end);
166 167
167 // Get the activities that are active for the given metric after |start|. 168 // Get the activities that are active for the given metric after |start|.
168 std::set<std::string> GetActiveActivities(MetricType metric_type, 169 std::set<std::string> GetActiveActivities(MetricType metric_type,
169 const base::Time& start); 170 const base::Time& start);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 std::vector<TimeRange> GetActiveIntervals(const base::Time& start, 229 std::vector<TimeRange> GetActiveIntervals(const base::Time& start,
229 const base::Time& end); 230 const base::Time& end);
230 231
231 FilePath path() const { return path_; } 232 FilePath path() const { return path_; }
232 233
233 void set_clock(scoped_ptr<Clock> clock) { 234 void set_clock(scoped_ptr<Clock> clock) {
234 clock_ = clock.Pass(); 235 clock_ = clock.Pass();
235 } 236 }
236 237
237 private: 238 private:
238 friend class DatabaseTestHelper; 239 FRIEND_TEST_ALL_PREFIXES(PerformanceMonitorDatabaseSetupTest, OpenClose);
240 FRIEND_TEST_ALL_PREFIXES(PerformanceMonitorDatabaseSetupTest, ActiveInterval);
239 241
240 typedef std::map<std::string, std::string> RecentMap; 242 typedef std::map<std::string, std::string> RecentMap;
241 typedef std::map<std::string, double> MaxValueMap; 243 typedef std::map<std::string, double> MaxValueMap;
242 244
243 // By default, the database uses a clock that simply returns the current time. 245 // By default, the database uses a clock that simply returns the current time.
244 class SystemClock : public Clock { 246 class SystemClock : public Clock {
245 public: 247 public:
246 SystemClock() {} 248 SystemClock() {}
247 virtual ~SystemClock() {} 249 virtual ~SystemClock() {}
248 virtual base::Time GetTime() OVERRIDE; 250 virtual base::Time GetTime() OVERRIDE;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 303
302 leveldb::ReadOptions read_options_; 304 leveldb::ReadOptions read_options_;
303 leveldb::WriteOptions write_options_; 305 leveldb::WriteOptions write_options_;
304 306
305 DISALLOW_COPY_AND_ASSIGN(Database); 307 DISALLOW_COPY_AND_ASSIGN(Database);
306 }; 308 };
307 309
308 } // namespace performance_monitor 310 } // namespace performance_monitor
309 311
310 #endif // CHROME_BROWSER_PERFORMANCE_MONITOR_DATABASE_H_ 312 #endif // CHROME_BROWSER_PERFORMANCE_MONITOR_DATABASE_H_
OLDNEW
« no previous file with comments | « chrome/browser/performance_monitor/constants.cc ('k') | chrome/browser/performance_monitor/database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698