Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: chrome/common/metrics_helpers.cc

Issue 8368018: Convert chrome/common non-debug logs to debug logs. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/common/mac/objc_zombie_unittest.mm ('k') | chrome/common/metrics_log_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/common/metrics_helpers.h" 5 #include "chrome/common/metrics_helpers.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/file_util.h" 9 #include "base/file_util.h"
10 #include "base/md5.h" 10 #include "base/md5.h"
(...skipping 29 matching lines...) Expand all
40 40
41 } // namespace 41 } // namespace
42 42
43 class MetricsLogBase::XmlWrapper { 43 class MetricsLogBase::XmlWrapper {
44 public: 44 public:
45 XmlWrapper() 45 XmlWrapper()
46 : doc_(NULL), 46 : doc_(NULL),
47 buffer_(NULL), 47 buffer_(NULL),
48 writer_(NULL) { 48 writer_(NULL) {
49 buffer_ = xmlBufferCreate(); 49 buffer_ = xmlBufferCreate();
50 CHECK(buffer_); 50 DCHECK(buffer_);
51 51
52 #if defined(OS_CHROMEOS) 52 #if defined(OS_CHROMEOS)
53 writer_ = xmlNewTextWriterDoc(&doc_, /* compression */ 0); 53 writer_ = xmlNewTextWriterDoc(&doc_, /* compression */ 0);
54 #else 54 #else
55 writer_ = xmlNewTextWriterMemory(buffer_, /* compression */ 0); 55 writer_ = xmlNewTextWriterMemory(buffer_, /* compression */ 0);
56 #endif // OS_CHROMEOS 56 #endif // OS_CHROMEOS
57 DCHECK(writer_); 57 DCHECK(writer_);
58 58
59 int result = xmlTextWriterSetIndent(writer_, 2); 59 int result = xmlTextWriterSetIndent(writer_, 2);
60 DCHECK_EQ(0, result); 60 DCHECK_EQ(0, result);
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 unsigned char* reverse = reinterpret_cast<unsigned char *>(&reverse_uint64); 190 unsigned char* reverse = reinterpret_cast<unsigned char *>(&reverse_uint64);
191 DCHECK(arraysize(digest.a) >= sizeof(reverse_uint64)); 191 DCHECK(arraysize(digest.a) >= sizeof(reverse_uint64));
192 for (size_t i = 0; i < sizeof(reverse_uint64); ++i) 192 for (size_t i = 0; i < sizeof(reverse_uint64); ++i)
193 reverse[i] = digest.a[sizeof(reverse_uint64) - i - 1]; 193 reverse[i] = digest.a[sizeof(reverse_uint64) - i - 1];
194 // The following log is VERY helpful when folks add some named histogram into 194 // The following log is VERY helpful when folks add some named histogram into
195 // the code, but forgot to update the descriptive list of histograms. When 195 // the code, but forgot to update the descriptive list of histograms. When
196 // that happens, all we get to see (server side) is a hash of the histogram 196 // that happens, all we get to see (server side) is a hash of the histogram
197 // name. We can then use this logging to find out what histogram name was 197 // name. We can then use this logging to find out what histogram name was
198 // being hashed to a given MD5 value by just running the version of Chromium 198 // being hashed to a given MD5 value by just running the version of Chromium
199 // in question with --enable-logging. 199 // in question with --enable-logging.
200 VLOG(1) << "Metrics: Hash numeric [" << value 200 DVLOG(1) << "Metrics: Hash numeric [" << value
201 << "]=[" << reverse_uint64 << "]"; 201 << "]=[" << reverse_uint64 << "]";
202 return std::string(reinterpret_cast<char*>(digest.a), arraysize(digest.a)); 202 return std::string(reinterpret_cast<char*>(digest.a), arraysize(digest.a));
203 } 203 }
204 204
205 std::string MetricsLogBase::CreateBase64Hash(const std::string& string) { 205 std::string MetricsLogBase::CreateBase64Hash(const std::string& string) {
206 std::string encoded_digest; 206 std::string encoded_digest;
207 if (base::Base64Encode(CreateHash(string), &encoded_digest)) { 207 if (base::Base64Encode(CreateHash(string), &encoded_digest)) {
208 DVLOG(1) << "Metrics: Hash [" << encoded_digest << "]=[" << string << "]"; 208 DVLOG(1) << "Metrics: Hash [" << encoded_digest << "]=[" << string << "]";
209 return encoded_digest; 209 return encoded_digest;
210 } 210 }
211 return std::string(); 211 return std::string();
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 snapshot.Subtract(*already_logged); 528 snapshot.Subtract(*already_logged);
529 } 529 }
530 530
531 // Snapshot now contains only a delta to what we've already_logged. 531 // Snapshot now contains only a delta to what we've already_logged.
532 if (snapshot.redundant_count() > 0) { 532 if (snapshot.redundant_count() > 0) {
533 TransmitHistogramDelta(histogram, snapshot); 533 TransmitHistogramDelta(histogram, snapshot);
534 // Add new data into our running total. 534 // Add new data into our running total.
535 already_logged->Add(snapshot); 535 already_logged->Add(snapshot);
536 } 536 }
537 } 537 }
OLDNEW
« no previous file with comments | « chrome/common/mac/objc_zombie_unittest.mm ('k') | chrome/common/metrics_log_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698