| 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 f35d6e11ce8ff810d8bedfda720fb895973a0d89..38f7192ca207bead318ace9cd48800521db71a54 100644
|
| --- a/chrome/browser/performance_monitor/performance_monitor.cc
|
| +++ b/chrome/browser/performance_monitor/performance_monitor.cc
|
| @@ -30,6 +30,7 @@
|
| #include "chrome/test/base/chrome_process_util.h"
|
| #include "content/public/browser/browser_child_process_host.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"
|
| @@ -146,6 +147,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
|
| @@ -228,6 +233,12 @@ void PerformanceMonitor::AddEventOnBackgroundThread(scoped_ptr<Event> event) {
|
| database_->AddEvent(*event.get());
|
| }
|
|
|
| +void PerformanceMonitor::AddMetricOnBackgroundThread(MetricType type,
|
| + const std::string& value) {
|
| + DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| + database_->AddMetric(type, value);
|
| +}
|
| +
|
| void PerformanceMonitor::NotifyInitialized() {
|
| content::NotificationService::current()->Notify(
|
| chrome::NOTIFICATION_PERFORMANCE_MONITOR_INITIALIZED,
|
| @@ -419,6 +430,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;
|
|
|