| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" | 5 #include "chrome/browser/metrics/chrome_stability_metrics_provider.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/metrics/sparse_histogram.h" | 11 #include "base/metrics/sparse_histogram.h" |
| 12 #include "base/prefs/pref_registry_simple.h" | 12 #include "base/prefs/pref_registry_simple.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
| 17 #include "components/metrics/proto/system_profile.pb.h" | 17 #include "components/metrics/proto/system_profile.pb.h" |
| 18 #include "content/public/browser/child_process_data.h" | 18 #include "content/public/browser/child_process_data.h" |
| 19 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 20 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
| 21 #include "content/public/browser/user_metrics.h" | 21 #include "content/public/browser/user_metrics.h" |
| 22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
| 23 |
| 24 #if defined(ENABLE_EXTENSIONS) |
| 23 #include "extensions/browser/process_map.h" | 25 #include "extensions/browser/process_map.h" |
| 26 #endif |
| 24 | 27 |
| 25 #if defined(ENABLE_PLUGINS) | 28 #if defined(ENABLE_PLUGINS) |
| 26 #include "chrome/browser/metrics/plugin_metrics_provider.h" | 29 #include "chrome/browser/metrics/plugin_metrics_provider.h" |
| 27 #endif | 30 #endif |
| 28 | 31 |
| 29 #if defined(OS_WIN) | 32 #if defined(OS_WIN) |
| 30 #include <windows.h> // Needed for STATUS_* codes | 33 #include <windows.h> // Needed for STATUS_* codes |
| 31 #endif | 34 #endif |
| 32 | 35 |
| 33 namespace { | 36 namespace { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 IncrementPrefValue(prefs::kStabilityPageLoadCount); | 191 IncrementPrefValue(prefs::kStabilityPageLoadCount); |
| 189 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); | 192 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); |
| 190 // We need to save the prefs, as page load count is a critical stat, and it | 193 // We need to save the prefs, as page load count is a critical stat, and it |
| 191 // might be lost due to a crash :-(. | 194 // might be lost due to a crash :-(. |
| 192 } | 195 } |
| 193 | 196 |
| 194 void ChromeStabilityMetricsProvider::LogRendererCrash( | 197 void ChromeStabilityMetricsProvider::LogRendererCrash( |
| 195 content::RenderProcessHost* host, | 198 content::RenderProcessHost* host, |
| 196 base::TerminationStatus status, | 199 base::TerminationStatus status, |
| 197 int exit_code) { | 200 int exit_code) { |
| 198 bool was_extension_process = | 201 bool was_extension_process = false; |
| 199 extensions::ProcessMap::Get(host->GetBrowserContext()) | 202 #if defined(ENABLE_EXTENSIONS) |
| 200 ->Contains(host->GetID()); | 203 was_extension_process = |
| 204 extensions::ProcessMap::Get(host->GetBrowserContext())->Contains( |
| 205 host->GetID()); |
| 206 #endif |
| 201 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || | 207 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || |
| 202 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { | 208 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { |
| 203 if (was_extension_process) { | 209 if (was_extension_process) { |
| 204 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); | 210 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); |
| 205 | 211 |
| 206 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Extension", | 212 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Extension", |
| 207 MapCrashExitCodeForHistogram(exit_code)); | 213 MapCrashExitCodeForHistogram(exit_code)); |
| 208 } else { | 214 } else { |
| 209 IncrementPrefValue(prefs::kStabilityRendererCrashCount); | 215 IncrementPrefValue(prefs::kStabilityRendererCrashCount); |
| 210 | 216 |
| 211 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Renderer", | 217 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Renderer", |
| 212 MapCrashExitCodeForHistogram(exit_code)); | 218 MapCrashExitCodeForHistogram(exit_code)); |
| 213 } | 219 } |
| 214 | 220 |
| 215 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", | 221 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", |
| 216 was_extension_process ? 2 : 1); | 222 was_extension_process ? 2 : 1); |
| 217 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { | 223 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { |
| 218 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", | 224 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", |
| 219 was_extension_process ? 2 : 1); | 225 was_extension_process ? 2 : 1); |
| 220 } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) { | 226 } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) { |
| 221 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.DisconnectedAlive", | 227 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.DisconnectedAlive", |
| 222 was_extension_process ? 2 : 1); | 228 was_extension_process ? 2 : 1); |
| 223 } | 229 } |
| 224 } | 230 } |
| 225 | 231 |
| 226 void ChromeStabilityMetricsProvider::LogRendererHang() { | 232 void ChromeStabilityMetricsProvider::LogRendererHang() { |
| 227 IncrementPrefValue(prefs::kStabilityRendererHangCount); | 233 IncrementPrefValue(prefs::kStabilityRendererHangCount); |
| 228 } | 234 } |
| OLD | NEW |