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

Side by Side Diff: components/metrics/metrics_log.cc

Issue 1476633003: Move HashMetricName to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed unittest Created 5 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/metrics/metrics_log.h" 5 #include "components/metrics/metrics_log.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/base64.h" 11 #include "base/base64.h"
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/build_time.h" 13 #include "base/build_time.h"
14 #include "base/cpu.h" 14 #include "base/cpu.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/metrics/histogram_samples.h" 17 #include "base/metrics/histogram_samples.h"
18 #include "base/metrics/metrics_hashes.h"
18 #include "base/prefs/pref_registry_simple.h" 19 #include "base/prefs/pref_registry_simple.h"
19 #include "base/prefs/pref_service.h" 20 #include "base/prefs/pref_service.h"
20 #include "base/sha1.h" 21 #include "base/sha1.h"
21 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/string_util.h" 23 #include "base/strings/string_util.h"
23 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
24 #include "base/sys_info.h" 25 #include "base/sys_info.h"
25 #include "base/time/time.h" 26 #include "base/time/time.h"
26 #include "components/metrics/histogram_encoder.h" 27 #include "components/metrics/histogram_encoder.h"
27 #include "components/metrics/metrics_hashes.h"
28 #include "components/metrics/metrics_pref_names.h" 28 #include "components/metrics/metrics_pref_names.h"
29 #include "components/metrics/metrics_provider.h" 29 #include "components/metrics/metrics_provider.h"
30 #include "components/metrics/metrics_service_client.h" 30 #include "components/metrics/metrics_service_client.h"
31 #include "components/metrics/proto/histogram_event.pb.h" 31 #include "components/metrics/proto/histogram_event.pb.h"
32 #include "components/metrics/proto/system_profile.pb.h" 32 #include "components/metrics/proto/system_profile.pb.h"
33 #include "components/metrics/proto/user_action_event.pb.h" 33 #include "components/metrics/proto/user_action_event.pb.h"
34 #include "components/variations/active_field_trials.h" 34 #include "components/variations/active_field_trials.h"
35 35
36 #if defined(OS_ANDROID) 36 #if defined(OS_ANDROID)
37 #include "base/android/build_info.h" 37 #include "base/android/build_info.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 registry->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0); 127 registry->RegisterIntegerPref(prefs::kStabilityDebuggerPresent, 0);
128 registry->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0); 128 registry->RegisterIntegerPref(prefs::kStabilityDebuggerNotPresent, 0);
129 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfile, 129 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfile,
130 std::string()); 130 std::string());
131 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfileHash, 131 registry->RegisterStringPref(prefs::kStabilitySavedSystemProfileHash,
132 std::string()); 132 std::string());
133 } 133 }
134 134
135 // static 135 // static
136 uint64 MetricsLog::Hash(const std::string& value) { 136 uint64 MetricsLog::Hash(const std::string& value) {
137 uint64 hash = HashMetricName(value); 137 uint64 hash = base::HashMetricName(value);
138 138
139 // The following log is VERY helpful when folks add some named histogram into 139 // The following log is VERY helpful when folks add some named histogram into
140 // the code, but forgot to update the descriptive list of histograms. When 140 // the code, but forgot to update the descriptive list of histograms. When
141 // that happens, all we get to see (server side) is a hash of the histogram 141 // that happens, all we get to see (server side) is a hash of the histogram
142 // name. We can then use this logging to find out what histogram name was 142 // name. We can then use this logging to find out what histogram name was
143 // being hashed to a given MD5 value by just running the version of Chromium 143 // being hashed to a given MD5 value by just running the version of Chromium
144 // in question with --enable-logging. 144 // in question with --enable-logging.
145 DVLOG(1) << "Metrics: Hash numeric [" << value << "]=[" << hash << "]"; 145 DVLOG(1) << "Metrics: Hash numeric [" << value << "]=[" << hash << "]";
146 146
147 return hash; 147 return hash;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 DCHECK(!closed_); 392 DCHECK(!closed_);
393 closed_ = true; 393 closed_ = true;
394 } 394 }
395 395
396 void MetricsLog::GetEncodedLog(std::string* encoded_log) { 396 void MetricsLog::GetEncodedLog(std::string* encoded_log) {
397 DCHECK(closed_); 397 DCHECK(closed_);
398 uma_proto_.SerializeToString(encoded_log); 398 uma_proto_.SerializeToString(encoded_log);
399 } 399 }
400 400
401 } // namespace metrics 401 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/metrics_hashes_unittest.cc ('k') | components/metrics/metrics_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698