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 is | 10 // A MetricsService instance is typically created at application startup. It is |
(...skipping 1744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1755 | 1755 |
1756 RecordPluginChanges(pref); | 1756 RecordPluginChanges(pref); |
1757 } | 1757 } |
1758 | 1758 |
1759 // static | 1759 // static |
1760 bool MetricsService::IsPluginProcess(int process_type) { | 1760 bool MetricsService::IsPluginProcess(int process_type) { |
1761 return (process_type == content::PROCESS_TYPE_PLUGIN || | 1761 return (process_type == content::PROCESS_TYPE_PLUGIN || |
1762 process_type == content::PROCESS_TYPE_PPAPI_PLUGIN || | 1762 process_type == content::PROCESS_TYPE_PPAPI_PLUGIN || |
1763 process_type == content::PROCESS_TYPE_PPAPI_BROKER); | 1763 process_type == content::PROCESS_TYPE_PPAPI_BROKER); |
1764 } | 1764 } |
1765 | |
1766 // static | |
1767 bool MetricsServiceHelper::IsMetricsReportingEnabled() { | |
1768 bool result = false; | |
1769 const PrefService* local_state = g_browser_process->local_state(); | |
1770 if (local_state) { | |
1771 const PrefService::Preference* uma_pref = | |
1772 local_state->FindPreference(prefs::kMetricsReportingEnabled); | |
1773 if (uma_pref) { | |
1774 bool success = uma_pref->GetValue()->GetAsBoolean(&result); | |
1775 DCHECK(success); | |
1776 } | |
1777 } | |
1778 return result; | |
1779 } | |
1780 | |
1781 bool MetricsServiceHelper::IsCrashReportingEnabled() { | |
1782 #if defined(GOOGLE_CHROME_BUILD) | |
1783 #if defined(OS_CHROMEOS) | |
1784 bool reporting_enabled = false; | |
1785 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kStatsReportingPref, | |
1786 &reporting_enabled); | |
1787 return reporting_enabled; | |
1788 #elif defined(OS_ANDROID) | |
1789 // Android has its own settings for metrics / crash uploading. | |
1790 const PrefService* prefs = g_browser_process->local_state(); | |
1791 return prefs->GetBoolean(prefs::kCrashReportingEnabled); | |
1792 #else | |
1793 return MetricsServiceHelper::IsMetricsReportingEnabled(); | |
1794 #endif | |
1795 #else | |
1796 return false; | |
1797 #endif | |
1798 } | |
1799 | |
1800 void MetricsServiceHelper::AddMetricsServiceObserver( | |
1801 MetricsServiceObserver* observer) { | |
1802 MetricsService* metrics_service = g_browser_process->metrics_service(); | |
1803 if (metrics_service) | |
1804 metrics_service->AddObserver(observer); | |
1805 } | |
1806 | |
1807 void MetricsServiceHelper::RemoveMetricsServiceObserver( | |
1808 MetricsServiceObserver* observer) { | |
1809 MetricsService* metrics_service = g_browser_process->metrics_service(); | |
1810 if (metrics_service) | |
1811 metrics_service->RemoveObserver(observer); | |
1812 } | |
OLD | NEW |