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 #include "chrome/common/metrics/metrics_log_base.h" | 5 #include "chrome/common/metrics/metrics_log_base.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/md5.h" | 9 #include "base/md5.h" |
10 #include "base/perftimer.h" | 10 #include "base/perftimer.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 xmlBufferPtr buffer() const { return buffer_; } | 116 xmlBufferPtr buffer() const { return buffer_; } |
117 | 117 |
118 private: | 118 private: |
119 xmlDocPtr doc_; | 119 xmlDocPtr doc_; |
120 xmlBufferPtr buffer_; | 120 xmlBufferPtr buffer_; |
121 xmlTextWriterPtr writer_; | 121 xmlTextWriterPtr writer_; |
122 }; | 122 }; |
123 | 123 |
124 MetricsLogBase::MetricsLogBase(const std::string& client_id, int session_id, | 124 MetricsLogBase::MetricsLogBase(const std::string& client_id, int session_id, |
125 const std::string& version_string) | 125 const std::string& version_string) |
126 : start_time_(Time::Now()), | 126 : num_events_(0), |
| 127 start_time_(Time::Now()), |
127 client_id_(client_id), | 128 client_id_(client_id), |
128 session_id_(base::IntToString(session_id)), | 129 session_id_(base::IntToString(session_id)), |
129 locked_(false), | 130 locked_(false), |
130 xml_wrapper_(new XmlWrapper), | 131 xml_wrapper_(new XmlWrapper) { |
131 num_events_(0) { | |
132 int64_t build_time = GetBuildTime(); | 132 int64_t build_time = GetBuildTime(); |
133 | 133 |
134 // Write the XML version. | 134 // Write the XML version. |
135 StartElement("log"); | 135 StartElement("log"); |
136 WriteAttribute("clientid", client_id_); | 136 WriteAttribute("clientid", client_id_); |
137 WriteInt64Attribute("buildtime", build_time); | 137 WriteInt64Attribute("buildtime", build_time); |
138 WriteAttribute("appversion", version_string); | 138 WriteAttribute("appversion", version_string); |
139 | 139 |
140 // Write the protobuf version. | 140 // Write the protobuf version. |
141 if (IsTestingID(client_id_)) { | 141 if (IsTestingID(client_id_)) { |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 for (size_t i = 0; i < histogram.bucket_count(); ++i) { | 464 for (size_t i = 0; i < histogram.bucket_count(); ++i) { |
465 if (snapshot.counts(i)) { | 465 if (snapshot.counts(i)) { |
466 HistogramEventProto::Bucket* bucket = histogram_proto->add_bucket(); | 466 HistogramEventProto::Bucket* bucket = histogram_proto->add_bucket(); |
467 bucket->set_min(histogram.ranges(i)); | 467 bucket->set_min(histogram.ranges(i)); |
468 bucket->set_max(histogram.ranges(i + 1)); | 468 bucket->set_max(histogram.ranges(i + 1)); |
469 bucket->set_bucket_index(i); | 469 bucket->set_bucket_index(i); |
470 bucket->set_count(snapshot.counts(i)); | 470 bucket->set_count(snapshot.counts(i)); |
471 } | 471 } |
472 } | 472 } |
473 } | 473 } |
OLD | NEW |