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

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: using the ContainsKey() method 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..da8722efaf552737818f481a42c437d7f7d8ba67 100644
--- a/chrome/browser/performance_monitor/database.cc
+++ b/chrome/browser/performance_monitor/database.cc
@@ -11,6 +11,7 @@
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/path_service.h"
+#include "base/stl_util.h"
#include "base/string_number_conversions.h"
#include "base/string_split.h"
#include "base/stringprintf.h"
@@ -379,6 +380,23 @@ 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 (!ContainsKey(recent_map_, recent_map_key))
+ return false;
+ std::string recent_key = recent_map_[recent_map_key];
+
+ std::string result;
+ leveldb::Status status = recent_db_->Get(read_options_, recent_key, &result);
+ if (status.ok())
+ *info = MetricInfo(SplitRecentKey(recent_key).time, result);
+ return status.ok();
+}
+
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