OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_COMMON_METRICS_HELPERS_H_ | 8 #ifndef CHROME_COMMON_METRICS_HELPERS_H_ |
9 #define CHROME_COMMON_METRICS_HELPERS_H_ | 9 #define CHROME_COMMON_METRICS_HELPERS_H_ |
10 #pragma once | 10 #pragma once |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 | 87 |
88 // Return a base64-encoded MD5 hash of the given string. | 88 // Return a base64-encoded MD5 hash of the given string. |
89 static std::string CreateBase64Hash(const std::string& string); | 89 static std::string CreateBase64Hash(const std::string& string); |
90 | 90 |
91 // Get the GMT buildtime for the current binary, expressed in seconds since | 91 // Get the GMT buildtime for the current binary, expressed in seconds since |
92 // Januray 1, 1970 GMT. | 92 // Januray 1, 1970 GMT. |
93 // The value is used to identify when a new build is run, so that previous | 93 // The value is used to identify when a new build is run, so that previous |
94 // reliability stats, from other builds, can be abandoned. | 94 // reliability stats, from other builds, can be abandoned. |
95 static int64 GetBuildTime(); | 95 static int64 GetBuildTime(); |
96 | 96 |
97 // Use |extension| in all uploaded appversions in addition to the standard | |
98 // version string. | |
99 static void set_version_extension(const std::string& extension) { | |
100 version_extension_ = extension; | |
101 } | |
102 | |
103 virtual MetricsLog* AsMetricsLog(); | 97 virtual MetricsLog* AsMetricsLog(); |
104 | 98 |
105 protected: | 99 protected: |
106 class XmlWrapper; | 100 class XmlWrapper; |
107 | 101 |
108 // Returns a string containing the current time. | 102 // Returns a string containing the current time. |
109 // Virtual so that it can be overridden for testing. | 103 // Virtual so that it can be overridden for testing. |
110 virtual std::string GetCurrentTimeString(); | 104 virtual std::string GetCurrentTimeString(); |
111 // Helper class that invokes StartElement from constructor, and EndElement | 105 // Helper class that invokes StartElement from constructor, and EndElement |
112 // from destructor. | 106 // from destructor. |
(...skipping 30 matching lines...) Expand all Loading... |
143 // Convenience versions of xmlWriter functions | 137 // Convenience versions of xmlWriter functions |
144 void StartElement(const char* name); | 138 void StartElement(const char* name); |
145 void EndElement(); | 139 void EndElement(); |
146 void WriteAttribute(const std::string& name, const std::string& value); | 140 void WriteAttribute(const std::string& name, const std::string& value); |
147 void WriteIntAttribute(const std::string& name, int value); | 141 void WriteIntAttribute(const std::string& name, int value); |
148 void WriteInt64Attribute(const std::string& name, int64 value); | 142 void WriteInt64Attribute(const std::string& name, int64 value); |
149 | 143 |
150 // Write the attributes that are common to every metrics event type. | 144 // Write the attributes that are common to every metrics event type. |
151 void WriteCommonEventAttributes(); | 145 void WriteCommonEventAttributes(); |
152 | 146 |
153 // An extension that is appended to the appversion in each log. | |
154 static std::string version_extension_; | |
155 | |
156 base::Time start_time_; | 147 base::Time start_time_; |
157 base::Time end_time_; | 148 base::Time end_time_; |
158 | 149 |
159 std::string client_id_; | 150 std::string client_id_; |
160 std::string session_id_; | 151 std::string session_id_; |
161 std::string hardware_class_; | 152 std::string hardware_class_; |
162 | 153 |
163 // locked_ is true when record has been packed up for sending, and should | 154 // locked_ is true when record has been packed up for sending, and should |
164 // no longer be written to. It is only used for sanity checking and is | 155 // no longer be written to. It is only used for sanity checking and is |
165 // not a real lock. | 156 // not a real lock. |
166 bool locked_; | 157 bool locked_; |
167 | 158 |
168 // Isolated to limit the dependency on the XML library for our consumers. | 159 // Isolated to limit the dependency on the XML library for our consumers. |
169 XmlWrapper* xml_wrapper_; | 160 XmlWrapper* xml_wrapper_; |
170 | 161 |
171 int num_events_; // the number of events recorded in this log | 162 int num_events_; // the number of events recorded in this log |
172 | 163 |
| 164 private: |
173 DISALLOW_COPY_AND_ASSIGN(MetricsLogBase); | 165 DISALLOW_COPY_AND_ASSIGN(MetricsLogBase); |
174 }; | 166 }; |
175 | 167 |
176 // HistogramSender handles the logistics of gathering up available histograms | 168 // HistogramSender handles the logistics of gathering up available histograms |
177 // for transmission (such as from renderer to browser, or from browser to UMA | 169 // for transmission (such as from renderer to browser, or from browser to UMA |
178 // upload). It has several pure virtual functions that are replaced in | 170 // upload). It has several pure virtual functions that are replaced in |
179 // derived classes to allow the exact lower level transmission mechanism, | 171 // derived classes to allow the exact lower level transmission mechanism, |
180 // or error report mechanism, to be replaced. Since histograms can sit in | 172 // or error report mechanism, to be replaced. Since histograms can sit in |
181 // memory for an extended period of time, and are vulnerable to memory | 173 // memory for an extended period of time, and are vulnerable to memory |
182 // corruption, this class also validates as much rendundancy as it can before | 174 // corruption, this class also validates as much rendundancy as it can before |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 const base::Histogram& histogram, | 238 const base::Histogram& histogram, |
247 const base::Histogram::SampleSet& snapshot); | 239 const base::Histogram::SampleSet& snapshot); |
248 virtual void InconsistencyDetected(int problem); | 240 virtual void InconsistencyDetected(int problem); |
249 virtual void UniqueInconsistencyDetected(int problem); | 241 virtual void UniqueInconsistencyDetected(int problem); |
250 virtual void SnapshotProblemResolved(int amount); | 242 virtual void SnapshotProblemResolved(int amount); |
251 | 243 |
252 DISALLOW_COPY_AND_ASSIGN(MetricsServiceBase); | 244 DISALLOW_COPY_AND_ASSIGN(MetricsServiceBase); |
253 }; | 245 }; |
254 | 246 |
255 #endif // CHROME_COMMON_METRICS_HELPERS_H_ | 247 #endif // CHROME_COMMON_METRICS_HELPERS_H_ |
OLD | NEW |