Chromium Code Reviews| 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 "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "content/public/browser/child_process_data.h" | 14 #include "content/public/browser/child_process_data.h" |
| 15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 16 #include "content/public/browser/render_process_host.h" | 16 #include "content/public/browser/render_process_host.h" |
| 17 | 17 |
| 18 #if defined(ENABLE_EXTENSIONS) | 18 #if defined(ENABLE_EXTENSIONS) |
| 19 #include "extensions/browser/process_map.h" | 19 #include "extensions/browser/process_map.h" |
| 20 #endif | 20 #endif |
| 21 | 21 |
| 22 #if defined(ENABLE_PLUGINS) | 22 #if defined(ENABLE_PLUGINS) |
| 23 #include "chrome/browser/metrics/plugin_metrics_provider.h" | 23 #include "chrome/browser/metrics/plugin_metrics_provider.h" |
| 24 #endif | 24 #endif |
| 25 | 25 |
| 26 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
| 27 #include <windows.h> // Needed for STATUS_* codes | 27 #include <windows.h> // Needed for STATUS_* codes |
| 28 #include "chrome/common/metrics_constants_util_win.h" | 28 #include "chrome/common/metrics_constants_util_win.h" |
| 29 #include "components/browser_watcher/crash_reporting_metrics_win.h" | |
| 30 #endif | 29 #endif |
| 31 | 30 |
| 32 namespace { | |
| 33 | |
| 34 #if defined(OS_WIN) | |
| 35 void CountBrowserCrashDumpAttempts() { | |
| 36 enum Outcome { | |
| 37 OUTCOME_SUCCESS, | |
| 38 OUTCOME_FAILURE, | |
| 39 OUTCOME_UNKNOWN, | |
| 40 OUTCOME_MAX_VALUE | |
| 41 }; | |
| 42 | |
| 43 browser_watcher::CrashReportingMetrics::Values metrics = | |
| 44 browser_watcher::CrashReportingMetrics( | |
| 45 chrome::GetBrowserCrashDumpAttemptsRegistryPath()) | |
| 46 .RetrieveAndResetMetrics(); | |
| 47 | |
| 48 for (int i = 0; i < metrics.crash_dump_attempts; ++i) { | |
| 49 Outcome outcome = OUTCOME_UNKNOWN; | |
| 50 if (i < metrics.successful_crash_dumps) | |
| 51 outcome = OUTCOME_SUCCESS; | |
| 52 else if (i < metrics.successful_crash_dumps + metrics.failed_crash_dumps) | |
| 53 outcome = OUTCOME_FAILURE; | |
| 54 | |
| 55 UMA_STABILITY_HISTOGRAM_ENUMERATION("CrashReport.BreakpadCrashDumpOutcome", | |
|
Alexei Svitkine (slow)
2016/04/26 14:44:28
Please mark all the histograms you're deleting as
Sigurður Ásgeirsson
2016/04/26 14:53:16
Done.
| |
| 56 outcome, OUTCOME_MAX_VALUE); | |
| 57 } | |
| 58 | |
| 59 for (int i = 0; i < metrics.dump_without_crash_attempts; ++i) { | |
| 60 Outcome outcome = OUTCOME_UNKNOWN; | |
| 61 if (i < metrics.successful_dumps_without_crash) { | |
| 62 outcome = OUTCOME_SUCCESS; | |
| 63 } else if (i < metrics.successful_dumps_without_crash + | |
| 64 metrics.failed_dumps_without_crash) { | |
| 65 outcome = OUTCOME_FAILURE; | |
| 66 } | |
| 67 | |
| 68 UMA_STABILITY_HISTOGRAM_ENUMERATION( | |
| 69 "CrashReport.BreakpadDumpWithoutCrashOutcome", outcome, | |
| 70 OUTCOME_MAX_VALUE); | |
| 71 } | |
| 72 } | |
| 73 #endif // defined(OS_WIN) | |
| 74 | |
| 75 } // namespace | |
| 76 | |
| 77 ChromeStabilityMetricsProvider::ChromeStabilityMetricsProvider( | 31 ChromeStabilityMetricsProvider::ChromeStabilityMetricsProvider( |
| 78 PrefService* local_state) | 32 PrefService* local_state) |
| 79 : helper_(local_state) { | 33 : helper_(local_state) { |
| 80 BrowserChildProcessObserver::Add(this); | 34 BrowserChildProcessObserver::Add(this); |
| 81 } | 35 } |
| 82 | 36 |
| 83 ChromeStabilityMetricsProvider::~ChromeStabilityMetricsProvider() { | 37 ChromeStabilityMetricsProvider::~ChromeStabilityMetricsProvider() { |
| 84 BrowserChildProcessObserver::Remove(this); | 38 BrowserChildProcessObserver::Remove(this); |
| 85 } | 39 } |
| 86 | 40 |
| 87 void ChromeStabilityMetricsProvider::OnRecordingEnabled() { | 41 void ChromeStabilityMetricsProvider::OnRecordingEnabled() { |
| 88 registrar_.Add(this, | 42 registrar_.Add(this, |
| 89 content::NOTIFICATION_LOAD_START, | 43 content::NOTIFICATION_LOAD_START, |
| 90 content::NotificationService::AllSources()); | 44 content::NotificationService::AllSources()); |
| 91 registrar_.Add(this, | 45 registrar_.Add(this, |
| 92 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, | 46 content::NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 93 content::NotificationService::AllSources()); | 47 content::NotificationService::AllSources()); |
| 94 registrar_.Add(this, | 48 registrar_.Add(this, |
| 95 content::NOTIFICATION_RENDER_WIDGET_HOST_HANG, | 49 content::NOTIFICATION_RENDER_WIDGET_HOST_HANG, |
| 96 content::NotificationService::AllSources()); | 50 content::NotificationService::AllSources()); |
| 97 } | 51 } |
| 98 | 52 |
| 99 void ChromeStabilityMetricsProvider::OnRecordingDisabled() { | 53 void ChromeStabilityMetricsProvider::OnRecordingDisabled() { |
| 100 registrar_.RemoveAll(); | 54 registrar_.RemoveAll(); |
| 101 } | 55 } |
| 102 | 56 |
| 103 void ChromeStabilityMetricsProvider::ProvideStabilityMetrics( | 57 void ChromeStabilityMetricsProvider::ProvideStabilityMetrics( |
| 104 metrics::SystemProfileProto* system_profile_proto) { | 58 metrics::SystemProfileProto* system_profile_proto) { |
| 105 helper_.ProvideStabilityMetrics(system_profile_proto); | 59 helper_.ProvideStabilityMetrics(system_profile_proto); |
| 106 | |
| 107 #if defined(OS_WIN) | |
| 108 CountBrowserCrashDumpAttempts(); | |
| 109 #endif // defined(OS_WIN) | |
| 110 } | 60 } |
| 111 | 61 |
| 112 void ChromeStabilityMetricsProvider::ClearSavedStabilityMetrics() { | 62 void ChromeStabilityMetricsProvider::ClearSavedStabilityMetrics() { |
| 113 helper_.ClearSavedStabilityMetrics(); | 63 helper_.ClearSavedStabilityMetrics(); |
| 114 } | 64 } |
| 115 | 65 |
| 116 void ChromeStabilityMetricsProvider::Observe( | 66 void ChromeStabilityMetricsProvider::Observe( |
| 117 int type, | 67 int type, |
| 118 const content::NotificationSource& source, | 68 const content::NotificationSource& source, |
| 119 const content::NotificationDetails& details) { | 69 const content::NotificationDetails& details) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 int exit_code) { | 106 int exit_code) { |
| 157 #if defined(ENABLE_PLUGINS) | 107 #if defined(ENABLE_PLUGINS) |
| 158 // Exclude plugin crashes from the count below because we report them via | 108 // Exclude plugin crashes from the count below because we report them via |
| 159 // a separate UMA metric. | 109 // a separate UMA metric. |
| 160 if (PluginMetricsProvider::IsPluginProcess(data.process_type)) | 110 if (PluginMetricsProvider::IsPluginProcess(data.process_type)) |
| 161 return; | 111 return; |
| 162 #endif | 112 #endif |
| 163 | 113 |
| 164 helper_.BrowserChildProcessCrashed(); | 114 helper_.BrowserChildProcessCrashed(); |
| 165 } | 115 } |
| OLD | NEW |