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

Unified Diff: chrome/browser/performance_monitor/database.cc

Issue 10860017: Refactor Metrics (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 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: chrome/browser/performance_monitor/database.cc
diff --git a/chrome/browser/performance_monitor/database.cc b/chrome/browser/performance_monitor/database.cc
index da8722efaf552737818f481a42c437d7f7d8ba67..e71771055be71384380a7ffb26d0a6a93f47b2f8 100644
--- a/chrome/browser/performance_monitor/database.cc
+++ b/chrome/browser/performance_monitor/database.cc
@@ -275,10 +275,10 @@ Database::EventList Database::GetEvents(EventType type, const base::Time& start,
return events;
}
-Database::EventTypeSet Database::GetEventTypes(const base::Time& start,
+std::set<EventType> Database::GetEventTypes(const base::Time& start,
const base::Time& end) {
CHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- EventTypeSet results;
+ std::set<EventType> results;
std::string start_key = CreateEventKey(start, EVENT_UNDEFINED);
std::string end_key = CreateEventKey(end, EVENT_NUMBER_OF_EVENTS);
scoped_ptr<leveldb::Iterator> it(event_db_->NewIterator(read_options_));
@@ -311,10 +311,9 @@ bool Database::AddMetric(const std::string& activity, MetricType metric,
return recent_status.ok() && metric_status.ok();
}
-std::vector<const MetricDetails*> Database::GetActiveMetrics(
+std::set<MetricType> Database::GetActiveMetrics(
eaugusti 2012/08/17 21:06:04 typedef std::set<MetricType> MetricTypeSet;
const base::Time& start, const base::Time& end) {
CHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- std::vector<const MetricDetails*> results;
std::string recent_start_key = CreateRecentKey(
start, static_cast<MetricType>(0), std::string());
std::string recent_end_key = CreateRecentKey(
@@ -358,24 +357,21 @@ std::vector<const MetricDetails*> Database::GetActiveMetrics(
active_metrics.insert(*possible_it);
}
}
- std::set<MetricType>::iterator it;
- for (it = active_metrics.begin(); it != active_metrics.end(); ++it)
- results.push_back(GetMetricDetails(*it));
- return results;
+ return active_metrics;
}
-std::vector<std::string> Database::GetActiveActivities(
- MetricType metric_type, const base::Time& start) {
+std::set<std::string> Database::GetActiveActivities(MetricType metric_type,
+ const base::Time& start) {
CHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- std::vector<std::string> results;
+ std::set<std::string> results;
std::string start_key = CreateRecentKey(
start, static_cast<MetricType>(0), std::string());
scoped_ptr<leveldb::Iterator> it(recent_db_->NewIterator(read_options_));
for (it->Seek(start_key); it->Valid(); it->Next()) {
RecentKey split_key = SplitRecentKey(it->key().ToString());
if (split_key.type == metric_type)
- results.push_back(split_key.activity);
+ results.insert(split_key.activity);
}
return results;
}
@@ -383,7 +379,7 @@ std::vector<std::string> Database::GetActiveActivities(
bool Database::GetRecentStatsForActivityAndMetric(
const std::string& activity,
MetricType metric,
- MetricInfo* info) {
+ Metric* info) {
CHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
std::string recent_map_key = CreateRecentMapKey(metric, activity);
if (!ContainsKey(recent_map_, recent_map_key))
@@ -393,15 +389,15 @@ bool Database::GetRecentStatsForActivityAndMetric(
std::string result;
leveldb::Status status = recent_db_->Get(read_options_, recent_key, &result);
if (status.ok())
- *info = MetricInfo(SplitRecentKey(recent_key).time, result);
+ *info = Metric(SplitRecentKey(recent_key).time, result);
return status.ok();
}
-Database::MetricInfoVector Database::GetStatsForActivityAndMetric(
+std::vector<Metric> Database::GetStatsForActivityAndMetric(
const std::string& activity, MetricType metric_type,
const base::Time& start, const base::Time& end) {
CHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
- MetricInfoVector results;
+ std::vector<Metric> results;
std::string start_key = CreateMetricKey(start, metric_type, activity);
std::string end_key = CreateMetricKey(end, metric_type, activity);
scoped_ptr<leveldb::Iterator> it(metric_db_->NewIterator(read_options_));
@@ -410,7 +406,7 @@ Database::MetricInfoVector Database::GetStatsForActivityAndMetric(
it->Next()) {
MetricKey split_key = SplitMetricKey(it->key().ToString());
if (split_key.activity == activity)
- results.push_back(MetricInfo(split_key.time, it->value().ToString()));
+ results.push_back(Metric(split_key.time, it->value().ToString()));
}
return results;
}
@@ -428,10 +424,10 @@ Database::MetricVectorMap Database::GetStatsForMetricByActivity(
MetricKey split_key = SplitMetricKey(it->key().ToString());
if (!results[split_key.activity].get()) {
results[split_key.activity] =
- linked_ptr<MetricInfoVector>(new MetricInfoVector());
+ linked_ptr<std::vector<Metric> >(new std::vector<Metric>());
}
results[split_key.activity]->push_back(
- MetricInfo(split_key.time, it->value().ToString()));
+ Metric(split_key.time, it->value().ToString()));
}
return results;
}

Powered by Google App Engine
This is Rietveld 408576698