| 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_COMMON_METRICS_METRICS_LOG_BASE_H_ | 8 #ifndef CHROME_COMMON_METRICS_METRICS_LOG_BASE_H_ |
| 9 #define CHROME_COMMON_METRICS_METRICS_LOG_BASE_H_ | 9 #define CHROME_COMMON_METRICS_METRICS_LOG_BASE_H_ |
| 10 #pragma once | 10 #pragma once |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 | 97 |
| 98 void set_hardware_class(const std::string& hardware_class) { | 98 void set_hardware_class(const std::string& hardware_class) { |
| 99 hardware_class_ = hardware_class; | 99 hardware_class_ = hardware_class; |
| 100 } | 100 } |
| 101 | 101 |
| 102 protected: | 102 protected: |
| 103 class XmlWrapper; | 103 class XmlWrapper; |
| 104 | 104 |
| 105 // Returns a string containing the current time. | 105 // Returns a string containing the current time. |
| 106 // Virtual so that it can be overridden for testing. | 106 // Virtual so that it can be overridden for testing. |
| 107 // TODO(isherman): Remove this method once the XML pipeline is old news. |
| 107 virtual std::string GetCurrentTimeString(); | 108 virtual std::string GetCurrentTimeString(); |
| 108 // Helper class that invokes StartElement from constructor, and EndElement | 109 // Helper class that invokes StartElement from constructor, and EndElement |
| 109 // from destructor. | 110 // from destructor. |
| 110 // | 111 // |
| 111 // Use the macro OPEN_ELEMENT_FOR_SCOPE to help avoid usage problems. | 112 // Use the macro OPEN_ELEMENT_FOR_SCOPE to help avoid usage problems. |
| 112 class ScopedElement { | 113 class ScopedElement { |
| 113 public: | 114 public: |
| 114 ScopedElement(MetricsLogBase* log, const std::string& name) : log_(log) { | 115 ScopedElement(MetricsLogBase* log, const std::string& name) : log_(log) { |
| 115 DCHECK(log); | 116 DCHECK(log); |
| 116 log->StartElement(name.c_str()); | 117 log->StartElement(name.c_str()); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 140 // Convenience versions of xmlWriter functions | 141 // Convenience versions of xmlWriter functions |
| 141 void StartElement(const char* name); | 142 void StartElement(const char* name); |
| 142 void EndElement(); | 143 void EndElement(); |
| 143 void WriteAttribute(const std::string& name, const std::string& value); | 144 void WriteAttribute(const std::string& name, const std::string& value); |
| 144 void WriteIntAttribute(const std::string& name, int value); | 145 void WriteIntAttribute(const std::string& name, int value); |
| 145 void WriteInt64Attribute(const std::string& name, int64 value); | 146 void WriteInt64Attribute(const std::string& name, int64 value); |
| 146 | 147 |
| 147 // Write the attributes that are common to every metrics event type. | 148 // Write the attributes that are common to every metrics event type. |
| 148 void WriteCommonEventAttributes(); | 149 void WriteCommonEventAttributes(); |
| 149 | 150 |
| 151 bool locked() const { return locked_; } |
| 152 |
| 153 metrics::ChromeUserMetricsExtension* uma_proto() { return &uma_proto_; } |
| 154 const metrics::ChromeUserMetricsExtension* uma_proto() const { |
| 155 return &uma_proto_; |
| 156 } |
| 157 |
| 158 // TODO(isherman): Remove this once the XML pipeline is outta here. |
| 159 int num_events_; // the number of events recorded in this log |
| 160 |
| 161 private: |
| 150 base::Time start_time_; | 162 base::Time start_time_; |
| 151 base::Time end_time_; | 163 base::Time end_time_; |
| 152 | 164 |
| 153 std::string client_id_; | 165 std::string client_id_; |
| 154 std::string session_id_; | 166 std::string session_id_; |
| 155 std::string hardware_class_; | 167 std::string hardware_class_; |
| 156 | 168 |
| 157 // locked_ is true when record has been packed up for sending, and should | 169 // locked_ is true when record has been packed up for sending, and should |
| 158 // no longer be written to. It is only used for sanity checking and is | 170 // no longer be written to. It is only used for sanity checking and is |
| 159 // not a real lock. | 171 // not a real lock. |
| 160 bool locked_; | 172 bool locked_; |
| 161 | 173 |
| 162 // Isolated to limit the dependency on the XML library for our consumers. | 174 // Isolated to limit the dependency on the XML library for our consumers. |
| 163 XmlWrapper* xml_wrapper_; | 175 XmlWrapper* xml_wrapper_; |
| 164 | 176 |
| 165 int num_events_; // the number of events recorded in this log | |
| 166 | |
| 167 // Stores the protocol buffer representation for this log. | 177 // Stores the protocol buffer representation for this log. |
| 168 metrics::ChromeUserMetricsExtension uma_proto_; | 178 metrics::ChromeUserMetricsExtension uma_proto_; |
| 169 | 179 |
| 170 private: | |
| 171 DISALLOW_COPY_AND_ASSIGN(MetricsLogBase); | 180 DISALLOW_COPY_AND_ASSIGN(MetricsLogBase); |
| 172 }; | 181 }; |
| 173 | 182 |
| 174 #endif // CHROME_COMMON_METRICS_METRICS_LOG_BASE_H_ | 183 #endif // CHROME_COMMON_METRICS_METRICS_LOG_BASE_H_ |
| OLD | NEW |