| 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 27 matching lines...) Expand all Loading... |
| 38 namespace variations { | 38 namespace variations { |
| 39 struct ActiveGroupId; | 39 struct ActiveGroupId; |
| 40 } | 40 } |
| 41 | 41 |
| 42 class MetricsLog : public metrics::MetricsLogBase { | 42 class MetricsLog : public metrics::MetricsLogBase { |
| 43 public: | 43 public: |
| 44 // Creates a new metrics log of the specified type. | 44 // Creates a new metrics log of the specified type. |
| 45 // |client_id| is the identifier for this profile on this installation | 45 // |client_id| is the identifier for this profile on this installation |
| 46 // |session_id| is an integer that's incremented on each application launch | 46 // |session_id| is an integer that's incremented on each application launch |
| 47 // |client| is used to interact with the embedder. | 47 // |client| is used to interact with the embedder. |
| 48 // |local_state| is the PrefService that this instance should use. |
| 48 // Note: |this| instance does not take ownership of the |client|, but rather | 49 // Note: |this| instance does not take ownership of the |client|, but rather |
| 49 // stores a weak pointer to it. The caller should ensure that the |client| is | 50 // stores a weak pointer to it. The caller should ensure that the |client| is |
| 50 // valid for the lifetime of this class. | 51 // valid for the lifetime of this class. |
| 51 MetricsLog(const std::string& client_id, | 52 MetricsLog(const std::string& client_id, |
| 52 int session_id, | 53 int session_id, |
| 53 LogType log_type, | 54 LogType log_type, |
| 54 metrics::MetricsServiceClient* client); | 55 metrics::MetricsServiceClient* client, |
| 56 PrefService* local_state); |
| 55 virtual ~MetricsLog(); | 57 virtual ~MetricsLog(); |
| 56 | 58 |
| 57 // Records the current operating environment, including metrics provided by | 59 // Records the current operating environment, including metrics provided by |
| 58 // the specified set of |metrics_providers|. Takes the list of installed | 60 // the specified set of |metrics_providers|. Takes the list of installed |
| 59 // plugins, Google Update statistics, and synthetic trial IDs as parameters | 61 // plugins, Google Update statistics, and synthetic trial IDs as parameters |
| 60 // because those can't be obtained synchronously from the UI thread. | 62 // because those can't be obtained synchronously from the UI thread. |
| 61 // A synthetic trial is one that is set up dynamically by code in Chrome. For | 63 // A synthetic trial is one that is set up dynamically by code in Chrome. For |
| 62 // example, a pref may be mapped to a synthetic trial such that the group | 64 // example, a pref may be mapped to a synthetic trial such that the group |
| 63 // is determined by the pref value. | 65 // is determined by the pref value. |
| 64 void RecordEnvironment( | 66 void RecordEnvironment( |
| (...skipping 29 matching lines...) Expand all Loading... |
| 94 void RecordGeneralMetrics( | 96 void RecordGeneralMetrics( |
| 95 const std::vector<metrics::MetricsProvider*>& metrics_providers); | 97 const std::vector<metrics::MetricsProvider*>& metrics_providers); |
| 96 | 98 |
| 97 const base::TimeTicks& creation_time() const { | 99 const base::TimeTicks& creation_time() const { |
| 98 return creation_time_; | 100 return creation_time_; |
| 99 } | 101 } |
| 100 | 102 |
| 101 protected: | 103 protected: |
| 102 // Exposed for the sake of mocking in test code. | 104 // Exposed for the sake of mocking in test code. |
| 103 | 105 |
| 104 // Returns the PrefService from which to log metrics data. | |
| 105 virtual PrefService* GetPrefService(); | |
| 106 | |
| 107 // Fills |field_trial_ids| with the list of initialized field trials name and | 106 // Fills |field_trial_ids| with the list of initialized field trials name and |
| 108 // group ids. | 107 // group ids. |
| 109 virtual void GetFieldTrialIds( | 108 virtual void GetFieldTrialIds( |
| 110 std::vector<variations::ActiveGroupId>* field_trial_ids) const; | 109 std::vector<variations::ActiveGroupId>* field_trial_ids) const; |
| 111 | 110 |
| 112 private: | 111 private: |
| 113 FRIEND_TEST_ALL_PREFIXES(MetricsLogTest, ChromeOSStabilityData); | 112 FRIEND_TEST_ALL_PREFIXES(MetricsLogTest, ChromeOSStabilityData); |
| 114 | 113 |
| 115 // Returns true if the environment has already been filled in by a call to | 114 // Returns true if the environment has already been filled in by a call to |
| 116 // RecordEnvironment() or LoadSavedEnvironmentFromPrefs(). | 115 // RecordEnvironment() or LoadSavedEnvironmentFromPrefs(). |
| (...skipping 14 matching lines...) Expand all Loading... |
| 131 base::TimeDelta incremental_uptime, | 130 base::TimeDelta incremental_uptime, |
| 132 base::TimeDelta uptime); | 131 base::TimeDelta uptime); |
| 133 | 132 |
| 134 // Used to interact with the embedder. Weak pointer; must outlive |this| | 133 // Used to interact with the embedder. Weak pointer; must outlive |this| |
| 135 // instance. | 134 // instance. |
| 136 metrics::MetricsServiceClient* const client_; | 135 metrics::MetricsServiceClient* const client_; |
| 137 | 136 |
| 138 // The time when the current log was created. | 137 // The time when the current log was created. |
| 139 const base::TimeTicks creation_time_; | 138 const base::TimeTicks creation_time_; |
| 140 | 139 |
| 140 PrefService* local_state_; |
| 141 |
| 141 DISALLOW_COPY_AND_ASSIGN(MetricsLog); | 142 DISALLOW_COPY_AND_ASSIGN(MetricsLog); |
| 142 }; | 143 }; |
| 143 | 144 |
| 144 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_H_ | 145 #endif // CHROME_BROWSER_METRICS_METRICS_LOG_H_ |
| OLD | NEW |