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 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 break; | 673 break; |
674 | 674 |
675 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { | 675 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { |
676 content::RenderProcessHost::RendererClosedDetails* process_details = | 676 content::RenderProcessHost::RendererClosedDetails* process_details = |
677 content::Details< | 677 content::Details< |
678 content::RenderProcessHost::RendererClosedDetails>( | 678 content::RenderProcessHost::RendererClosedDetails>( |
679 details).ptr(); | 679 details).ptr(); |
680 content::RenderProcessHost* host = | 680 content::RenderProcessHost* host = |
681 content::Source<content::RenderProcessHost>(source).ptr(); | 681 content::Source<content::RenderProcessHost>(source).ptr(); |
682 LogRendererCrash( | 682 LogRendererCrash( |
683 host, process_details->status, process_details->exit_code, | 683 host, process_details->status, process_details->exit_code); |
684 process_details->was_alive); | |
685 } | 684 } |
686 break; | 685 break; |
687 | 686 |
688 case content::NOTIFICATION_RENDERER_PROCESS_HANG: | 687 case content::NOTIFICATION_RENDERER_PROCESS_HANG: |
689 LogRendererHang(); | 688 LogRendererHang(); |
690 break; | 689 break; |
691 | 690 |
692 case content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED: | 691 case content::NOTIFICATION_CHILD_PROCESS_HOST_CONNECTED: |
693 case content::NOTIFICATION_CHILD_PROCESS_CRASHED: | 692 case content::NOTIFICATION_CHILD_PROCESS_CRASHED: |
694 case content::NOTIFICATION_CHILD_INSTANCE_CREATED: | 693 case content::NOTIFICATION_CHILD_INSTANCE_CREATED: |
(...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1558 void MetricsService::LogLoadStarted() { | 1557 void MetricsService::LogLoadStarted() { |
1559 HISTOGRAM_ENUMERATION("Chrome.UmaPageloadCounter", 1, 2); | 1558 HISTOGRAM_ENUMERATION("Chrome.UmaPageloadCounter", 1, 2); |
1560 IncrementPrefValue(prefs::kStabilityPageLoadCount); | 1559 IncrementPrefValue(prefs::kStabilityPageLoadCount); |
1561 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); | 1560 IncrementLongPrefsValue(prefs::kUninstallMetricsPageLoadCount); |
1562 // We need to save the prefs, as page load count is a critical stat, and it | 1561 // We need to save the prefs, as page load count is a critical stat, and it |
1563 // might be lost due to a crash :-(. | 1562 // might be lost due to a crash :-(. |
1564 } | 1563 } |
1565 | 1564 |
1566 void MetricsService::LogRendererCrash(content::RenderProcessHost* host, | 1565 void MetricsService::LogRendererCrash(content::RenderProcessHost* host, |
1567 base::TerminationStatus status, | 1566 base::TerminationStatus status, |
1568 int exit_code, | 1567 int exit_code) { |
1569 bool was_alive) { | |
1570 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); | 1568 Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); |
1571 ExtensionService* service = profile->GetExtensionService(); | 1569 ExtensionService* service = profile->GetExtensionService(); |
1572 bool was_extension_process = | 1570 bool was_extension_process = |
1573 service && service->process_map()->Contains(host->GetID()); | 1571 service && service->process_map()->Contains(host->GetID()); |
1574 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || | 1572 if (status == base::TERMINATION_STATUS_PROCESS_CRASHED || |
1575 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { | 1573 status == base::TERMINATION_STATUS_ABNORMAL_TERMINATION) { |
1576 if (was_extension_process) { | 1574 if (was_extension_process) { |
1577 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); | 1575 IncrementPrefValue(prefs::kStabilityExtensionRendererCrashCount); |
1578 | 1576 |
1579 UMA_HISTOGRAM_CUSTOM_ENUMERATION("CrashExitCodes.Extension", | 1577 UMA_HISTOGRAM_CUSTOM_ENUMERATION("CrashExitCodes.Extension", |
1580 MapCrashExitCodeForHistogram(exit_code), | 1578 MapCrashExitCodeForHistogram(exit_code), |
1581 GetAllCrashExitCodes()); | 1579 GetAllCrashExitCodes()); |
1582 } else { | 1580 } else { |
1583 IncrementPrefValue(prefs::kStabilityRendererCrashCount); | 1581 IncrementPrefValue(prefs::kStabilityRendererCrashCount); |
1584 | 1582 |
1585 UMA_HISTOGRAM_CUSTOM_ENUMERATION("CrashExitCodes.Renderer", | 1583 UMA_HISTOGRAM_CUSTOM_ENUMERATION("CrashExitCodes.Renderer", |
1586 MapCrashExitCodeForHistogram(exit_code), | 1584 MapCrashExitCodeForHistogram(exit_code), |
1587 GetAllCrashExitCodes()); | 1585 GetAllCrashExitCodes()); |
1588 } | 1586 } |
1589 | 1587 |
1590 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", | 1588 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashes", |
1591 was_extension_process ? 2 : 1); | 1589 was_extension_process ? 2 : 1); |
1592 if (was_alive) { | |
1593 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildCrashesWasAlive", | |
1594 was_extension_process ? 2 : 1); | |
1595 } | |
1596 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { | 1590 } else if (status == base::TERMINATION_STATUS_PROCESS_WAS_KILLED) { |
1597 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", | 1591 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKills", |
1598 was_extension_process ? 2 : 1); | 1592 was_extension_process ? 2 : 1); |
1599 if (was_alive) { | 1593 } else if (status == base::TERMINATION_STATUS_STILL_RUNNING) { |
1600 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.ChildKillsWasAlive", | 1594 UMA_HISTOGRAM_PERCENTAGE("BrowserRenderProcessHost.DisconnectedAlive", |
1601 was_extension_process ? 2 : 1); | 1595 was_extension_process ? 2 : 1); |
1602 } | 1596 } |
1603 } | 1597 } |
1604 } | |
1605 | 1598 |
1606 void MetricsService::LogRendererHang() { | 1599 void MetricsService::LogRendererHang() { |
1607 IncrementPrefValue(prefs::kStabilityRendererHangCount); | 1600 IncrementPrefValue(prefs::kStabilityRendererHangCount); |
1608 } | 1601 } |
1609 | 1602 |
1610 void MetricsService::LogNeedForCleanShutdown() { | 1603 void MetricsService::LogNeedForCleanShutdown() { |
1611 PrefService* pref = g_browser_process->local_state(); | 1604 PrefService* pref = g_browser_process->local_state(); |
1612 pref->SetBoolean(prefs::kStabilityExitedCleanly, false); | 1605 pref->SetBoolean(prefs::kStabilityExitedCleanly, false); |
1613 // Redundant setting to be sure we call for a clean shutdown. | 1606 // Redundant setting to be sure we call for a clean shutdown. |
1614 clean_shutdown_status_ = NEED_TO_SHUTDOWN; | 1607 clean_shutdown_status_ = NEED_TO_SHUTDOWN; |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1874 } | 1867 } |
1875 | 1868 |
1876 void MetricsService::RecordCurrentState(PrefService* pref) { | 1869 void MetricsService::RecordCurrentState(PrefService* pref) { |
1877 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); | 1870 pref->SetInt64(prefs::kStabilityLastTimestampSec, Time::Now().ToTimeT()); |
1878 | 1871 |
1879 RecordPluginChanges(pref); | 1872 RecordPluginChanges(pref); |
1880 } | 1873 } |
1881 | 1874 |
1882 // static | 1875 // static |
1883 bool MetricsService::IsPluginProcess(content::ProcessType type) { | 1876 bool MetricsService::IsPluginProcess(content::ProcessType type) { |
1884 return (type == content::PROCESS_TYPE_PLUGIN || | 1877 return (type == content::PROCESS_TYPE_PLUGIN|| |
1885 type == content::PROCESS_TYPE_PPAPI_PLUGIN || | 1878 type == content::PROCESS_TYPE_PPAPI_PLUGIN || |
1886 type == content::PROCESS_TYPE_PPAPI_BROKER); | 1879 type == content::PROCESS_TYPE_PPAPI_BROKER); |
1887 } | 1880 } |
1888 | 1881 |
1889 #if defined(OS_CHROMEOS) | 1882 #if defined(OS_CHROMEOS) |
1890 void MetricsService::StartExternalMetrics() { | 1883 void MetricsService::StartExternalMetrics() { |
1891 external_metrics_ = new chromeos::ExternalMetrics; | 1884 external_metrics_ = new chromeos::ExternalMetrics; |
1892 external_metrics_->Start(); | 1885 external_metrics_->Start(); |
1893 } | 1886 } |
1894 #endif | 1887 #endif |
1895 | 1888 |
1896 // static | 1889 // static |
1897 bool MetricsServiceHelper::IsMetricsReportingEnabled() { | 1890 bool MetricsServiceHelper::IsMetricsReportingEnabled() { |
1898 bool result = false; | 1891 bool result = false; |
1899 const PrefService* local_state = g_browser_process->local_state(); | 1892 const PrefService* local_state = g_browser_process->local_state(); |
1900 if (local_state) { | 1893 if (local_state) { |
1901 const PrefService::Preference* uma_pref = | 1894 const PrefService::Preference* uma_pref = |
1902 local_state->FindPreference(prefs::kMetricsReportingEnabled); | 1895 local_state->FindPreference(prefs::kMetricsReportingEnabled); |
1903 if (uma_pref) { | 1896 if (uma_pref) { |
1904 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | 1897 bool success = uma_pref->GetValue()->GetAsBoolean(&result); |
1905 DCHECK(success); | 1898 DCHECK(success); |
1906 } | 1899 } |
1907 } | 1900 } |
1908 return result; | 1901 return result; |
1909 } | 1902 } |
OLD | NEW |