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 // 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 COMPONENTS_METRICS_METRICS_LOG_H_ | 8 #ifndef COMPONENTS_METRICS_METRICS_LOG_H_ |
9 #define COMPONENTS_METRICS_METRICS_LOG_H_ | 9 #define COMPONENTS_METRICS_METRICS_LOG_H_ |
10 | 10 |
(...skipping 26 matching lines...) Expand all Loading... |
37 } | 37 } |
38 | 38 |
39 class MetricsProvider; | 39 class MetricsProvider; |
40 class MetricsServiceClient; | 40 class MetricsServiceClient; |
41 | 41 |
42 class MetricsLog { | 42 class MetricsLog { |
43 public: | 43 public: |
44 enum LogType { | 44 enum LogType { |
45 INITIAL_STABILITY_LOG, // The initial log containing stability stats. | 45 INITIAL_STABILITY_LOG, // The initial log containing stability stats. |
46 ONGOING_LOG, // Subsequent logs in a session. | 46 ONGOING_LOG, // Subsequent logs in a session. |
| 47 INDEPENDENT_LOG, // An independent log from a previous session. |
47 }; | 48 }; |
48 | 49 |
49 // Creates a new metrics log of the specified type. | 50 // Creates a new metrics log of the specified type. |
50 // |client_id| is the identifier for this profile on this installation | 51 // |client_id| is the identifier for this profile on this installation |
51 // |session_id| is an integer that's incremented on each application launch | 52 // |session_id| is an integer that's incremented on each application launch |
52 // |client| is used to interact with the embedder. | 53 // |client| is used to interact with the embedder. |
53 // |local_state| is the PrefService that this instance should use. | 54 // |local_state| is the PrefService that this instance should use. |
54 // Note: |this| instance does not take ownership of the |client|, but rather | 55 // Note: |this| instance does not take ownership of the |client|, but rather |
55 // stores a weak pointer to it. The caller should ensure that the |client| is | 56 // stores a weak pointer to it. The caller should ensure that the |client| is |
56 // valid for the lifetime of this class. | 57 // valid for the lifetime of this class. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 // trial IDs as a parameter. A synthetic trial is one that is set up | 99 // trial IDs as a parameter. A synthetic trial is one that is set up |
99 // dynamically by code in Chrome. For example, a pref may be mapped to a | 100 // dynamically by code in Chrome. For example, a pref may be mapped to a |
100 // synthetic trial such that the group is determined by the pref value. The | 101 // synthetic trial such that the group is determined by the pref value. The |
101 // current environment is returned serialized as a string. | 102 // current environment is returned serialized as a string. |
102 std::string RecordEnvironment( | 103 std::string RecordEnvironment( |
103 const std::vector<std::unique_ptr<MetricsProvider>>& metrics_providers, | 104 const std::vector<std::unique_ptr<MetricsProvider>>& metrics_providers, |
104 const std::vector<variations::ActiveGroupId>& synthetic_trials, | 105 const std::vector<variations::ActiveGroupId>& synthetic_trials, |
105 int64_t install_date, | 106 int64_t install_date, |
106 int64_t metrics_reporting_enabled_date); | 107 int64_t metrics_reporting_enabled_date); |
107 | 108 |
| 109 // Loads a saved system profile and the associated metrics into the log. |
| 110 // Returns true on success. Keep calling it with fresh logs until it returns |
| 111 // false. |
| 112 bool LoadIndependentMetrics(MetricsProvider* metrics_provider); |
| 113 |
108 // Loads the environment proto that was saved by the last RecordEnvironment() | 114 // Loads the environment proto that was saved by the last RecordEnvironment() |
109 // call from prefs. On success, returns true and |app_version| contains the | 115 // call from prefs. On success, returns true and |app_version| contains the |
110 // recovered version. Otherwise (if there was no saved environment in prefs | 116 // recovered version. Otherwise (if there was no saved environment in prefs |
111 // or it could not be decoded), returns false and |app_version| is empty. | 117 // or it could not be decoded), returns false and |app_version| is empty. |
112 bool LoadSavedEnvironmentFromPrefs(std::string* app_version); | 118 bool LoadSavedEnvironmentFromPrefs(std::string* app_version); |
113 | 119 |
114 // Writes application stability metrics, including stability metrics provided | 120 // Writes application stability metrics, including stability metrics provided |
115 // by the specified set of |metrics_providers|. The system profile portion of | 121 // by the specified set of |metrics_providers|. The system profile portion of |
116 // the log must have already been filled in by a call to RecordEnvironment() | 122 // the log must have already been filled in by a call to RecordEnvironment() |
117 // or LoadSavedEnvironmentFromPrefs(). | 123 // or LoadSavedEnvironmentFromPrefs(). |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 const base::TimeTicks creation_time_; | 207 const base::TimeTicks creation_time_; |
202 | 208 |
203 PrefService* local_state_; | 209 PrefService* local_state_; |
204 | 210 |
205 DISALLOW_COPY_AND_ASSIGN(MetricsLog); | 211 DISALLOW_COPY_AND_ASSIGN(MetricsLog); |
206 }; | 212 }; |
207 | 213 |
208 } // namespace metrics | 214 } // namespace metrics |
209 | 215 |
210 #endif // COMPONENTS_METRICS_METRICS_LOG_H_ | 216 #endif // COMPONENTS_METRICS_METRICS_LOG_H_ |
OLD | NEW |