| 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 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "chrome/browser/metrics/extension_metrics.h" | 15 #include "chrome/browser/metrics/extension_metrics.h" |
| 16 #include "chrome/common/variations/variations_util.h" | 16 #include "chrome/common/variations/variations_util.h" |
| 17 #include "chrome/installer/util/google_update_settings.h" | |
| 18 #include "components/metrics/metrics_log_base.h" | 17 #include "components/metrics/metrics_log_base.h" |
| 19 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
| 20 | 19 |
| 21 class HashedExtensionMetrics; | 20 class HashedExtensionMetrics; |
| 22 class PrefService; | 21 class PrefService; |
| 23 class PrefRegistrySimple; | |
| 24 | 22 |
| 25 #if defined(OS_CHROMEOS) | 23 #if defined(OS_CHROMEOS) |
| 26 class MetricsLogChromeOS; | 24 class MetricsLogChromeOS; |
| 27 #endif | 25 #endif |
| 28 | 26 |
| 29 namespace base { | 27 namespace base { |
| 30 class DictionaryValue; | 28 class DictionaryValue; |
| 31 } | 29 } |
| 32 | 30 |
| 33 namespace content { | 31 namespace content { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 55 // |client| is used to interact with the embedder. | 53 // |client| is used to interact with the embedder. |
| 56 // Note: |this| instance does not take ownership of the |client|, but rather | 54 // Note: |this| instance does not take ownership of the |client|, but rather |
| 57 // stores a weak pointer to it. The caller should ensure that the |client| is | 55 // stores a weak pointer to it. The caller should ensure that the |client| is |
| 58 // valid for the lifetime of this class. | 56 // valid for the lifetime of this class. |
| 59 MetricsLog(const std::string& client_id, | 57 MetricsLog(const std::string& client_id, |
| 60 int session_id, | 58 int session_id, |
| 61 LogType log_type, | 59 LogType log_type, |
| 62 metrics::MetricsServiceClient* client); | 60 metrics::MetricsServiceClient* client); |
| 63 virtual ~MetricsLog(); | 61 virtual ~MetricsLog(); |
| 64 | 62 |
| 65 static void RegisterPrefs(PrefRegistrySimple* registry); | |
| 66 | |
| 67 // Records the current operating environment, including metrics provided by | 63 // Records the current operating environment, including metrics provided by |
| 68 // the specified set of |metrics_providers|. Takes the list of installed | 64 // the specified set of |metrics_providers|. Takes the list of installed |
| 69 // plugins, Google Update statistics, and synthetic trial IDs as parameters | 65 // plugins, Google Update statistics, and synthetic trial IDs as parameters |
| 70 // because those can't be obtained synchronously from the UI thread. | 66 // because those can't be obtained synchronously from the UI thread. |
| 71 // A synthetic trial is one that is set up dynamically by code in Chrome. For | 67 // A synthetic trial is one that is set up dynamically by code in Chrome. For |
| 72 // example, a pref may be mapped to a synthetic trial such that the group | 68 // example, a pref may be mapped to a synthetic trial such that the group |
| 73 // is determined by the pref value. | 69 // is determined by the pref value. |
| 74 void RecordEnvironment( | 70 void RecordEnvironment( |
| 75 const std::vector<metrics::MetricsProvider*>& metrics_providers, | 71 const std::vector<metrics::MetricsProvider*>& metrics_providers, |
| 76 const std::vector<content::WebPluginInfo>& plugin_list, | |
| 77 const std::vector<variations::ActiveGroupId>& synthetic_trials); | 72 const std::vector<variations::ActiveGroupId>& synthetic_trials); |
| 78 | 73 |
| 79 // Loads the environment proto that was saved by the last RecordEnvironment() | 74 // Loads the environment proto that was saved by the last RecordEnvironment() |
| 80 // call from prefs and clears the pref value. Returns true on success or false | 75 // call from prefs and clears the pref value. Returns true on success or false |
| 81 // if there was no saved environment in prefs or it could not be decoded. | 76 // if there was no saved environment in prefs or it could not be decoded. |
| 82 bool LoadSavedEnvironmentFromPrefs(); | 77 bool LoadSavedEnvironmentFromPrefs(); |
| 83 | 78 |
| 84 // Records the passed profiled data, which should be a snapshot of the | 79 // Records the passed profiled data, which should be a snapshot of the |
| 85 // browser's profiled performance during startup for a single process. | 80 // browser's profiled performance during startup for a single process. |
| 86 void RecordProfilerData( | 81 void RecordProfilerData( |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 FRIEND_TEST_ALL_PREFIXES(MetricsLogTest, ChromeOSStabilityData); | 133 FRIEND_TEST_ALL_PREFIXES(MetricsLogTest, ChromeOSStabilityData); |
| 139 | 134 |
| 140 // Returns true if the environment has already been filled in by a call to | 135 // Returns true if the environment has already been filled in by a call to |
| 141 // RecordEnvironment() or LoadSavedEnvironmentFromPrefs(). | 136 // RecordEnvironment() or LoadSavedEnvironmentFromPrefs(). |
| 142 bool HasEnvironment() const; | 137 bool HasEnvironment() const; |
| 143 | 138 |
| 144 // Returns true if the stability metrics have already been filled in by a | 139 // Returns true if the stability metrics have already been filled in by a |
| 145 // call to RecordStabilityMetrics(). | 140 // call to RecordStabilityMetrics(). |
| 146 bool HasStabilityMetrics() const; | 141 bool HasStabilityMetrics() const; |
| 147 | 142 |
| 148 // Within stability group, write plugin crash stats. | |
| 149 void WritePluginStabilityElements(PrefService* pref); | |
| 150 | |
| 151 // Within the stability group, write required attributes. | 143 // Within the stability group, write required attributes. |
| 152 void WriteRequiredStabilityAttributes(PrefService* pref); | 144 void WriteRequiredStabilityAttributes(PrefService* pref); |
| 153 | 145 |
| 154 // Within the stability group, write attributes that need to be updated asap | 146 // Within the stability group, write attributes that need to be updated asap |
| 155 // and can't be delayed until the user decides to restart chromium. | 147 // and can't be delayed until the user decides to restart chromium. |
| 156 // Delaying these stats would bias metrics away from happy long lived | 148 // Delaying these stats would bias metrics away from happy long lived |
| 157 // chromium processes (ones that don't crash, and keep on running). | 149 // chromium processes (ones that don't crash, and keep on running). |
| 158 void WriteRealtimeStabilityAttributes(PrefService* pref, | 150 void WriteRealtimeStabilityAttributes(PrefService* pref, |
| 159 base::TimeDelta incremental_uptime, | 151 base::TimeDelta incremental_uptime, |
| 160 base::TimeDelta uptime); | 152 base::TimeDelta uptime); |
| 161 | 153 |
| 162 // Writes the list of installed plugins. | |
| 163 void WritePluginList(const std::vector<content::WebPluginInfo>& plugin_list); | |
| 164 | |
| 165 // Used to interact with the embedder. Weak pointer; must outlive |this| | 154 // Used to interact with the embedder. Weak pointer; must outlive |this| |
| 166 // instance. | 155 // instance. |
| 167 metrics::MetricsServiceClient* const client_; | 156 metrics::MetricsServiceClient* const client_; |
| 168 | 157 |
| 169 // The time when the current log was created. | 158 // The time when the current log was created. |
| 170 const base::TimeTicks creation_time_; | 159 const base::TimeTicks creation_time_; |
| 171 | 160 |
| 172 // For including information on which extensions are installed in reports. | 161 // For including information on which extensions are installed in reports. |
| 173 HashedExtensionMetrics extension_metrics_; | 162 HashedExtensionMetrics extension_metrics_; |
| 174 | 163 |
| 175 DISALLOW_COPY_AND_ASSIGN(MetricsLog); | 164 DISALLOW_COPY_AND_ASSIGN(MetricsLog); |
| 176 }; | 165 }; |
| 177 | 166 |
| 178 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_H_ | 167 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_H_ |
| OLD | NEW |