OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/browser/metrics/metrics_log.h" | 5 #include "chrome/browser/metrics/metrics_log.h" |
6 | 6 |
| 7 #include "base/base64.h" |
7 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
8 #include "base/file_util.h" | 9 #include "base/file_util.h" |
9 #include "base/file_version_info.h" | 10 #include "base/file_version_info.h" |
10 #include "base/md5.h" | 11 #include "base/md5.h" |
11 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
12 #include "base/string_util.h" | 13 #include "base/string_util.h" |
13 #include "base/sys_info.h" | 14 #include "base/sys_info.h" |
14 #include "chrome/browser/autocomplete/autocomplete.h" | 15 #include "chrome/browser/autocomplete/autocomplete.h" |
15 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
16 #include "chrome/common/logging_chrome.h" | 17 #include "chrome/common/logging_chrome.h" |
17 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
18 #include "chrome/common/pref_service.h" | 19 #include "chrome/common/pref_service.h" |
19 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
20 #include "net/base/base64.h" | |
21 | 21 |
22 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) | 22 #define OPEN_ELEMENT_FOR_SCOPE(name) ScopedElement scoped_element(this, name) |
23 | 23 |
24 using base::Time; | 24 using base::Time; |
25 using base::TimeDelta; | 25 using base::TimeDelta; |
26 | 26 |
27 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx | 27 // http://blogs.msdn.com/oldnewthing/archive/2004/10/25/247180.aspx |
28 #if defined(OS_WIN) | 28 #if defined(OS_WIN) |
29 extern "C" IMAGE_DOS_HEADER __ImageBase; | 29 extern "C" IMAGE_DOS_HEADER __ImageBase; |
30 #endif | 30 #endif |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 // name. We can then use this logging to find out what histogram name was | 122 // name. We can then use this logging to find out what histogram name was |
123 // being hashed to a given MD5 value by just running the version of Chromium | 123 // being hashed to a given MD5 value by just running the version of Chromium |
124 // in question with --enable-logging. | 124 // in question with --enable-logging. |
125 LOG(INFO) << "Metrics: Hash numeric [" << value << "]=[" | 125 LOG(INFO) << "Metrics: Hash numeric [" << value << "]=[" |
126 << reverse_uint64 << "]"; | 126 << reverse_uint64 << "]"; |
127 return std::string(reinterpret_cast<char*>(digest.a), arraysize(digest.a)); | 127 return std::string(reinterpret_cast<char*>(digest.a), arraysize(digest.a)); |
128 } | 128 } |
129 | 129 |
130 std::string MetricsLog::CreateBase64Hash(const std::string& string) { | 130 std::string MetricsLog::CreateBase64Hash(const std::string& string) { |
131 std::string encoded_digest; | 131 std::string encoded_digest; |
132 if (net::Base64Encode(CreateHash(string), &encoded_digest)) { | 132 if (base::Base64Encode(CreateHash(string), &encoded_digest)) { |
133 DLOG(INFO) << "Metrics: Hash [" << encoded_digest << "]=[" << string << "]"; | 133 DLOG(INFO) << "Metrics: Hash [" << encoded_digest << "]=[" << string << "]"; |
134 return encoded_digest; | 134 return encoded_digest; |
135 } | 135 } |
136 return std::string(); | 136 return std::string(); |
137 } | 137 } |
138 | 138 |
139 void MetricsLog::RecordUserAction(const char* key) { | 139 void MetricsLog::RecordUserAction(const char* key) { |
140 DCHECK(!locked_); | 140 DCHECK(!locked_); |
141 | 141 |
142 std::string command_hash = CreateBase64Hash(key); | 142 std::string command_hash = CreateBase64Hash(key); |
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 | 684 |
685 for (size_t i = 0; i < histogram.bucket_count(); i++) { | 685 for (size_t i = 0; i < histogram.bucket_count(); i++) { |
686 if (snapshot.counts(i)) { | 686 if (snapshot.counts(i)) { |
687 OPEN_ELEMENT_FOR_SCOPE("histogrambucket"); | 687 OPEN_ELEMENT_FOR_SCOPE("histogrambucket"); |
688 WriteIntAttribute("min", histogram.ranges(i)); | 688 WriteIntAttribute("min", histogram.ranges(i)); |
689 WriteIntAttribute("max", histogram.ranges(i + 1)); | 689 WriteIntAttribute("max", histogram.ranges(i + 1)); |
690 WriteIntAttribute("count", snapshot.counts(i)); | 690 WriteIntAttribute("count", snapshot.counts(i)); |
691 } | 691 } |
692 } | 692 } |
693 } | 693 } |
OLD | NEW |