| 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 set of user experience metrics data recorded by | 5 // This file defines a set of user experience metrics data recorded by |
| 6 // the MetricsService. This is the unit of data that is sent to the server. | 6 // the MetricsService. This is the unit of data that is sent to the server. |
| 7 | 7 |
| 8 #ifndef CHROME_BROWSER_METRICS_METRICS_LOG_H_ | 8 #ifndef CHROME_BROWSER_METRICS_METRICS_LOG_H_ |
| 9 #define CHROME_BROWSER_METRICS_METRICS_LOG_H_ | 9 #define CHROME_BROWSER_METRICS_METRICS_LOG_H_ |
| 10 | 10 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 class MetricsNetworkObserver; | 24 class MetricsNetworkObserver; |
| 25 struct OmniboxLog; | 25 struct OmniboxLog; |
| 26 class PrefService; | 26 class PrefService; |
| 27 class PrefRegistrySimple; | 27 class PrefRegistrySimple; |
| 28 | 28 |
| 29 namespace base { | 29 namespace base { |
| 30 class DictionaryValue; | 30 class DictionaryValue; |
| 31 } | 31 } |
| 32 | 32 |
| 33 namespace content { |
| 34 struct WebPluginInfo; |
| 35 } |
| 36 |
| 33 namespace device { | 37 namespace device { |
| 34 class BluetoothAdapter; | 38 class BluetoothAdapter; |
| 35 } | 39 } |
| 36 | 40 |
| 37 namespace tracked_objects { | 41 namespace tracked_objects { |
| 38 struct ProcessDataSnapshot; | 42 struct ProcessDataSnapshot; |
| 39 } | 43 } |
| 40 | 44 |
| 41 namespace chrome_variations { | 45 namespace chrome_variations { |
| 42 struct ActiveGroupId; | 46 struct ActiveGroupId; |
| 43 } | 47 } |
| 44 | 48 |
| 45 namespace webkit { | |
| 46 struct WebPluginInfo; | |
| 47 } | |
| 48 | |
| 49 // This is a small helper struct to pass Google Update metrics in a single | 49 // This is a small helper struct to pass Google Update metrics in a single |
| 50 // reference argument to MetricsLog::RecordEnvironment(). | 50 // reference argument to MetricsLog::RecordEnvironment(). |
| 51 struct GoogleUpdateMetrics { | 51 struct GoogleUpdateMetrics { |
| 52 GoogleUpdateMetrics(); | 52 GoogleUpdateMetrics(); |
| 53 ~GoogleUpdateMetrics(); | 53 ~GoogleUpdateMetrics(); |
| 54 | 54 |
| 55 // Defines whether this is a user-level or system-level install. | 55 // Defines whether this is a user-level or system-level install. |
| 56 bool is_system_install; | 56 bool is_system_install; |
| 57 // The time at which Google Update last started an automatic update check. | 57 // The time at which Google Update last started an automatic update check. |
| 58 base::Time last_started_au; | 58 base::Time last_started_au; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 87 static void set_version_extension(const std::string& extension); | 87 static void set_version_extension(const std::string& extension); |
| 88 static const std::string& version_extension(); | 88 static const std::string& version_extension(); |
| 89 | 89 |
| 90 // Records the current operating environment. Takes the list of installed | 90 // Records the current operating environment. Takes the list of installed |
| 91 // plugins and Google Update statistics as parameters because those can't be | 91 // plugins and Google Update statistics as parameters because those can't be |
| 92 // obtained synchronously from the UI thread. | 92 // obtained synchronously from the UI thread. |
| 93 // profile_metrics, if non-null, gives a dictionary of all profile metrics | 93 // profile_metrics, if non-null, gives a dictionary of all profile metrics |
| 94 // that are to be recorded. Each value in profile_metrics should be a | 94 // that are to be recorded. Each value in profile_metrics should be a |
| 95 // dictionary giving the metrics for the profile. | 95 // dictionary giving the metrics for the profile. |
| 96 void RecordEnvironment( | 96 void RecordEnvironment( |
| 97 const std::vector<webkit::WebPluginInfo>& plugin_list, | 97 const std::vector<content::WebPluginInfo>& plugin_list, |
| 98 const GoogleUpdateMetrics& google_update_metrics); | 98 const GoogleUpdateMetrics& google_update_metrics); |
| 99 | 99 |
| 100 // Records the current operating environment. Takes the list of installed | 100 // Records the current operating environment. Takes the list of installed |
| 101 // plugins and Google Update statistics as parameters because those can't be | 101 // plugins and Google Update statistics as parameters because those can't be |
| 102 // obtained synchronously from the UI thread. This is exposed as a separate | 102 // obtained synchronously from the UI thread. This is exposed as a separate |
| 103 // method from the |RecordEnvironment()| method above because we record the | 103 // method from the |RecordEnvironment()| method above because we record the |
| 104 // environment with *each* protobuf upload, but only with the initial XML | 104 // environment with *each* protobuf upload, but only with the initial XML |
| 105 // upload. | 105 // upload. |
| 106 void RecordEnvironmentProto( | 106 void RecordEnvironmentProto( |
| 107 const std::vector<webkit::WebPluginInfo>& plugin_list, | 107 const std::vector<content::WebPluginInfo>& plugin_list, |
| 108 const GoogleUpdateMetrics& google_update_metrics); | 108 const GoogleUpdateMetrics& google_update_metrics); |
| 109 | 109 |
| 110 // Records the input text, available choices, and selected entry when the | 110 // Records the input text, available choices, and selected entry when the |
| 111 // user uses the Omnibox to open a URL. | 111 // user uses the Omnibox to open a URL. |
| 112 void RecordOmniboxOpenedURL(const OmniboxLog& log); | 112 void RecordOmniboxOpenedURL(const OmniboxLog& log); |
| 113 | 113 |
| 114 // Records the passed profiled data, which should be a snapshot of the | 114 // Records the passed profiled data, which should be a snapshot of the |
| 115 // browser's profiled performance during startup for a single process. | 115 // browser's profiled performance during startup for a single process. |
| 116 void RecordProfilerData( | 116 void RecordProfilerData( |
| 117 const tracked_objects::ProcessDataSnapshot& process_data, | 117 const tracked_objects::ProcessDataSnapshot& process_data, |
| 118 int process_type); | 118 int process_type); |
| 119 | 119 |
| 120 // Record recent delta for critical stability metrics. We can't wait for a | 120 // Record recent delta for critical stability metrics. We can't wait for a |
| 121 // restart to gather these, as that delay biases our observation away from | 121 // restart to gather these, as that delay biases our observation away from |
| 122 // users that run happily for a looooong time. We send increments with each | 122 // users that run happily for a looooong time. We send increments with each |
| 123 // uma log upload, just as we send histogram data. Takes the list of | 123 // uma log upload, just as we send histogram data. Takes the list of |
| 124 // installed plugins as a parameter because that can't be obtained | 124 // installed plugins as a parameter because that can't be obtained |
| 125 // synchronously from the UI thread. | 125 // synchronously from the UI thread. |
| 126 void RecordIncrementalStabilityElements( | 126 void RecordIncrementalStabilityElements( |
| 127 const std::vector<webkit::WebPluginInfo>& plugin_list); | 127 const std::vector<content::WebPluginInfo>& plugin_list); |
| 128 | 128 |
| 129 protected: | 129 protected: |
| 130 // Exposed for the sake of mocking in test code. | 130 // Exposed for the sake of mocking in test code. |
| 131 | 131 |
| 132 // Returns the PrefService from which to log metrics data. | 132 // Returns the PrefService from which to log metrics data. |
| 133 virtual PrefService* GetPrefService(); | 133 virtual PrefService* GetPrefService(); |
| 134 | 134 |
| 135 // Returns the screen size for the primary monitor. | 135 // Returns the screen size for the primary monitor. |
| 136 virtual gfx::Size GetScreenSize() const; | 136 virtual gfx::Size GetScreenSize() const; |
| 137 | 137 |
| 138 // Returns the device scale factor for the primary monitor. | 138 // Returns the device scale factor for the primary monitor. |
| 139 virtual float GetScreenDeviceScaleFactor() const; | 139 virtual float GetScreenDeviceScaleFactor() const; |
| 140 | 140 |
| 141 // Returns the number of monitors the user is using. | 141 // Returns the number of monitors the user is using. |
| 142 virtual int GetScreenCount() const; | 142 virtual int GetScreenCount() const; |
| 143 | 143 |
| 144 // Fills |field_trial_ids| with the list of initialized field trials name and | 144 // Fills |field_trial_ids| with the list of initialized field trials name and |
| 145 // group ids. | 145 // group ids. |
| 146 virtual void GetFieldTrialIds( | 146 virtual void GetFieldTrialIds( |
| 147 std::vector<chrome_variations::ActiveGroupId>* field_trial_ids) const; | 147 std::vector<chrome_variations::ActiveGroupId>* field_trial_ids) const; |
| 148 | 148 |
| 149 private: | 149 private: |
| 150 FRIEND_TEST_ALL_PREFIXES(MetricsLogTest, ChromeOSStabilityData); | 150 FRIEND_TEST_ALL_PREFIXES(MetricsLogTest, ChromeOSStabilityData); |
| 151 | 151 |
| 152 // Writes application stability metrics (as part of the profile log). | 152 // Writes application stability metrics (as part of the profile log). |
| 153 // NOTE: Has the side-effect of clearing those counts. | 153 // NOTE: Has the side-effect of clearing those counts. |
| 154 void WriteStabilityElement( | 154 void WriteStabilityElement( |
| 155 const std::vector<webkit::WebPluginInfo>& plugin_list, | 155 const std::vector<content::WebPluginInfo>& plugin_list, |
| 156 PrefService* pref); | 156 PrefService* pref); |
| 157 | 157 |
| 158 // Within stability group, write plugin crash stats. | 158 // Within stability group, write plugin crash stats. |
| 159 void WritePluginStabilityElements( | 159 void WritePluginStabilityElements( |
| 160 const std::vector<webkit::WebPluginInfo>& plugin_list, | 160 const std::vector<content::WebPluginInfo>& plugin_list, |
| 161 PrefService* pref); | 161 PrefService* pref); |
| 162 | 162 |
| 163 // Within the stability group, write required attributes. | 163 // Within the stability group, write required attributes. |
| 164 void WriteRequiredStabilityAttributes(PrefService* pref); | 164 void WriteRequiredStabilityAttributes(PrefService* pref); |
| 165 | 165 |
| 166 // Within the stability group, write attributes that need to be updated asap | 166 // Within the stability group, write attributes that need to be updated asap |
| 167 // and can't be delayed until the user decides to restart chromium. | 167 // and can't be delayed until the user decides to restart chromium. |
| 168 // Delaying these stats would bias metrics away from happy long lived | 168 // Delaying these stats would bias metrics away from happy long lived |
| 169 // chromium processes (ones that don't crash, and keep on running). | 169 // chromium processes (ones that don't crash, and keep on running). |
| 170 void WriteRealtimeStabilityAttributes(PrefService* pref); | 170 void WriteRealtimeStabilityAttributes(PrefService* pref); |
| 171 | 171 |
| 172 // Writes the list of installed plugins. | 172 // Writes the list of installed plugins. |
| 173 void WritePluginList(const std::vector<webkit::WebPluginInfo>& plugin_list); | 173 void WritePluginList(const std::vector<content::WebPluginInfo>& plugin_list); |
| 174 | 174 |
| 175 // Writes info about the Google Update install that is managing this client. | 175 // Writes info about the Google Update install that is managing this client. |
| 176 // This is a no-op if called on a non-Windows platform. | 176 // This is a no-op if called on a non-Windows platform. |
| 177 void WriteGoogleUpdateProto(const GoogleUpdateMetrics& google_update_metrics); | 177 void WriteGoogleUpdateProto(const GoogleUpdateMetrics& google_update_metrics); |
| 178 | 178 |
| 179 // Sets the Bluetooth Adapter instance used for the WriteBluetoothProto() | 179 // Sets the Bluetooth Adapter instance used for the WriteBluetoothProto() |
| 180 // call. | 180 // call. |
| 181 void SetBluetoothAdapter(scoped_refptr<device::BluetoothAdapter> adapter); | 181 void SetBluetoothAdapter(scoped_refptr<device::BluetoothAdapter> adapter); |
| 182 | 182 |
| 183 // Writes info about paired Bluetooth devices on this system. | 183 // Writes info about paired Bluetooth devices on this system. |
| 184 // This is a no-op if called on a non-Chrome OS platform. | 184 // This is a no-op if called on a non-Chrome OS platform. |
| 185 void WriteBluetoothProto(metrics::SystemProfileProto::Hardware* hardware); | 185 void WriteBluetoothProto(metrics::SystemProfileProto::Hardware* hardware); |
| 186 | 186 |
| 187 // Observes network state to provide values for SystemProfile::Network. | 187 // Observes network state to provide values for SystemProfile::Network. |
| 188 MetricsNetworkObserver network_observer_; | 188 MetricsNetworkObserver network_observer_; |
| 189 | 189 |
| 190 #if defined(OS_CHROMEOS) | 190 #if defined(OS_CHROMEOS) |
| 191 metrics::PerfProvider perf_provider_; | 191 metrics::PerfProvider perf_provider_; |
| 192 #endif | 192 #endif |
| 193 | 193 |
| 194 // Bluetooth Adapter instance for collecting information about paired devices. | 194 // Bluetooth Adapter instance for collecting information about paired devices. |
| 195 scoped_refptr<device::BluetoothAdapter> adapter_; | 195 scoped_refptr<device::BluetoothAdapter> adapter_; |
| 196 | 196 |
| 197 DISALLOW_COPY_AND_ASSIGN(MetricsLog); | 197 DISALLOW_COPY_AND_ASSIGN(MetricsLog); |
| 198 }; | 198 }; |
| 199 | 199 |
| 200 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_H_ | 200 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_H_ |
| OLD | NEW |