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 4bbe8d0af62b98a6af0fab8946a31a7088e4fd27..b62826e8a31684a7c920466d5325f89550c85f55 100644 |
--- a/chrome/browser/performance_monitor/performance_monitor.cc |
+++ b/chrome/browser/performance_monitor/performance_monitor.cc |
@@ -27,6 +27,7 @@ |
#include "chrome/common/extensions/extension.h" |
#include "chrome/common/extensions/extension_constants.h" |
#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/load_notification_details.h" |
#include "content/public/browser/notification_service.h" |
#include "content/public/browser/notification_types.h" |
#include "content/public/browser/web_contents.h" |
@@ -139,6 +140,10 @@ void PerformanceMonitor::RegisterForNotifications() { |
// Profiles (for unclean exit) |
registrar_.Add(this, chrome::NOTIFICATION_PROFILE_ADDED, |
content::NotificationService::AllSources()); |
+ |
+ // Page load times |
+ registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, |
+ content::NotificationService::AllSources()); |
} |
// We check if profiles exited cleanly initialization time in case they were |
@@ -221,6 +226,11 @@ void PerformanceMonitor::AddEventOnBackgroundThread(scoped_ptr<Event> event) { |
database_->AddEvent(*event.get()); |
} |
+void PerformanceMonitor::AddMetricOnBackgroundThread(MetricType type, |
+ const std::string& value) { |
+ database_->AddMetric(type, value); |
Yoyo Zhou
2012/08/10 18:34:04
Maybe DCHECK that you're on the right thread?
Devlin
2012/08/11 18:22:25
Done.
|
+} |
+ |
void PerformanceMonitor::GetStateValueOnBackgroundThread( |
const std::string& key, |
const StateValueCallback& callback) { |
@@ -339,6 +349,21 @@ void PerformanceMonitor::Observe(int type, |
} |
break; |
} |
+ case content::NOTIFICATION_LOAD_STOP: { |
+ const content::LoadNotificationDetails* load_details = |
+ content::Details<content::LoadNotificationDetails>(details).ptr(); |
+ if (!load_details) |
+ break; |
+ BrowserThread::PostBlockingPoolSequencedTask( |
+ Database::kDatabaseSequenceToken, |
+ FROM_HERE, |
+ base::Bind( |
+ &PerformanceMonitor::AddMetricOnBackgroundThread, |
+ base::Unretained(this), |
+ METRIC_PAGE_LOAD_TIME, |
+ base::Int64ToString(load_details->load_time.ToInternalValue()))); |
+ break; |
+ } |
default: { |
NOTREACHED(); |
break; |