| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_helpers.h" | 5 #include "chrome/common/metrics_helpers.h" |
| 6 | 6 |
| 7 #if defined(USE_SYSTEM_LIBBZ2) | 7 #if defined(USE_SYSTEM_LIBBZ2) |
| 8 #include <bzlib.h> | 8 #include <bzlib.h> |
| 9 #else | 9 #else |
| 10 #include "third_party/bzip2/bzlib.h" | 10 #include "third_party/bzip2/bzlib.h" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 unsigned char* reverse = reinterpret_cast<unsigned char *>(&reverse_uint64); | 188 unsigned char* reverse = reinterpret_cast<unsigned char *>(&reverse_uint64); |
| 189 DCHECK(arraysize(digest.a) >= sizeof(reverse_uint64)); | 189 DCHECK(arraysize(digest.a) >= sizeof(reverse_uint64)); |
| 190 for (size_t i = 0; i < sizeof(reverse_uint64); ++i) | 190 for (size_t i = 0; i < sizeof(reverse_uint64); ++i) |
| 191 reverse[i] = digest.a[sizeof(reverse_uint64) - i - 1]; | 191 reverse[i] = digest.a[sizeof(reverse_uint64) - i - 1]; |
| 192 // The following log is VERY helpful when folks add some named histogram into | 192 // The following log is VERY helpful when folks add some named histogram into |
| 193 // the code, but forgot to update the descriptive list of histograms. When | 193 // the code, but forgot to update the descriptive list of histograms. When |
| 194 // that happens, all we get to see (server side) is a hash of the histogram | 194 // that happens, all we get to see (server side) is a hash of the histogram |
| 195 // name. We can then use this logging to find out what histogram name was | 195 // name. We can then use this logging to find out what histogram name was |
| 196 // being hashed to a given MD5 value by just running the version of Chromium | 196 // being hashed to a given MD5 value by just running the version of Chromium |
| 197 // in question with --enable-logging. | 197 // in question with --enable-logging. |
| 198 LOG(INFO) << "Metrics: Hash numeric [" << value << "]=[" | 198 VLOG(1) << "Metrics: Hash numeric [" << value |
| 199 << reverse_uint64 << "]"; | 199 << "]=[" << reverse_uint64 << "]"; |
| 200 return std::string(reinterpret_cast<char*>(digest.a), arraysize(digest.a)); | 200 return std::string(reinterpret_cast<char*>(digest.a), arraysize(digest.a)); |
| 201 } | 201 } |
| 202 | 202 |
| 203 std::string MetricsLogBase::CreateBase64Hash(const std::string& string) { | 203 std::string MetricsLogBase::CreateBase64Hash(const std::string& string) { |
| 204 std::string encoded_digest; | 204 std::string encoded_digest; |
| 205 if (base::Base64Encode(CreateHash(string), &encoded_digest)) { | 205 if (base::Base64Encode(CreateHash(string), &encoded_digest)) { |
| 206 DLOG(INFO) << "Metrics: Hash [" << encoded_digest << "]=[" << string << "]"; | 206 DVLOG(1) << "Metrics: Hash [" << encoded_digest << "]=[" << string << "]"; |
| 207 return encoded_digest; | 207 return encoded_digest; |
| 208 } | 208 } |
| 209 return std::string(); | 209 return std::string(); |
| 210 } | 210 } |
| 211 | 211 |
| 212 void MetricsLogBase::RecordUserAction(const char* key) { | 212 void MetricsLogBase::RecordUserAction(const char* key) { |
| 213 DCHECK(!locked_); | 213 DCHECK(!locked_); |
| 214 | 214 |
| 215 std::string command_hash = CreateBase64Hash(key); | 215 std::string command_hash = CreateBase64Hash(key); |
| 216 if (command_hash.empty()) { | 216 if (command_hash.empty()) { |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 } | 509 } |
| 510 } | 510 } |
| 511 | 511 |
| 512 void MetricsServiceBase::DiscardPendingLog() { | 512 void MetricsServiceBase::DiscardPendingLog() { |
| 513 if (pending_log_) { // Shutdown might have deleted it! | 513 if (pending_log_) { // Shutdown might have deleted it! |
| 514 delete pending_log_; | 514 delete pending_log_; |
| 515 pending_log_ = NULL; | 515 pending_log_ = NULL; |
| 516 } | 516 } |
| 517 compressed_log_.clear(); | 517 compressed_log_.clear(); |
| 518 } | 518 } |
| OLD | NEW |