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 // This file defines a service that collects information about the user | 5 // This file defines a service that collects information about the user |
6 // experience in order to help improve future versions of the app. | 6 // experience in order to help improve future versions of the app. |
7 | 7 |
8 #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 8 #ifndef CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
9 #define CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 9 #define CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "chrome/common/metrics/metrics_service_base.h" | 28 #include "chrome/common/metrics/metrics_service_base.h" |
29 #include "components/metrics/metrics_provider.h" | 29 #include "components/metrics/metrics_provider.h" |
30 #include "components/metrics/metrics_service_observer.h" | 30 #include "components/metrics/metrics_service_observer.h" |
31 #include "components/variations/active_field_trials.h" | 31 #include "components/variations/active_field_trials.h" |
32 #include "content/public/browser/browser_child_process_observer.h" | 32 #include "content/public/browser/browser_child_process_observer.h" |
33 #include "content/public/browser/notification_observer.h" | 33 #include "content/public/browser/notification_observer.h" |
34 #include "content/public/browser/notification_registrar.h" | 34 #include "content/public/browser/notification_registrar.h" |
35 #include "content/public/browser/user_metrics.h" | 35 #include "content/public/browser/user_metrics.h" |
36 #include "net/url_request/url_fetcher_delegate.h" | 36 #include "net/url_request/url_fetcher_delegate.h" |
37 | 37 |
38 class ChromeBrowserMetricsServiceObserver; | |
39 class GoogleUpdateMetricsProviderWin; | 38 class GoogleUpdateMetricsProviderWin; |
40 class MetricsReportingScheduler; | 39 class MetricsReportingScheduler; |
41 class PrefService; | 40 class PrefService; |
42 class PrefRegistrySimple; | 41 class PrefRegistrySimple; |
43 class Profile; | |
44 class TemplateURLService; | |
45 | |
46 namespace { | |
47 class CrashesDOMHandler; | |
48 class FlashDOMHandler; | |
49 } | |
50 | 42 |
51 namespace base { | 43 namespace base { |
52 class DictionaryValue; | 44 class DictionaryValue; |
53 class MessageLoopProxy; | 45 class MessageLoopProxy; |
54 } | 46 } |
55 | 47 |
56 namespace variations { | 48 namespace variations { |
57 struct ActiveGroupId; | 49 struct ActiveGroupId; |
58 } | 50 } |
59 | 51 |
60 namespace content { | 52 namespace content { |
61 class RenderProcessHost; | 53 class RenderProcessHost; |
62 class WebContents; | 54 class WebContents; |
63 struct WebPluginInfo; | 55 struct WebPluginInfo; |
64 } | 56 } |
65 | 57 |
66 namespace extensions { | |
67 class ExtensionDownloader; | |
68 class ManifestFetchData; | |
69 class MetricsPrivateGetIsCrashReportingEnabledFunction; | |
70 } | |
71 | |
72 namespace metrics { | 58 namespace metrics { |
73 class MetricsServiceClient; | 59 class MetricsServiceClient; |
74 class MetricsStateManager; | 60 class MetricsStateManager; |
75 } | 61 } |
76 | 62 |
77 namespace net { | 63 namespace net { |
78 class URLFetcher; | 64 class URLFetcher; |
79 } | 65 } |
80 | 66 |
81 namespace prerender { | |
82 bool IsOmniboxEnabled(Profile* profile); | |
83 } | |
84 | |
85 namespace system_logs { | |
86 class ChromeInternalLogSource; | |
87 } | |
88 | |
89 namespace tracked_objects { | 67 namespace tracked_objects { |
90 struct ProcessDataSnapshot; | 68 struct ProcessDataSnapshot; |
91 } | 69 } |
92 | 70 |
93 // A Field Trial and its selected group, which represent a particular | 71 // A Field Trial and its selected group, which represent a particular |
94 // Chrome configuration state. For example, the trial name could map to | 72 // Chrome configuration state. For example, the trial name could map to |
95 // a preference name, and the group name could map to a preference value. | 73 // a preference name, and the group name could map to a preference value. |
96 struct SyntheticTrialGroup { | 74 struct SyntheticTrialGroup { |
97 public: | 75 public: |
98 ~SyntheticTrialGroup(); | 76 ~SyntheticTrialGroup(); |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
563 static ShutdownCleanliness clean_shutdown_status_; | 541 static ShutdownCleanliness clean_shutdown_status_; |
564 | 542 |
565 // Field trial groups that map to Chrome configuration states. | 543 // Field trial groups that map to Chrome configuration states. |
566 SyntheticTrialGroups synthetic_trial_groups_; | 544 SyntheticTrialGroups synthetic_trial_groups_; |
567 | 545 |
568 ObserverList<MetricsServiceObserver> observers_; | 546 ObserverList<MetricsServiceObserver> observers_; |
569 | 547 |
570 // Confirms single-threaded access to |observers_| in debug builds. | 548 // Confirms single-threaded access to |observers_| in debug builds. |
571 base::ThreadChecker thread_checker_; | 549 base::ThreadChecker thread_checker_; |
572 | 550 |
573 friend class MetricsServiceHelper; | 551 friend class ChromeMetricsServiceAccessor; |
574 | 552 |
575 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); | 553 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, IsPluginProcess); |
576 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsServiceObserver); | 554 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsServiceObserver); |
577 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, | 555 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, |
578 PermutedEntropyCacheClearedWhenLowEntropyReset); | 556 PermutedEntropyCacheClearedWhenLowEntropyReset); |
579 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); | 557 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, RegisterSyntheticTrial); |
580 | 558 |
581 DISALLOW_COPY_AND_ASSIGN(MetricsService); | 559 DISALLOW_COPY_AND_ASSIGN(MetricsService); |
582 }; | 560 }; |
583 | 561 |
584 // This class limits and documents access to metrics service helper methods. | |
585 // Since these methods are private, each user has to be explicitly declared | |
586 // as a 'friend' below. | |
587 class MetricsServiceHelper { | |
588 private: | |
589 friend bool prerender::IsOmniboxEnabled(Profile* profile); | |
590 friend class ::ChromeBrowserMetricsServiceObserver; | |
591 friend class ChromeRenderMessageFilter; | |
592 friend class ::CrashesDOMHandler; | |
593 friend class extensions::ExtensionDownloader; | |
594 friend class extensions::ManifestFetchData; | |
595 friend class extensions::MetricsPrivateGetIsCrashReportingEnabledFunction; | |
596 friend class ::FlashDOMHandler; | |
597 friend class system_logs::ChromeInternalLogSource; | |
598 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, MetricsReportingEnabled); | |
599 FRIEND_TEST_ALL_PREFIXES(MetricsServiceTest, CrashReportingEnabled); | |
600 | |
601 // Returns true if prefs::kMetricsReportingEnabled is set. | |
602 // TODO(asvitkine): Consolidate the method in MetricsStateManager. | |
603 // TODO(asvitkine): This function does not report the correct value on | |
604 // Android and ChromeOS, see http://crbug.com/362192. | |
605 static bool IsMetricsReportingEnabled(); | |
606 | |
607 // Returns true if crash reporting is enabled. This is set at the platform | |
608 // level for Android and ChromeOS, and otherwise is the same as | |
609 // IsMetricsReportingEnabled for desktop Chrome. | |
610 static bool IsCrashReportingEnabled(); | |
611 | |
612 // Registers/unregisters |observer| to receive MetricsLog notifications | |
613 // from metrics service. | |
614 static void AddMetricsServiceObserver(MetricsServiceObserver* observer); | |
615 static void RemoveMetricsServiceObserver(MetricsServiceObserver* observer); | |
616 | |
617 DISALLOW_IMPLICIT_CONSTRUCTORS(MetricsServiceHelper); | |
618 }; | |
619 | |
620 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ | 562 #endif // CHROME_BROWSER_METRICS_METRICS_SERVICE_H_ |
OLD | NEW |