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

Side by Side Diff: content/browser/bluetooth/tools/bluetooth_metrics_hash.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, 7 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 unified diff | Download patch
« no previous file with comments | « content/browser/bluetooth/tools/BUILD.gn ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include <iostream>
6
7 #include "base/hash.h"
8 #include "base/logging.h"
9 #include "device/bluetooth/bluetooth_uuid.h"
10
11 int main(int argc, char** argv) {
12 if (argc <= 1) {
13 std::cout << "Generates hash values given UUIDs using the same method\n"
14 << "as in bluetooth_metrics.cc.\n"
15 << "\n"
16 << "Output is formatted for including into histograms.xml.\n"
17 << "Note that tools/metrics/histograms/pretty_print.py will\n"
18 << "sort enum entries for you.\n"
19 << "\n"
20 << "Usage: " << argv[0] << " <uuid> [uuid2 ...]\n"
21 << " The UUIDs may be short UUIDs, and will be made\n"
22 << " canonical before being hashed.\n"
23 << "\n"
24 << "Example: " << argv[0] << " FEFF FEFE\n"
25 << " <int value=\"62669585\" "
26 "label=\"0000feff-0000-1000-8000-00805f9b34fb\"/>\n"
27 << " <int value=\"643543662\" "
28 "label=\"0000fefe-0000-1000-8000-00805f9b34fb\"/>\n";
29 return 1;
30 }
31
32 for (int i = 1; i < argc; i++) {
33 std::string input_string(argv[i]);
34 device::BluetoothUUID uuid(input_string);
35 std::string uuid_canonical_string = uuid.canonical_value();
36 uint32_t hash = base::SuperFastHash(uuid_canonical_string.data(),
37 uuid_canonical_string.size());
38
39 // Strip off the sign bit because UMA doesn't support negative values,
40 // but takes a signed int as input.
41 hash &= 0x7fffffff;
42
43 std::cout << " <int value=\"" << hash << "\" label=\""
44 << uuid_canonical_string << "\"/>\n";
45 }
46 return 0;
47 }
OLDNEW
« no previous file with comments | « content/browser/bluetooth/tools/BUILD.gn ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698