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

Unified Diff: content/browser/bluetooth/bluetooth_metrics.cc

Issue 1885073003: bluetooth: Create bluetooth_metrics_hash tool. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try with type fix in base/hash.h Created 4 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « BUILD.gn ('k') | content/browser/bluetooth/tools/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/bluetooth/bluetooth_metrics.cc
diff --git a/content/browser/bluetooth/bluetooth_metrics.cc b/content/browser/bluetooth/bluetooth_metrics.cc
index 32f7c73dfa7015e6fda33fb643be6be3c95b19bc..b354a026c10e83df154d4dbfc10aba64c3dad418 100644
--- a/content/browser/bluetooth/bluetooth_metrics.cc
+++ b/content/browser/bluetooth/bluetooth_metrics.cc
@@ -17,12 +17,20 @@
using device::BluetoothUUID;
namespace {
-// TODO(ortuno): Remove once we have a macro to histogram strings.
-// http://crbug.com/520284
-int HashUUID(const std::string& uuid) {
- uint32_t data = base::SuperFastHash(uuid.data(), uuid.size());
- // Strip off the signed bit because UMA doesn't support negative values,
+// Generates a hash from a canonical UUID string suitable for
+// UMA_HISTOGRAM_SPARSE_SLOWLY (positive int).
+//
+// Hash values can be produced manually using tool: bluetooth_metrics_hash.
+int HashUUID(const std::string& canonical_uuid) {
+ DCHECK(canonical_uuid == BluetoothUUID(canonical_uuid).canonical_value());
+
+ // TODO(520284): Other than verifying that uuid is canonical, this logic
+ // should be migrated to a dedicated histogram macro for hashed strings.
+ uint32_t data =
+ base::SuperFastHash(canonical_uuid.data(), canonical_uuid.size());
+
+ // Strip off the sign bit because UMA doesn't support negative values,
// but takes a signed int as input.
return static_cast<int>(data & 0x7fffffff);
}
« no previous file with comments | « BUILD.gn ('k') | content/browser/bluetooth/tools/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698