| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/metrics/stability_metrics_helper.h" | 5 #include "components/metrics/stability_metrics_helper.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); | 175 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); |
| 176 // We need to save the prefs, as page load count is a critical stat, and it | 176 // We need to save the prefs, as page load count is a critical stat, and it |
| 177 // might be lost due to a crash :-(. | 177 // might be lost due to a crash :-(. |
| 178 } | 178 } |
| 179 | 179 |
| 180 void StabilityMetricsHelper::LogRendererCrash(bool was_extension_process, | 180 void StabilityMetricsHelper::LogRendererCrash(bool was_extension_process, |
| 181 base::TerminationStatus status, | 181 base::TerminationStatus status, |
| 182 int exit_code) { | 182 int exit_code) { |
| 183 int histogram_type = | 183 int histogram_type = |
| 184 was_extension_process ? RENDERER_TYPE_EXTENSION : RENDERER_TYPE_RENDERER; | 184 was_extension_process ? RENDERER_TYPE_EXTENSION : RENDERER_TYPE_RENDERER; |
| 185 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || | |
| 186 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { | |
| 187 if (was_extension_process) { | |
| 188 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); | |
| 189 | 185 |
| 190 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Extension", | 186 switch (status) { |
| 191 MapCrashExitCodeForHistogram(exit_code)); | 187 case base::TERMINATION_STATUS_NORMAL_TERMINATION: |
| 192 } else { | 188 break; |
| 193 IncrementPrefValue(prefs::kStabilityRendererCrashCount); | 189 case base::TERMINATION_STATUS_PROCESS_CRASHED: |
| 190 case base::TERMINATION_STATUS_ABNORMAL_TERMINATION: |
| 191 case base::TERMINATION_STATUS_OOM: |
| 192 if (was_extension_process) { |
| 193 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); |
| 194 | 194 |
| 195 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Renderer", | 195 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Extension", |
| 196 MapCrashExitCodeForHistogram(exit_code)); | 196 MapCrashExitCodeForHistogram(exit_code)); |
| 197 } | 197 } else { |
| 198 IncrementPrefValue(prefs::kStabilityRendererCrashCount); |
| 198 | 199 |
| 199 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildCrashes", | 200 UMA_HISTOGRAM_SPARSE_SLOWLY("CrashExitCodes.Renderer", |
| 200 histogram_type, RENDERER_TYPE_COUNT); | 201 MapCrashExitCodeForHistogram(exit_code)); |
| 201 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { | 202 } |
| 202 RecordChildKills(histogram_type); | 203 |
| 204 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildCrashes", |
| 205 histogram_type, RENDERER_TYPE_COUNT); |
| 206 break; |
| 207 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED: |
| 208 RecordChildKills(histogram_type); |
| 209 break; |
| 210 #if defined(OS_ANDROID) |
| 211 case base::TERMINATION_STATUS_OOM_PROTECTED: |
| 212 // TODO(wfh): Check if this should be a Kill or a Crash on Android. |
| 213 break; |
| 214 #endif |
| 203 #if defined(OS_CHROMEOS) | 215 #if defined(OS_CHROMEOS) |
| 204 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM) { | 216 case base::TERMINATION_STATUS_PROCESS_WAS_KILLED_BY_OOM: |
| 205 RecordChildKills(histogram_type); | 217 RecordChildKills(histogram_type); |
| 206 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildKills.OOM", | 218 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildKills.OOM", |
| 207 was_extension_process ? 2 : 1, 3); | 219 was_extension_process ? 2 : 1, 3); |
| 208 RecordMemoryStats(was_extension_process | 220 RecordMemoryStats(was_extension_process |
| 209 ? RECORD_MEMORY_STATS_EXTENSIONS_OOM_KILLED | 221 ? RECORD_MEMORY_STATS_EXTENSIONS_OOM_KILLED |
| 210 : RECORD_MEMORY_STATS_CONTENTS_OOM_KILLED); | 222 : RECORD_MEMORY_STATS_CONTENTS_OOM_KILLED); |
| 223 break; |
| 211 #endif | 224 #endif |
| 212 } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) { | 225 case base::TERMINATION_STATUS_STILL_RUNNING: |
| 213 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.DisconnectedAlive", | 226 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.DisconnectedAlive", |
| 214 histogram_type, RENDERER_TYPE_COUNT); | 227 histogram_type, RENDERER_TYPE_COUNT); |
| 215 } else if (status == base::TERMINATION_STATUS_LAUNCH_FAILED) { | 228 break; |
| 216 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildLaunchFailures", | 229 case base::TERMINATION_STATUS_LAUNCH_FAILED: |
| 217 histogram_type, RENDERER_TYPE_COUNT); | 230 UMA_HISTOGRAM_ENUMERATION("BrowserRenderProcessHost.ChildLaunchFailures", |
| 218 UMA_HISTOGRAM_SPARSE_SLOWLY( | 231 histogram_type, RENDERER_TYPE_COUNT); |
| 219 "BrowserRenderProcessHost.ChildLaunchFailureCodes", exit_code); | 232 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 220 if (was_extension_process) | 233 "BrowserRenderProcessHost.ChildLaunchFailureCodes", exit_code); |
| 221 IncrementPrefValue(prefs::kStabilityExtensionRendererFailedLaunchCount); | 234 if (was_extension_process) |
| 222 else | 235 IncrementPrefValue(prefs::kStabilityExtensionRendererFailedLaunchCount); |
| 223 IncrementPrefValue(prefs::kStabilityRendererFailedLaunchCount); | 236 else |
| 237 IncrementPrefValue(prefs::kStabilityRendererFailedLaunchCount); |
| 238 break; |
| 239 case base::TERMINATION_STATUS_MAX_ENUM: |
| 240 NOTREACHED(); |
| 241 break; |
| 224 } | 242 } |
| 225 } | 243 } |
| 226 | 244 |
| 227 void StabilityMetricsHelper::LogRendererLaunched(bool was_extension_process) { | 245 void StabilityMetricsHelper::LogRendererLaunched(bool was_extension_process) { |
| 228 if (was_extension_process) | 246 if (was_extension_process) |
| 229 IncrementPrefValue(prefs::kStabilityExtensionRendererLaunchCount); | 247 IncrementPrefValue(prefs::kStabilityExtensionRendererLaunchCount); |
| 230 else | 248 else |
| 231 IncrementPrefValue(prefs::kStabilityRendererLaunchCount); | 249 IncrementPrefValue(prefs::kStabilityRendererLaunchCount); |
| 232 } | 250 } |
| 233 | 251 |
| 234 void StabilityMetricsHelper::IncrementPrefValue(const char* path) { | 252 void StabilityMetricsHelper::IncrementPrefValue(const char* path) { |
| 235 int value = local_state_->GetInteger(path); | 253 int value = local_state_->GetInteger(path); |
| 236 local_state_->SetInteger(path, value + 1); | 254 local_state_->SetInteger(path, value + 1); |
| 237 } | 255 } |
| 238 | 256 |
| 239 void StabilityMetricsHelper::IncrementLongPrefsValue(const char* path) { | 257 void StabilityMetricsHelper::IncrementLongPrefsValue(const char* path) { |
| 240 int64_t value = local_state_->GetInt64(path); | 258 int64_t value = local_state_->GetInt64(path); |
| 241 local_state_->SetInt64(path, value + 1); | 259 local_state_->SetInt64(path, value + 1); |
| 242 } | 260 } |
| 243 | 261 |
| 244 void StabilityMetricsHelper::LogRendererHang() { | 262 void StabilityMetricsHelper::LogRendererHang() { |
| 245 IncrementPrefValue(prefs::kStabilityRendererHangCount); | 263 IncrementPrefValue(prefs::kStabilityRendererHangCount); |
| 246 } | 264 } |
| 247 | 265 |
| 248 } // namespace metrics | 266 } // namespace metrics |
| OLD | NEW |