Files.app: Use core-icon for the dropdown button of combobutton.
[chromium-blink-merge.git] / ppapi / tools / pepper_hash_for_uma.cc
blob7c006a89b79a094cb07eb1d99ef1d5ce4178c2cd
1 // Copyright (c) 2014 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 // This is a utility executable used for generating hashes for pepper
6 // interfaces for inclusion in tools/metrics/histograms/histograms.xml. Every
7 // interface-version pair must have a corresponding entry in the enum there.
8 //
9 // The hashing logic here must match the hashing logic at
10 // ppapi/proxy/interface_list.cc.
12 // This utility can be used to generate a sorted list of hashes for all current
13 // PPB* interfaces by running a script to generate the interface names, e.g.
14 // $ grep -r "PPB_" ppapi/c | grep -o "\".*;[0-9]*\.[0-9]*\"" | tr '\n' ' '
15 // and then invoking pepper_hash_for_uma on the list. The sorted output hashes
16 // can be compared to tools/metrics/histograms/histograms.xml to determine if
17 // any interfaces have been left out.
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
23 #include <algorithm>
24 #include <vector>
26 #include "base/hash.h"
27 #include "base/macros.h"
29 int main(int argc, char **argv) {
30 if (argc < 2) {
31 fprintf(stderr, "Usage: %s <interface1> <interface2> <...>\n", argv[0]);
32 fprintf(stderr, "\n");
33 fprintf(stderr, "Prints hashes for interface names.\n");
34 fprintf(stderr, "Example: %s \"PPB_Var;1.1\" \"PPB_FileIO;1.2\"\n",
35 argv[0]);
36 return 1;
38 std::vector<std::pair<uint32, char*>> hashes;
39 for (int i = 1; i < argc; i++) {
40 uint32 data = base::Hash(argv[i], strlen(argv[i]));
42 // Strip off the signed bit because UMA doesn't support negative values,
43 // but takes a signed int as input.
44 int hash = static_cast<int>(data & 0x7fffffff);
45 hashes.push_back(std::make_pair(hash, argv[i]));
47 std::sort(hashes.begin(), hashes.end());
48 for (const auto& hash : hashes) {
49 printf("<int value=\"%d\" label=\"%s\"/>\n", hash.first, hash.second);
52 return 0;