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

Side by Side Diff: chrome/browser/metrics/chrome_stability_metrics_provider.cc

Issue 1320153002: Add new termination status for failed launch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase and a nit. Created 5 years, 3 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 unified diff | Download patch
OLDNEW
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"
(...skipping 23 matching lines...) Expand all
34 #include "chrome/installer/util/install_util.h" 34 #include "chrome/installer/util/install_util.h"
35 #include "components/browser_watcher/crash_reporting_metrics_win.h" 35 #include "components/browser_watcher/crash_reporting_metrics_win.h"
36 #endif 36 #endif
37 37
38 #if defined(OS_CHROMEOS) 38 #if defined(OS_CHROMEOS)
39 #include "chrome/browser/memory/system_memory_stats_recorder.h" 39 #include "chrome/browser/memory/system_memory_stats_recorder.h"
40 #endif 40 #endif
41 41
42 namespace { 42 namespace {
43 43
44 enum RendererType {
45 RENDERER_TYPE_RENDERER,
46 RENDERER_TYPE_EXTENSION,
47 // NOTE: Add new action types only immediately above this line. Also,
48 // make sure the enum list in tools/metrics/histograms/histograms.xml is
49 // updated with any change in here.
50 RENDERER_TYPE_COUNT
51 };
52
44 // Converts an exit code into something that can be inserted into our 53 // Converts an exit code into something that can be inserted into our
45 // histograms (which expect non-negative numbers less than MAX_INT). 54 // histograms (which expect non-negative numbers less than MAX_INT).
46 int MapCrashExitCodeForHistogram(int exit_code) { 55 int MapCrashExitCodeForHistogram(int exit_code) {
47 #if defined(OS_WIN) 56 #if defined(OS_WIN)
48 // Since |abs(STATUS_GUARD_PAGE_VIOLATION) == MAX_INT| it causes problems in 57 // Since |abs(STATUS_GUARD_PAGE_VIOLATION) == MAX_INT| it causes problems in
49 // histograms.cc. Solve this by remapping it to a smaller value, which 58 // histograms.cc. Solve this by remapping it to a smaller value, which
50 // hopefully doesn't conflict with other codes. 59 // hopefully doesn't conflict with other codes.
51 if (exit_code == STATUS_GUARD_PAGE_VIOLATION) 60 if (exit_code == STATUS_GUARD_PAGE_VIOLATION)
52 return 0x1FCF7EC3; // Randomly picked number. 61 return 0x1FCF7EC3; // Randomly picked number.
53 #endif 62 #endif
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 outcome = OUTCOME_FAILURE; 100 outcome = OUTCOME_FAILURE;
92 } 101 }
93 102
94 UMA_STABILITY_HISTOGRAM_ENUMERATION( 103 UMA_STABILITY_HISTOGRAM_ENUMERATION(
95 "CrashReport.BreakpadDumpWithoutCrashOutcome", outcome, 104 "CrashReport.BreakpadDumpWithoutCrashOutcome", outcome,
96 OUTCOME_MAX_VALUE); 105 OUTCOME_MAX_VALUE);
97 } 106 }
98 } 107 }
99 #endif // defined(OS_WIN) 108 #endif // defined(OS_WIN)
100 109
101 void RecordChildKills(bool was_extension_process) { 110 void RecordChildKills(int histogram_type) {
102 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", 111 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildKills",
103 was_extension_process ? 2 : 1); 112 histogram_type, RENDERER_TYPE_COUNT);
104 } 113 }
105 114
106 } // namespace 115 } // namespace
107 116
108 ChromeStabilityMetricsProvider::ChromeStabilityMetricsProvider( 117 ChromeStabilityMetricsProvider::ChromeStabilityMetricsProvider(
109 PrefService* local_state) 118 PrefService* local_state)
110 : local_state_(local_state) { 119 : local_state_(local_state) {
111 DCHECK(local_state_); 120 DCHECK(local_state_);
112 BrowserChildProcessObserver::Add(this); 121 BrowserChildProcessObserver::Add(this);
113 } 122 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 IncrementPrefValue(prefs::kStabilityPageLoadCount); 260 IncrementPrefValue(prefs::kStabilityPageLoadCount);
252 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); 261 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount);
253 // We need to save the prefs, as page load count is a critical stat, and it 262 // We need to save the prefs, as page load count is a critical stat, and it
254 // might be lost due to a crash :-(. 263 // might be lost due to a crash :-(.
255 } 264 }
256 265
257 void ChromeStabilityMetricsProvider::LogRendererCrash( 266 void ChromeStabilityMetricsProvider::LogRendererCrash(
258 content::RenderProcessHost* host, 267 content::RenderProcessHost* host,
259 base::TerminationStatus status, 268 base::TerminationStatus status,
260 int exit_code) { 269 int exit_code) {
270 int histogram_type = RENDERER_TYPE_RENDERER;
261 bool was_extension_process = false; 271 bool was_extension_process = false;
262 #if defined(ENABLE_EXTENSIONS) 272 #if defined(ENABLE_EXTENSIONS)
263 was_extension_process = 273 if (extensions::ProcessMap::Get(host->GetBrowserContext())
264 extensions::ProcessMap::Get(host->GetBrowserContext())->Contains( 274 ->Contains(host->GetID())) {
265 host->GetID()); 275 histogram_type = RENDERER_TYPE_EXTENSION;
276 was_extension_process = true;
277 }
266 #endif 278 #endif
267 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || 279 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED ||
268 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { 280 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) {
269 if (was_extension_process) { 281 if (was_extension_process) {
270 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); 282 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount);
271 283
272 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Extension", 284 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Extension",
273 MapCrashExitCodeForHistogram(exit_code)); 285 MapCrashExitCodeForHistogram(exit_code));
274 } else { 286 } else {
275 IncrementPrefValue(prefs::kStabilityRendererCrashCount); 287 IncrementPrefValue(prefs::kStabilityRendererCrashCount);
276 288
277 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Renderer", 289 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Renderer",
278 MapCrashExitCodeForHistogram(exit_code)); 290 MapCrashExitCodeForHistogram(exit_code));
279 } 291 }
280 292
281 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", 293 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildCrashes",
282 was_extension_process ? 2 : 1); 294 histogram_type, RENDERER_TYPE_COUNT);
283 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { 295 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) {
284 RecordChildKills(was_extension_process); 296 RecordChildKills(histogram_type);
285 #if defined(OS_CHROMEOS) 297 #if defined(OS_CHROMEOS)
286 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM) { 298 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM) {
287 RecordChildKills(was_extension_process); 299 RecordChildKills(histogram_type);
288 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildKills.OOM", 300 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildKills.OOM",
289 was_extension_process ? 2 : 1, 301 was_extension_process ? 2 : 1,
290 3); 302 3);
291 memory::RecordMemoryStats( 303 memory::RecordMemoryStats(
292 was_extension_process 304 was_extension_process
293 ? memory::RECORD_MEMORY_STATS_EXTENSIONS_OOM_KILLED 305 ? memory::RECORD_MEMORY_STATS_EXTENSIONS_OOM_KILLED
294 : memory::RECORD_MEMORY_STATS_CONTENTS_OOM_KILLED); 306 : memory::RECORD_MEMORY_STATS_CONTENTS_OOM_KILLED);
295 #endif 307 #endif
296 } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) { 308 } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) {
297 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.DisconnectedAlive", 309 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.DisconnectedAlive",
298 was_extension_process ? 2 : 1); 310 histogram_type, RENDERER_TYPE_COUNT);
311 } else if (status == base::TERMINATION_STATUS_LAUNCH_FAILED) {
312 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildLaunchFailures",
313 histogram_type, RENDERER_TYPE_COUNT);
314 // Treat child process launch as a crash for now.
315 if (was_extension_process)
316 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount);
317 else
318 IncrementPrefValue(prefs::kStabilityRendererCrashCount);
299 } 319 }
300 } 320 }
301 321
302 void ChromeStabilityMetricsProvider::IncrementPrefValue(const char* path) { 322 void ChromeStabilityMetricsProvider::IncrementPrefValue(const char* path) {
303 int value = local_state_->GetInteger(path); 323 int value = local_state_->GetInteger(path);
304 local_state_->SetInteger(path, value + 1); 324 local_state_->SetInteger(path, value + 1);
305 } 325 }
306 326
307 void ChromeStabilityMetricsProvider::IncrementLongPrefsValue(const char* path) { 327 void ChromeStabilityMetricsProvider::IncrementLongPrefsValue(const char* path) {
308 int64 value = local_state_->GetInt64(path); 328 int64 value = local_state_->GetInt64(path);
309 local_state_->SetInt64(path, value + 1); 329 local_state_->SetInt64(path, value + 1);
310 } 330 }
311 331
312 void ChromeStabilityMetricsProvider::LogRendererHang() { 332 void ChromeStabilityMetricsProvider::LogRendererHang() {
313 IncrementPrefValue(prefs::kStabilityRendererHangCount); 333 IncrementPrefValue(prefs::kStabilityRendererHangCount);
314 } 334 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_ui_bindings.cc ('k') | chrome/browser/metrics/chrome_stability_metrics_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698