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 |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
| 13 #include <memory> |
13 #include <string> | 14 #include <string> |
14 #include <vector> | 15 #include <vector> |
15 | 16 |
16 #include "base/macros.h" | 17 #include "base/macros.h" |
17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
18 #include "components/metrics/metrics_service_client.h" | 19 #include "components/metrics/metrics_service_client.h" |
19 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" | 20 #include "components/metrics/proto/chrome_user_metrics_extension.pb.h" |
20 | 21 |
21 class PrefRegistrySimple; | 22 class PrefRegistrySimple; |
22 class PrefService; | 23 class PrefService; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 | 89 |
89 // TODO(rkaplow): I think this can be a little refactored as it currently | 90 // TODO(rkaplow): I think this can be a little refactored as it currently |
90 // records a pretty arbitrary set of things. | 91 // records a pretty arbitrary set of things. |
91 // Records the current operating environment, including metrics provided by | 92 // Records the current operating environment, including metrics provided by |
92 // the specified set of |metrics_providers|. Takes the list of synthetic | 93 // the specified set of |metrics_providers|. Takes the list of synthetic |
93 // trial IDs as a parameter. A synthetic trial is one that is set up | 94 // trial IDs as a parameter. A synthetic trial is one that is set up |
94 // dynamically by code in Chrome. For example, a pref may be mapped to a | 95 // dynamically by code in Chrome. For example, a pref may be mapped to a |
95 // synthetic trial such that the group is determined by the pref value. The | 96 // synthetic trial such that the group is determined by the pref value. The |
96 // current environment is returned serialized as a string. | 97 // current environment is returned serialized as a string. |
97 std::string RecordEnvironment( | 98 std::string RecordEnvironment( |
98 const std::vector<MetricsProvider*>& metrics_providers, | 99 const std::vector<std::unique_ptr<MetricsProvider>>& metrics_providers, |
99 const std::vector<variations::ActiveGroupId>& synthetic_trials, | 100 const std::vector<variations::ActiveGroupId>& synthetic_trials, |
100 int64_t install_date, | 101 int64_t install_date, |
101 int64_t metrics_reporting_enabled_date); | 102 int64_t metrics_reporting_enabled_date); |
102 | 103 |
103 // Loads the environment proto that was saved by the last RecordEnvironment() | 104 // Loads the environment proto that was saved by the last RecordEnvironment() |
104 // call from prefs. On success, returns true and |app_version| contains the | 105 // call from prefs. On success, returns true and |app_version| contains the |
105 // recovered version. Otherwise (if there was no saved environment in prefs | 106 // recovered version. Otherwise (if there was no saved environment in prefs |
106 // or it could not be decoded), returns false and |app_version| is empty. | 107 // or it could not be decoded), returns false and |app_version| is empty. |
107 bool LoadSavedEnvironmentFromPrefs(std::string* app_version); | 108 bool LoadSavedEnvironmentFromPrefs(std::string* app_version); |
108 | 109 |
109 // Writes application stability metrics, including stability metrics provided | 110 // Writes application stability metrics, including stability metrics provided |
110 // by the specified set of |metrics_providers|. The system profile portion of | 111 // by the specified set of |metrics_providers|. The system profile portion of |
111 // the log must have already been filled in by a call to RecordEnvironment() | 112 // the log must have already been filled in by a call to RecordEnvironment() |
112 // or LoadSavedEnvironmentFromPrefs(). | 113 // or LoadSavedEnvironmentFromPrefs(). |
113 // NOTE: Has the side-effect of clearing the stability prefs.. | 114 // NOTE: Has the side-effect of clearing the stability prefs.. |
114 // | 115 // |
115 // If this log is of type INITIAL_STABILITY_LOG, records additional info such | 116 // If this log is of type INITIAL_STABILITY_LOG, records additional info such |
116 // as number of incomplete shutdowns as well as extra breakpad and debugger | 117 // as number of incomplete shutdowns as well as extra breakpad and debugger |
117 // stats. | 118 // stats. |
118 void RecordStabilityMetrics( | 119 void RecordStabilityMetrics( |
119 const std::vector<MetricsProvider*>& metrics_providers, | 120 const std::vector<std::unique_ptr<MetricsProvider>>& metrics_providers, |
120 base::TimeDelta incremental_uptime, | 121 base::TimeDelta incremental_uptime, |
121 base::TimeDelta uptime); | 122 base::TimeDelta uptime); |
122 | 123 |
123 // Records general metrics based on the specified |metrics_providers|. | 124 // Records general metrics based on the specified |metrics_providers|. |
124 void RecordGeneralMetrics( | 125 void RecordGeneralMetrics( |
125 const std::vector<MetricsProvider*>& metrics_providers); | 126 const std::vector<std::unique_ptr<MetricsProvider>>& metrics_providers); |
126 | 127 |
127 // Stop writing to this record and generate the encoded representation. | 128 // Stop writing to this record and generate the encoded representation. |
128 // None of the Record* methods can be called after this is called. | 129 // None of the Record* methods can be called after this is called. |
129 void CloseLog(); | 130 void CloseLog(); |
130 | 131 |
131 // Fills |encoded_log| with the serialized protobuf representation of the | 132 // Fills |encoded_log| with the serialized protobuf representation of the |
132 // record. Must only be called after CloseLog() has been called. | 133 // record. Must only be called after CloseLog() has been called. |
133 void GetEncodedLog(std::string* encoded_log); | 134 void GetEncodedLog(std::string* encoded_log); |
134 | 135 |
135 const base::TimeTicks& creation_time() const { | 136 const base::TimeTicks& creation_time() const { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 const base::TimeTicks creation_time_; | 202 const base::TimeTicks creation_time_; |
202 | 203 |
203 PrefService* local_state_; | 204 PrefService* local_state_; |
204 | 205 |
205 DISALLOW_COPY_AND_ASSIGN(MetricsLog); | 206 DISALLOW_COPY_AND_ASSIGN(MetricsLog); |
206 }; | 207 }; |
207 | 208 |
208 } // namespace metrics | 209 } // namespace metrics |
209 | 210 |
210 #endif // COMPONENTS_METRICS_METRICS_LOG_H_ | 211 #endif // COMPONENTS_METRICS_METRICS_LOG_H_ |
OLD | NEW |