| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_ACCESSOR_H_ | 5 #ifndef CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_ACCESSOR_H_ |
| 6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_ACCESSOR_H_ | 6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_ACCESSOR_H_ |
| 7 | 7 |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "chrome/browser/metrics/metrics_service_accessor.h" |
| 10 | 11 |
| 11 class ChromeBrowserMetricsServiceObserver; | 12 class ChromeBrowserMetricsServiceObserver; |
| 12 class MetricsServiceObserver; | |
| 13 class Profile; | 13 class Profile; |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 class CrashesDOMHandler; | 16 class CrashesDOMHandler; |
| 17 class FlashDOMHandler; | 17 class FlashDOMHandler; |
| 18 } | 18 } |
| 19 | 19 |
| 20 namespace extensions { | 20 namespace extensions { |
| 21 class ExtensionDownloader; | 21 class ExtensionDownloader; |
| 22 class ManifestFetchData; | 22 class ManifestFetchData; |
| 23 class MetricsPrivateGetIsCrashReportingEnabledFunction; | 23 class MetricsPrivateGetIsCrashReportingEnabledFunction; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace prerender { | 26 namespace prerender { |
| 27 bool IsOmniboxEnabled(Profile* profile); | 27 bool IsOmniboxEnabled(Profile* profile); |
| 28 } | 28 } |
| 29 | 29 |
| 30 namespace system_logs { | 30 namespace system_logs { |
| 31 class ChromeInternalLogSource; | 31 class ChromeInternalLogSource; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // This class limits and documents access to metrics service helper methods. | 34 // This class limits and documents access to metrics service helper methods. |
| 35 // Since these methods are private, each user has to be explicitly declared | 35 // Since these methods are private, each user has to be explicitly declared |
| 36 // as a 'friend' below. | 36 // as a 'friend' below. |
| 37 class ChromeMetricsServiceAccessor { | 37 class ChromeMetricsServiceAccessor : public MetricsServiceAccessor { |
| 38 private: | 38 private: |
| 39 friend bool prerender::IsOmniboxEnabled(Profile* profile); | 39 friend bool prerender::IsOmniboxEnabled(Profile* profile); |
| 40 friend class ::ChromeBrowserMetricsServiceObserver; | 40 friend class ::ChromeBrowserMetricsServiceObserver; |
| 41 friend class ChromeRenderMessageFilter; | 41 friend class ChromeRenderMessageFilter; |
| 42 friend class ::CrashesDOMHandler; | 42 friend class ::CrashesDOMHandler; |
| 43 friend class extensions::ExtensionDownloader; | 43 friend class extensions::ExtensionDownloader; |
| 44 friend class extensions::ManifestFetchData; | 44 friend class extensions::ManifestFetchData; |
| 45 friend class extensions::MetricsPrivateGetIsCrashReportingEnabledFunction; | 45 friend class extensions::MetricsPrivateGetIsCrashReportingEnabledFunction; |
| 46 friend class ::FlashDOMHandler; | 46 friend class ::FlashDOMHandler; |
| 47 friend class system_logs::ChromeInternalLogSource; | 47 friend class system_logs::ChromeInternalLogSource; |
| 48 | 48 |
| 49 FRIEND_TEST_ALL_PREFIXES(ChromeMetricsServiceAccessorTest, | 49 FRIEND_TEST_ALL_PREFIXES(ChromeMetricsServiceAccessorTest, |
| 50 MetricsReportingEnabled); | 50 MetricsReportingEnabled); |
| 51 FRIEND_TEST_ALL_PREFIXES(ChromeMetricsServiceAccessorTest, | 51 FRIEND_TEST_ALL_PREFIXES(ChromeMetricsServiceAccessorTest, |
| 52 CrashReportingEnabled); | 52 CrashReportingEnabled); |
| 53 | 53 |
| 54 // Returns true if prefs::kMetricsReportingEnabled is set. | 54 // Returns true if prefs::kMetricsReportingEnabled is set. |
| 55 // TODO(asvitkine): Consolidate the method in MetricsStateManager. | 55 // TODO(asvitkine): Consolidate the method in MetricsStateManager. |
| 56 // TODO(asvitkine): This function does not report the correct value on | 56 // TODO(asvitkine): This function does not report the correct value on |
| 57 // Android and ChromeOS, see http://crbug.com/362192. | 57 // Android and ChromeOS, see http://crbug.com/362192. |
| 58 static bool IsMetricsReportingEnabled(); | 58 static bool IsMetricsReportingEnabled(); |
| 59 | 59 |
| 60 // Returns true if crash reporting is enabled. This is set at the platform | 60 // Returns true if crash reporting is enabled. This is set at the platform |
| 61 // level for Android and ChromeOS, and otherwise is the same as | 61 // level for Android and ChromeOS, and otherwise is the same as |
| 62 // IsMetricsReportingEnabled for desktop Chrome. | 62 // IsMetricsReportingEnabled for desktop Chrome. |
| 63 static bool IsCrashReportingEnabled(); | 63 static bool IsCrashReportingEnabled(); |
| 64 | 64 |
| 65 // Registers/unregisters |observer| to receive MetricsLog notifications | |
| 66 // from metrics service. | |
| 67 static void AddMetricsServiceObserver(MetricsServiceObserver* observer); | |
| 68 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer); | |
| 69 | |
| 70 DISALLOW_IMPLICIT_CONSTRUCTORS(ChromeMetricsServiceAccessor); | 65 DISALLOW_IMPLICIT_CONSTRUCTORS(ChromeMetricsServiceAccessor); |
| 71 }; | 66 }; |
| 72 | 67 |
| 73 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_ACCESSOR_H_ | 68 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_ACCESSOR_H_ |
| OLD | NEW |