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

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

Issue 10843010: Adds a method to the Performance Monitor Database to fetch the most recent metric. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: added comment Created 8 years, 5 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 8eb135080a00cedf9b51c82893712d7fc4520b0b..8cb2dbf4a2cdcce47d99d9282e8cae10c8039fb2 100644
--- a/chrome/browser/performance_monitor/database.cc
+++ b/chrome/browser/performance_monitor/database.cc
@@ -379,6 +379,29 @@ std::vector<std::string> Database::GetActiveActivities(
return results;
}
+bool Database::GetRecentStatsForActivityAndMetric(
+ const std::string& activity,
+ MetricType metric,
+ MetricInfo* info) {
+ CHECK(!content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
+ std::string recent_map_key = CreateRecentMapKey(metric, activity);
+ if (!recent_map_.count(recent_map_key))
+ return false;
+ std::string recent_start_key = recent_map_[recent_map_key];
eaugusti 2012/07/31 18:46:06 Not really a "start" key, just a key.
chebert 2012/07/31 19:26:36 Done.
+
+ scoped_ptr<leveldb::Iterator> it(recent_db_->NewIterator(read_options_));
eaugusti 2012/07/31 18:46:06 Maybe use Get() instead of an iterator: http://lev
chebert 2012/07/31 19:26:36 Done.
+
+ it->Seek(recent_start_key);
+ if (it->Valid()) {
+ RecentKey split_key = SplitRecentKey(it->key().ToString());
+ if (split_key.activity == activity) {
+ *info = MetricInfo(split_key.time, it->value().ToString());
+ return true;
+ }
+ }
+ return false;
+}
+
Database::MetricInfoVector Database::GetStatsForActivityAndMetric(
const std::string& activity, MetricType metric_type,
const base::Time& start, const base::Time& end) {
« no previous file with comments | « chrome/browser/performance_monitor/database.h ('k') | chrome/browser/performance_monitor/database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698