Index: chrome/browser/performance_monitor/performance_monitor.cc |
diff --git a/chrome/browser/performance_monitor/performance_monitor.cc b/chrome/browser/performance_monitor/performance_monitor.cc |
index 38f7192ca207bead318ace9cd48800521db71a54..57db0abaedb2d3acc62ce550f376ed1f09aee12a 100644 |
--- a/chrome/browser/performance_monitor/performance_monitor.cc |
+++ b/chrome/browser/performance_monitor/performance_monitor.cc |
@@ -61,7 +61,10 @@ bool StringToTime(std::string time, base::Time* output) { |
namespace performance_monitor { |
-PerformanceMonitor::PerformanceMonitor() : database_(NULL) { |
+bool PerformanceMonitor::enabled_ = false; |
+ |
+PerformanceMonitor::PerformanceMonitor() : bytes_read_(0), |
+ database_(NULL) { |
} |
PerformanceMonitor::~PerformanceMonitor() { |
@@ -94,6 +97,12 @@ void PerformanceMonitor::Start() { |
void PerformanceMonitor::InitOnBackgroundThread() { |
CHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
database_ = Database::Create(database_path_); |
+ |
+ // Initialize bytes_read_ to the value in the database; if there isn't a |
+ // recording in the database, bytes_read_ stays at 0. |
+ MetricInfo info; |
+ if (database_->GetRecentStatsForActivityAndMetric(METRIC_BYTES_READ, &info)) |
+ bytes_read_ = info.value; |
} |
void PerformanceMonitor::FinishInit() { |
@@ -244,11 +253,15 @@ void PerformanceMonitor::NotifyInitialized() { |
chrome::NOTIFICATION_PERFORMANCE_MONITOR_INITIALIZED, |
content::Source<PerformanceMonitor>(this), |
content::NotificationService::NoDetails()); |
+ |
+ enabled_ = true; |
Yoyo Zhou
2012/08/18 01:48:56
It might be a little misleading to have this be se
Devlin
2012/08/21 19:46:46
Done.
|
} |
void PerformanceMonitor::GatherStatisticsOnBackgroundThread() { |
CHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ database_->AddMetric(METRIC_BYTES_READ, base::Int64ToString(bytes_read_)); |
+ |
// Because the CPU usage is gathered as an average since the last time the |
// function was called, while the memory usage is gathered as an instantaneous |
// usage, the CPU usage is gathered before the metrics map is wiped. |
@@ -362,6 +375,16 @@ void PerformanceMonitor::UpdateLiveProfilesHelper( |
void PerformanceMonitor::DoTimedCollections() { |
UpdateLiveProfiles(); |
+ |
+ BrowserThread::PostBlockingPoolSequencedTask( |
+ Database::kDatabaseSequenceToken, |
+ FROM_HERE, |
+ base::Bind(&PerformanceMonitor::GatherStatisticsOnBackgroundThread, |
+ base::Unretained(this))); |
+} |
+ |
+void PerformanceMonitor::BytesRead(int bytes_read) { |
eaugusti
2012/08/21 17:17:26
IO thread only?
Devlin
2012/08/21 19:46:46
Done.
|
+ bytes_read_ += bytes_read; |
} |
void PerformanceMonitor::Observe(int type, |