OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 //------------------------------------------------------------------------------ | 5 //------------------------------------------------------------------------------ |
6 // Description of the life cycle of a instance of MetricsService. | 6 // Description of the life cycle of a instance of MetricsService. |
7 // | 7 // |
8 // OVERVIEW | 8 // OVERVIEW |
9 // | 9 // |
10 // A MetricsService instance is typically created at application startup. It | 10 // A MetricsService instance is typically created at application startup. It |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
149 #include "base/command_line.h" | 149 #include "base/command_line.h" |
150 #include "base/md5.h" | 150 #include "base/md5.h" |
151 #include "base/metrics/histogram.h" | 151 #include "base/metrics/histogram.h" |
152 #include "base/string_number_conversions.h" | 152 #include "base/string_number_conversions.h" |
153 #include "base/threading/platform_thread.h" | 153 #include "base/threading/platform_thread.h" |
154 #include "base/threading/thread.h" | 154 #include "base/threading/thread.h" |
155 #include "base/utf_string_conversions.h" | 155 #include "base/utf_string_conversions.h" |
156 #include "base/values.h" | 156 #include "base/values.h" |
157 #include "chrome/browser/bookmarks/bookmark_model.h" | 157 #include "chrome/browser/bookmarks/bookmark_model.h" |
158 #include "chrome/browser/browser_process.h" | 158 #include "chrome/browser/browser_process.h" |
| 159 #include "chrome/browser/extensions/extension_process_manager.h" |
159 #include "chrome/browser/memory_details.h" | 160 #include "chrome/browser/memory_details.h" |
160 #include "chrome/browser/metrics/histogram_synchronizer.h" | 161 #include "chrome/browser/metrics/histogram_synchronizer.h" |
161 #include "chrome/browser/metrics/metrics_log.h" | 162 #include "chrome/browser/metrics/metrics_log.h" |
162 #include "chrome/browser/metrics/metrics_log_serializer.h" | 163 #include "chrome/browser/metrics/metrics_log_serializer.h" |
163 #include "chrome/browser/metrics/metrics_reporting_scheduler.h" | 164 #include "chrome/browser/metrics/metrics_reporting_scheduler.h" |
164 #include "chrome/browser/net/network_stats.h" | 165 #include "chrome/browser/net/network_stats.h" |
165 #include "chrome/browser/prefs/pref_service.h" | 166 #include "chrome/browser/prefs/pref_service.h" |
166 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 167 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
167 #include "chrome/browser/profiles/profile.h" | 168 #include "chrome/browser/profiles/profile.h" |
168 #include "chrome/browser/search_engines/template_url_service.h" | 169 #include "chrome/browser/search_engines/template_url_service.h" |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 LogLoadComplete(type, source, details); | 518 LogLoadComplete(type, source, details); |
518 break; | 519 break; |
519 | 520 |
520 case content::NOTIFICATION_LOAD_START: | 521 case content::NOTIFICATION_LOAD_START: |
521 LogLoadStarted(); | 522 LogLoadStarted(); |
522 break; | 523 break; |
523 | 524 |
524 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { | 525 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { |
525 RenderProcessHost::RendererClosedDetails* process_details = | 526 RenderProcessHost::RendererClosedDetails* process_details = |
526 Details<RenderProcessHost::RendererClosedDetails>(details).ptr(); | 527 Details<RenderProcessHost::RendererClosedDetails>(details).ptr(); |
527 if (process_details->status == | 528 RenderProcessHost* host = Source<RenderProcessHost>(source).ptr(); |
528 base::TERMINATION_STATUS_PROCESS_CRASHED || | 529 LogRendererCrash( |
529 process_details->status == | 530 host, process_details->status, process_details->was_alive); |
530 base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { | |
531 if (process_details->was_extension_renderer) { | |
532 LogExtensionRendererCrash(); | |
533 } else { | |
534 LogRendererCrash(); | |
535 } | |
536 } | |
537 } | 531 } |
538 break; | 532 break; |
539 | 533 |
540 case content::NOTIFICATION_RENDERER_PROCESS_HANG: | 534 case content::NOTIFICATION_RENDERER_PROCESS_HANG: |
541 LogRendererHang(); | 535 LogRendererHang(); |
542 break; | 536 break; |
543 | 537 |
544 case content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED: | 538 case content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED: |
545 case content::NOTIFICATION_CHILD_PROCESS_CRASHED: | 539 case content::NOTIFICATION_CHILD_PROCESS_CRASHED: |
546 case content::NOTIFICATION_CHILD_INSTANCE_CREATED: | 540 case content::NOTIFICATION_CHILD_INSTANCE_CREATED: |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 } | 1228 } |
1235 | 1229 |
1236 void MetricsService::LogLoadStarted() { | 1230 void MetricsService::LogLoadStarted() { |
1237 HISTOGRAM_ENUMERATION("Chrome.UmaPageloadCounter", 1, 2); | 1231 HISTOGRAM_ENUMERATION("Chrome.UmaPageloadCounter", 1, 2); |
1238 IncrementPrefValue(prefs::kStabilityPageLoadCount); | 1232 IncrementPrefValue(prefs::kStabilityPageLoadCount); |
1239 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); | 1233 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); |
1240 // We need to save the prefs, as page load count is a critical stat, and it | 1234 // We need to save the prefs, as page load count is a critical stat, and it |
1241 // might be lost due to a crash :-(. | 1235 // might be lost due to a crash :-(. |
1242 } | 1236 } |
1243 | 1237 |
1244 void MetricsService::LogRendererCrash() { | 1238 void MetricsService::LogRendererCrash(RenderProcessHost* host, |
1245 IncrementPrefValue(prefs::kStabilityRendererCrashCount); | 1239 base::TerminationStatus status, |
1246 } | 1240 bool was_alive) { |
| 1241 Profile* profile = Profile::FromBrowserContext(host->browser_context()); |
| 1242 ExtensionProcessManager* extension_process_manager = |
| 1243 profile->GetExtensionProcessManager(); |
| 1244 bool was_extension_process = extension_process_manager ? |
| 1245 extension_process_manager->IsExtensionProcess(host->id()) : |
| 1246 false; |
| 1247 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || |
| 1248 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { |
| 1249 if (was_extension_process) |
| 1250 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); |
| 1251 else |
| 1252 IncrementPrefValue(prefs::kStabilityRendererCrashCount); |
1247 | 1253 |
1248 void MetricsService::LogExtensionRendererCrash() { | 1254 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", |
1249 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); | 1255 was_extension_process ? 2 : 1); |
| 1256 if (was_alive) { |
| 1257 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashesWasAlive", |
| 1258 was_extension_process ? 2 : 1); |
| 1259 } |
| 1260 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { |
| 1261 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", |
| 1262 was_extension_process ? 2 : 1); |
| 1263 if (was_alive) { |
| 1264 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKillsWasAlive", |
| 1265 was_extension_process ? 2 : 1); |
| 1266 } |
| 1267 } |
1250 } | 1268 } |
1251 | 1269 |
1252 void MetricsService::LogRendererHang() { | 1270 void MetricsService::LogRendererHang() { |
1253 IncrementPrefValue(prefs::kStabilityRendererHangCount); | 1271 IncrementPrefValue(prefs::kStabilityRendererHangCount); |
1254 } | 1272 } |
1255 | 1273 |
1256 void MetricsService::LogNeedForCleanShutdown() { | 1274 void MetricsService::LogNeedForCleanShutdown() { |
1257 PrefService* pref = g_browser_process->local_state(); | 1275 PrefService* pref = g_browser_process->local_state(); |
1258 pref->SetBoolean(prefs::kStabilityExitedCleanly, false); | 1276 pref->SetBoolean(prefs::kStabilityExitedCleanly, false); |
1259 // Redundant setting to be sure we call for a clean shutdown. | 1277 // Redundant setting to be sure we call for a clean shutdown. |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 if (local_state) { | 1536 if (local_state) { |
1519 const PrefService::Preference* uma_pref = | 1537 const PrefService::Preference* uma_pref = |
1520 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1538 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
1521 if (uma_pref) { | 1539 if (uma_pref) { |
1522 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1540 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
1523 DCHECK(success); | 1541 DCHECK(success); |
1524 } | 1542 } |
1525 } | 1543 } |
1526 return result; | 1544 return result; |
1527 } | 1545 } |
OLD | NEW |