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

Unified Diff: chrome/browser/performance_monitor/performance_monitor.h

Issue 10656052: Performance monitor stats gathering. (Closed) Base URL: http://git.chromium.org/chromium/src.git@cpm_main
Patch Set: Changes per comments 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/performance_monitor.h
diff --git a/chrome/browser/performance_monitor/performance_monitor.h b/chrome/browser/performance_monitor/performance_monitor.h
index 3a900813981989c2b9ab352d7c0db51ab2c35d96..227595d326838577ca313b6b8be0571c2174091e 100644
--- a/chrome/browser/performance_monitor/performance_monitor.h
+++ b/chrome/browser/performance_monitor/performance_monitor.h
@@ -6,10 +6,15 @@
#define CHROME_BROWSER_PERFORMANCE_MONITOR_PERFORMANCE_MONITOR_H_
#pragma once
+#include <map>
+#include <string>
+
#include "base/callback.h"
#include "base/file_path.h"
#include "base/memory/scoped_ptr.h"
#include "base/memory/singleton.h"
+#include "base/process.h"
+#include "base/process_util.h"
#include "chrome/browser/performance_monitor/database.h"
#include "chrome/browser/performance_monitor/event.h"
#include "content/public/browser/notification_details.h"
@@ -24,6 +29,9 @@ class PerformanceMonitor : public content::NotificationObserver {
public:
typedef base::Callback<void(const std::string&)> StateValueCallback;
+ typedef std::map<base::ProcessId,
+ linked_ptr<base::ProcessMetrics> > MetricsMap;
+
// Set the path which the PerformanceMonitor should use for the database files
// constructed. This must be done prior to the initialization of the
// PerformanceMonitor. Returns true on success, false on failure (failure
@@ -43,6 +51,19 @@ class PerformanceMonitor : public content::NotificationObserver {
// it has been updated. If it has, insert an event in the database.
void CheckForVersionUpdate();
+ // Gathers CPU usage and memory usage of all Chrome processes.
+ void GatherStatistics();
+
+ // Gathers the CPU usage of every process that has been running since the
+ // last call to GatherStatistics().
Devlin 2012/07/11 16:28:08 Make the helpers private?
mitchellwrosen 2012/07/11 18:30:18 Done.
+ void GatherCPUUsage();
+
+ // Gathers the memory usage of every process in the current list of processes.
+ void GatherMemoryUsage();
+
+ // Updates the ProcessMetrics map with the current list of processes.
+ void UpdateMetricsMap();
+
// content::NotificationObserver
// Wait for various notifications; insert events into the database upon
// occurance.
@@ -81,6 +102,14 @@ class PerformanceMonitor : public content::NotificationObserver {
void AddEventOnBackgroundThread(scoped_ptr<Event> event);
+ // Wrapper function for inserting metrics into the database.
+ void AddMetric(const std::string& key, const std::string& value);
+
+ void AddMetricOnBackgroundThread(const std::string& key,
+ const std::string& value);
+
+ MetricsMap metrics_map_;
+
// The location at which the database files are stored; if empty, the database
// will default to '<user_data_dir>/performance_monitor_dbs'.
FilePath database_path_;

Powered by Google App Engine
This is Rietveld 408576698