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

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

Issue 10829078: CPM Page Load timing (Closed) Base URL: http://git.chromium.org/chromium/src.git@dc_event_refactor
Patch Set: Created 8 years, 4 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.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;

Powered by Google App Engine
This is Rietveld 408576698