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