diff options
-rw-r--r-- | chrome/browser/metrics/metrics_service.cc | 68 | ||||
-rw-r--r-- | chrome/browser/metrics/metrics_service.h | 4 |
2 files changed, 44 insertions, 28 deletions
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc index 4865ffd..b6df42d 100644 --- a/chrome/browser/metrics/metrics_service.cc +++ b/chrome/browser/metrics/metrics_service.cc @@ -734,16 +734,19 @@ void MetricsService::Observe(int type, DCHECK(log_manager_.current_log()); DCHECK(IsSingleThreaded()); - if (!CanLogNotification()) - return; - + // Check for notifications related to core stability metrics, or that are + // just triggers to end idle mode. Anything else should be added in the later + // switch statement, where they take effect only if general metrics should be + // logged. + bool handled = false; switch (type) { case chrome::NOTIFICATION_BROWSER_OPENED: case chrome::NOTIFICATION_BROWSER_CLOSED: case chrome::NOTIFICATION_TAB_PARENTED: case chrome::NOTIFICATION_TAB_CLOSING: case content::NOTIFICATION_LOAD_STOP: - // These notifications are currently used only to break out of idle mode. + // These notifications are used only to break out of idle mode. + handled = true; break; case content::NOTIFICATION_LOAD_START: { @@ -751,39 +754,52 @@ void MetricsService::Observe(int type, content::Source<content::NavigationController>(source).ptr(); content::WebContents* web_contents = controller->GetWebContents(); LogLoadStarted(web_contents); + handled = true; break; } case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { - content::RenderProcessHost::RendererClosedDetails* process_details = - content::Details< - content::RenderProcessHost::RendererClosedDetails>( - details).ptr(); - content::RenderProcessHost* host = - content::Source<content::RenderProcessHost>(source).ptr(); - LogRendererCrash( - host, process_details->status, process_details->exit_code); - } + content::RenderProcessHost::RendererClosedDetails* process_details = + content::Details< + content::RenderProcessHost::RendererClosedDetails>( + details).ptr(); + content::RenderProcessHost* host = + content::Source<content::RenderProcessHost>(source).ptr(); + LogRendererCrash( + host, process_details->status, process_details->exit_code); + handled = true; break; + } case content::NOTIFICATION_RENDER_WIDGET_HOST_HANG: LogRendererHang(); + handled = true; break; - case chrome::NOTIFICATION_OMNIBOX_OPENED_URL: { - MetricsLog* current_log = - static_cast<MetricsLog*>(log_manager_.current_log()); - DCHECK(current_log); - current_log->RecordOmniboxOpenedURL( - *content::Details<OmniboxLog>(details).ptr()); - break; - } - default: - NOTREACHED(); + // Everything else is handled after the early return check below. break; } + // If it wasn't one of the stability-related notifications, and event + // logging isn't suppressed, handle it. + if (!handled && ShouldLogEvents()) { + switch (type) { + case chrome::NOTIFICATION_OMNIBOX_OPENED_URL: { + MetricsLog* current_log = + static_cast<MetricsLog*>(log_manager_.current_log()); + DCHECK(current_log); + current_log->RecordOmniboxOpenedURL( + *content::Details<OmniboxLog>(details).ptr()); + break; + } + + default: + NOTREACHED(); + break; + } + } + HandleIdleSinceLastTransmission(false); } @@ -1115,7 +1131,7 @@ void MetricsService::OnInitTaskGotGoogleUpdateData( } void MetricsService::OnUserAction(const std::string& action) { - if (!CanLogNotification()) + if (!ShouldLogEvents()) return; log_manager_.current_log()->RecordUserAction(action.c_str()); @@ -1988,8 +2004,8 @@ void MetricsService::RecordPluginChanges(PrefService* pref) { child_process_stats_buffer_.clear(); } -bool MetricsService::CanLogNotification() { - // We simply don't log anything to UMA if there is a single incognito +bool MetricsService::ShouldLogEvents() { + // We simply don't log events to UMA if there is a single incognito // session visible. The problem is that we always notify using the orginal // profile in order to simplify notification processing. return !chrome::IsOffTheRecordSessionActive(); diff --git a/chrome/browser/metrics/metrics_service.h b/chrome/browser/metrics/metrics_service.h index 5eb7fee..368e3df 100644 --- a/chrome/browser/metrics/metrics_service.h +++ b/chrome/browser/metrics/metrics_service.h @@ -479,8 +479,8 @@ class MetricsService // additional logging of the type of page loaded. void LogLoadStarted(content::WebContents* web_contents); - // Checks whether a notification can be logged. - bool CanLogNotification(); + // Checks whether events should currently be logged. + bool ShouldLogEvents(); // Sets the value of the specified path in prefs and schedules a save. void RecordBooleanPrefValue(const char* path, bool value); |