| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 break; | 667 break; |
| 668 | 668 |
| 669 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { | 669 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { |
| 670 content::RenderProcessHost::RendererClosedDetails* process_details = | 670 content::RenderProcessHost::RendererClosedDetails* process_details = |
| 671 content::Details< | 671 content::Details< |
| 672 content::RenderProcessHost::RendererClosedDetails>( | 672 content::RenderProcessHost::RendererClosedDetails>( |
| 673 details).ptr(); | 673 details).ptr(); |
| 674 content::RenderProcessHost* host = | 674 content::RenderProcessHost* host = |
| 675 content::Source<content::RenderProcessHost>(source).ptr(); | 675 content::Source<content::RenderProcessHost>(source).ptr(); |
| 676 LogRendererCrash( | 676 LogRendererCrash( |
| 677 host, process_details->status, process_details->exit_code, | 677 host, process_details->status, process_details->exit_code); |
| 678 process_details->was_alive); | |
| 679 } | 678 } |
| 680 break; | 679 break; |
| 681 | 680 |
| 682 case content::NOTIFICATION_RENDERER_PROCESS_HANG: | 681 case content::NOTIFICATION_RENDERER_PROCESS_HANG: |
| 683 LogRendererHang(); | 682 LogRendererHang(); |
| 684 break; | 683 break; |
| 685 | 684 |
| 686 case content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED: | 685 case content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED: |
| 687 case content::NOTIFICATION_CHILD_PROCESS_CRASHED: | 686 case content::NOTIFICATION_CHILD_PROCESS_CRASHED: |
| 688 case content::NOTIFICATION_CHILD_INSTANCE_CREATED: | 687 case content::NOTIFICATION_CHILD_INSTANCE_CREATED: |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 void MetricsService::LogLoadStarted() { | 1551 void MetricsService::LogLoadStarted() { |
| 1553 HISTOGRAM_ENUMERATION("Chrome.UmaPageloadCounter", 1, 2); | 1552 HISTOGRAM_ENUMERATION("Chrome.UmaPageloadCounter", 1, 2); |
| 1554 IncrementPrefValue(prefs::kStabilityPageLoadCount); | 1553 IncrementPrefValue(prefs::kStabilityPageLoadCount); |
| 1555 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); | 1554 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); |
| 1556 // We need to save the prefs, as page load count is a critical stat, and it | 1555 // We need to save the prefs, as page load count is a critical stat, and it |
| 1557 // might be lost due to a crash :-(. | 1556 // might be lost due to a crash :-(. |
| 1558 } | 1557 } |
| 1559 | 1558 |
| 1560 void MetricsService::LogRendererCrash(content::RenderProcessHost* host, | 1559 void MetricsService::LogRendererCrash(content::RenderProcessHost* host, |
| 1561 base::TerminationStatus status, | 1560 base::TerminationStatus status, |
| 1562 int exit_code, | 1561 int exit_code) { |
| 1563 bool was_alive) { | |
| 1564 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); | 1562 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); |
| 1565 ExtensionService* service = profile->GetExtensionService(); | 1563 ExtensionService* service = profile->GetExtensionService(); |
| 1566 bool was_extension_process = | 1564 bool was_extension_process = |
| 1567 service && service->process_map()->Contains(host->GetID()); | 1565 service && service->process_map()->Contains(host->GetID()); |
| 1568 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || | 1566 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || |
| 1569 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { | 1567 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { |
| 1570 if (was_extension_process) { | 1568 if (was_extension_process) { |
| 1571 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); | 1569 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); |
| 1572 | 1570 |
| 1573 UMA_HISTOGRAM_CUSTOM_ENUMERATION("CrashExitCodes.Extension", | 1571 UMA_HISTOGRAM_CUSTOM_ENUMERATION("CrashExitCodes.Extension", |
| 1574 MapCrashExitCodeForHistogram(exit_code), | 1572 MapCrashExitCodeForHistogram(exit_code), |
| 1575 GetAllCrashExitCodes()); | 1573 GetAllCrashExitCodes()); |
| 1576 } else { | 1574 } else { |
| 1577 IncrementPrefValue(prefs::kStabilityRendererCrashCount); | 1575 IncrementPrefValue(prefs::kStabilityRendererCrashCount); |
| 1578 | 1576 |
| 1579 UMA_HISTOGRAM_CUSTOM_ENUMERATION("CrashExitCodes.Renderer", | 1577 UMA_HISTOGRAM_CUSTOM_ENUMERATION("CrashExitCodes.Renderer", |
| 1580 MapCrashExitCodeForHistogram(exit_code), | 1578 MapCrashExitCodeForHistogram(exit_code), |
| 1581 GetAllCrashExitCodes()); | 1579 GetAllCrashExitCodes()); |
| 1582 } | 1580 } |
| 1583 | 1581 |
| 1584 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", | 1582 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", |
| 1585 was_extension_process ? 2 : 1); | 1583 was_extension_process ? 2 : 1); |
| 1586 if (was_alive) { | |
| 1587 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashesWasAlive", | |
| 1588 was_extension_process ? 2 : 1); | |
| 1589 } | |
| 1590 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { | 1584 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { |
| 1591 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", | 1585 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", |
| 1592 was_extension_process ? 2 : 1); | 1586 was_extension_process ? 2 : 1); |
| 1593 if (was_alive) { | 1587 } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) { |
| 1594 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKillsWasAlive", | 1588 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.DisconnectedAlive", |
| 1595 was_extension_process ? 2 : 1); | 1589 was_extension_process ? 2 : 1); |
| 1596 } | |
| 1597 } | 1590 } |
| 1598 } | 1591 } |
| 1599 | 1592 |
| 1600 void MetricsService::LogRendererHang() { | 1593 void MetricsService::LogRendererHang() { |
| 1601 IncrementPrefValue(prefs::kStabilityRendererHangCount); | 1594 IncrementPrefValue(prefs::kStabilityRendererHangCount); |
| 1602 } | 1595 } |
| 1603 | 1596 |
| 1604 void MetricsService::LogNeedForCleanShutdown() { | 1597 void MetricsService::LogNeedForCleanShutdown() { |
| 1605 PrefService* pref = g_browser_process->local_state(); | 1598 PrefService* pref = g_browser_process->local_state(); |
| 1606 pref->SetBoolean(prefs::kStabilityExitedCleanly, false); | 1599 pref->SetBoolean(prefs::kStabilityExitedCleanly, false); |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1865 if (local_state) { | 1858 if (local_state) { |
| 1866 const PrefService::Preference* uma_pref = | 1859 const PrefService::Preference* uma_pref = |
| 1867 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1860 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
| 1868 if (uma_pref) { | 1861 if (uma_pref) { |
| 1869 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1862 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
| 1870 DCHECK(success); | 1863 DCHECK(success); |
| 1871 } | 1864 } |
| 1872 } | 1865 } |
| 1873 return result; | 1866 return result; |
| 1874 } | 1867 } |
| OLD | NEW |