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 13 matching lines...) Expand all Loading... |
24 namespace base { | 24 namespace base { |
25 class HistogramSamples; | 25 class HistogramSamples; |
26 } | 26 } |
27 | 27 |
28 namespace variations { | 28 namespace variations { |
29 struct ActiveGroupId; | 29 struct ActiveGroupId; |
30 } | 30 } |
31 | 31 |
32 namespace metrics { | 32 namespace metrics { |
33 | 33 |
| 34 namespace internal { |
| 35 extern const int kOmniboxEventLimit; |
| 36 extern const int kUserActionEventLimit; |
| 37 } |
| 38 |
34 class MetricsProvider; | 39 class MetricsProvider; |
35 class MetricsServiceClient; | 40 class MetricsServiceClient; |
36 | 41 |
37 class MetricsLog { | 42 class MetricsLog { |
38 public: | 43 public: |
39 enum LogType { | 44 enum LogType { |
40 INITIAL_STABILITY_LOG, // The initial log containing stability stats. | 45 INITIAL_STABILITY_LOG, // The initial log containing stability stats. |
41 ONGOING_LOG, // Subsequent logs in a session. | 46 ONGOING_LOG, // Subsequent logs in a session. |
42 }; | 47 }; |
43 | 48 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 base::TimeDelta uptime); | 126 base::TimeDelta uptime); |
122 | 127 |
123 // Records general metrics based on the specified |metrics_providers|. | 128 // Records general metrics based on the specified |metrics_providers|. |
124 void RecordGeneralMetrics( | 129 void RecordGeneralMetrics( |
125 const std::vector<std::unique_ptr<MetricsProvider>>& metrics_providers); | 130 const std::vector<std::unique_ptr<MetricsProvider>>& metrics_providers); |
126 | 131 |
127 // Stop writing to this record and generate the encoded representation. | 132 // Stop writing to this record and generate the encoded representation. |
128 // None of the Record* methods can be called after this is called. | 133 // None of the Record* methods can be called after this is called. |
129 void CloseLog(); | 134 void CloseLog(); |
130 | 135 |
| 136 // Truncate some of the fields within the log that we want to restrict in |
| 137 // size due to bandwidth concerns. |
| 138 void TruncateEvents(); |
| 139 |
131 // Fills |encoded_log| with the serialized protobuf representation of the | 140 // Fills |encoded_log| with the serialized protobuf representation of the |
132 // record. Must only be called after CloseLog() has been called. | 141 // record. Must only be called after CloseLog() has been called. |
133 void GetEncodedLog(std::string* encoded_log); | 142 void GetEncodedLog(std::string* encoded_log); |
134 | 143 |
135 const base::TimeTicks& creation_time() const { | 144 const base::TimeTicks& creation_time() const { |
136 return creation_time_; | 145 return creation_time_; |
137 } | 146 } |
138 | 147 |
139 int num_events() const { | |
140 return uma_proto_.omnibox_event_size() + | |
141 uma_proto_.user_action_event_size(); | |
142 } | |
143 | |
144 LogType log_type() const { return log_type_; } | 148 LogType log_type() const { return log_type_; } |
145 | 149 |
146 protected: | 150 protected: |
147 // Exposed for the sake of mocking/accessing in test code. | 151 // Exposed for the sake of mocking/accessing in test code. |
148 | 152 |
149 // Fills |field_trial_ids| with the list of initialized field trials name and | 153 // Fills |field_trial_ids| with the list of initialized field trials name and |
150 // group ids. | 154 // group ids. |
151 virtual void GetFieldTrialIds( | 155 virtual void GetFieldTrialIds( |
152 std::vector<variations::ActiveGroupId>* field_trial_ids) const; | 156 std::vector<variations::ActiveGroupId>* field_trial_ids) const; |
153 | 157 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 const base::TimeTicks creation_time_; | 201 const base::TimeTicks creation_time_; |
198 | 202 |
199 PrefService* local_state_; | 203 PrefService* local_state_; |
200 | 204 |
201 DISALLOW_COPY_AND_ASSIGN(MetricsLog); | 205 DISALLOW_COPY_AND_ASSIGN(MetricsLog); |
202 }; | 206 }; |
203 | 207 |
204 } // namespace metrics | 208 } // namespace metrics |
205 | 209 |
206 #endif // COMPONENTS_METRICS_METRICS_LOG_H_ | 210 #endif // COMPONENTS_METRICS_METRICS_LOG_H_ |
OLD | NEW |