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_CLIENT_H_ | 5 #ifndef CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ |
6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ | 6 #define CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
14 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
15 #include "chrome/browser/metrics/network_stats_uploader.h" | 15 #include "chrome/browser/metrics/network_stats_uploader.h" |
16 #include "chrome/browser/metrics/tracking_synchronizer_observer.h" | |
16 #include "components/metrics/metrics_service_client.h" | 17 #include "components/metrics/metrics_service_client.h" |
17 #include "content/public/browser/notification_observer.h" | 18 #include "content/public/browser/notification_observer.h" |
18 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
19 | 20 |
20 class ChromeOSMetricsProvider; | 21 class ChromeOSMetricsProvider; |
22 class GoogleUpdateMetricsProviderWin; | |
21 class MetricsService; | 23 class MetricsService; |
24 class PluginMetricsProvider; | |
25 class PrefRegistrySimple; | |
26 class ProfilerMetricsProvider; | |
27 | |
28 namespace base { | |
29 class FilePath; | |
30 } | |
22 | 31 |
23 namespace metrics { | 32 namespace metrics { |
24 class MetricsStateManager; | 33 class MetricsStateManager; |
25 } | 34 } |
26 | 35 |
27 // ChromeMetricsServiceClient provides an implementation of MetricsServiceClient | 36 // ChromeMetricsServiceClient provides an implementation of MetricsServiceClient |
28 // that depends on chrome/. | 37 // that depends on chrome/. |
29 class ChromeMetricsServiceClient : public metrics::MetricsServiceClient, | 38 class ChromeMetricsServiceClient |
30 public content::NotificationObserver { | 39 : public metrics::MetricsServiceClient, |
40 public chrome_browser_metrics::TrackingSynchronizerObserver, | |
41 public content::NotificationObserver { | |
31 public: | 42 public: |
32 virtual ~ChromeMetricsServiceClient(); | 43 virtual ~ChromeMetricsServiceClient(); |
33 | 44 |
34 // Factory function. | 45 // Factory function. |
35 static scoped_ptr<ChromeMetricsServiceClient> Create( | 46 static scoped_ptr<ChromeMetricsServiceClient> Create( |
36 metrics::MetricsStateManager* state_manager, | 47 metrics::MetricsStateManager* state_manager, |
37 PrefService* local_state); | 48 PrefService* local_state); |
38 | 49 |
50 // Registers local state prefs used by this class. | |
51 static void RegisterPrefs(PrefRegistrySimple* registry); | |
52 | |
39 // metrics::MetricsServiceClient: | 53 // metrics::MetricsServiceClient: |
40 virtual void SetClientID(const std::string& client_id) OVERRIDE; | 54 virtual void SetClientID(const std::string& client_id) OVERRIDE; |
41 virtual bool IsOffTheRecordSessionActive() OVERRIDE; | 55 virtual bool IsOffTheRecordSessionActive() OVERRIDE; |
42 virtual std::string GetApplicationLocale() OVERRIDE; | 56 virtual std::string GetApplicationLocale() OVERRIDE; |
43 virtual bool GetBrand(std::string* brand_code) OVERRIDE; | 57 virtual bool GetBrand(std::string* brand_code) OVERRIDE; |
44 virtual metrics::SystemProfileProto::Channel GetChannel() OVERRIDE; | 58 virtual metrics::SystemProfileProto::Channel GetChannel() OVERRIDE; |
45 virtual std::string GetVersionString() OVERRIDE; | 59 virtual std::string GetVersionString() OVERRIDE; |
46 virtual int64 GetInstallDate() OVERRIDE; | 60 virtual int64 GetInstallDate() OVERRIDE; |
47 virtual void OnLogUploadComplete() OVERRIDE; | 61 virtual void OnLogUploadComplete() OVERRIDE; |
48 virtual void StartGatheringMetrics( | 62 virtual void StartGatheringMetrics( |
49 const base::Closure& done_callback) OVERRIDE; | 63 const base::Closure& done_callback) OVERRIDE; |
50 virtual void CollectFinalMetrics(const base::Closure& done_callback) | 64 virtual void CollectFinalMetrics(const base::Closure& done_callback) |
51 OVERRIDE; | 65 OVERRIDE; |
52 virtual scoped_ptr<metrics::MetricsLogUploader> CreateUploader( | 66 virtual scoped_ptr<metrics::MetricsLogUploader> CreateUploader( |
53 const std::string& server_url, | 67 const std::string& server_url, |
54 const std::string& mime_type, | 68 const std::string& mime_type, |
55 const base::Callback<void(int)>& on_upload_complete) OVERRIDE; | 69 const base::Callback<void(int)>& on_upload_complete) OVERRIDE; |
56 | 70 |
57 MetricsService* metrics_service() { return metrics_service_.get(); } | 71 MetricsService* metrics_service() { return metrics_service_.get(); } |
58 | 72 |
73 void LogPluginLoadingError(const base::FilePath& plugin_path); | |
74 | |
59 private: | 75 private: |
60 explicit ChromeMetricsServiceClient( | 76 explicit ChromeMetricsServiceClient( |
61 metrics::MetricsStateManager* state_manager); | 77 metrics::MetricsStateManager* state_manager); |
62 | 78 |
79 // TrackingSynchronizerObserver: | |
80 virtual void ReceivedProfilerData( | |
81 const tracked_objects::ProcessDataSnapshot& process_data, | |
82 int process_type) OVERRIDE; | |
83 virtual void FinishedReceivingProfilerData() OVERRIDE; | |
84 | |
63 // Completes the two-phase initialization of ChromeMetricsServiceClient. | 85 // Completes the two-phase initialization of ChromeMetricsServiceClient. |
64 void Initialize(); | 86 void Initialize(); |
65 | 87 |
88 // Callback that continues the init task by loading plugin information. | |
89 void OnInitTaskGotHardwareClass(); | |
90 | |
91 // Called after the Plugin init task has been completed that continues the | |
92 // init task by launching a task to gather Google Update statistics. | |
93 void OnInitTaskGotPluginInfo(); | |
94 | |
95 // Called after GoogleUpdate init task has been completed that continues the | |
96 // init task by loading profiler data. | |
97 void OnInitTaskGotGoogleUpdateData(); | |
98 | |
66 // Callbacks for various stages of final log info collection. Do not call | 99 // Callbacks for various stages of final log info collection. Do not call |
67 // these directly. | 100 // these directly. |
68 void OnMemoryDetailCollectionDone(); | 101 void OnMemoryDetailCollectionDone(); |
69 void OnHistogramSynchronizationDone(); | 102 void OnHistogramSynchronizationDone(); |
70 | 103 |
71 // Records metrics about the switches present on the command line. | 104 // Records metrics about the switches present on the command line. |
72 void RecordCommandLineMetrics(); | 105 void RecordCommandLineMetrics(); |
73 | 106 |
74 // Registers |this| as an observer for notifications which indicate that a | 107 // Registers |this| as an observer for notifications which indicate that a |
75 // user is performing work. This is useful to allow some features to sleep, | 108 // user is performing work. This is useful to allow some features to sleep, |
(...skipping 30 matching lines...) Expand all Loading... | |
106 | 139 |
107 // Saved callback received from CollectFinalMetrics(). | 140 // Saved callback received from CollectFinalMetrics(). |
108 base::Closure collect_final_metrics_done_callback_; | 141 base::Closure collect_final_metrics_done_callback_; |
109 | 142 |
110 // Indicates that collect final metrics step is running. | 143 // Indicates that collect final metrics step is running. |
111 bool waiting_for_collect_final_metrics_step_; | 144 bool waiting_for_collect_final_metrics_step_; |
112 | 145 |
113 // Number of async histogram fetch requests in progress. | 146 // Number of async histogram fetch requests in progress. |
114 int num_async_histogram_fetches_in_progress_; | 147 int num_async_histogram_fetches_in_progress_; |
115 | 148 |
149 // The ProfilerMetricsProvider instance that was registered with | |
150 // MetricsService. Outlives this instance. | |
Ilya Sherman
2014/06/06 19:04:18
Hmm, I think this is actually destroyed as part of
blundell
2014/06/08 09:15:55
Done.
| |
151 ProfilerMetricsProvider* profiler_metrics_provider_; | |
152 | |
153 #if defined(ENABLE_PLUGINS) | |
154 // The PluginMetricsProvider instance that was registered with | |
155 // MetricsService. Outlives this instance. | |
156 PluginMetricsProvider* plugin_metrics_provider_; | |
157 #endif | |
158 | |
159 #if defined(OS_WIN) | |
160 // The GoogleUpdateMetricsProviderWin instance that was registered with | |
161 // MetricsService. Outlives this instance. | |
162 GoogleUpdateMetricsProviderWin* google_update_metrics_provider_; | |
163 #endif | |
164 | |
165 // Callback that is called when initial metrics gathering is complete. | |
166 base::Closure finished_gathering_initial_metrics_callback_; | |
167 | |
116 base::WeakPtrFactory<ChromeMetricsServiceClient> weak_ptr_factory_; | 168 base::WeakPtrFactory<ChromeMetricsServiceClient> weak_ptr_factory_; |
117 | 169 |
118 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClient); | 170 DISALLOW_COPY_AND_ASSIGN(ChromeMetricsServiceClient); |
119 }; | 171 }; |
120 | 172 |
121 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ | 173 #endif // CHROME_BROWSER_METRICS_CHROME_METRICS_SERVICE_CLIENT_H_ |
OLD | NEW |