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.
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.
9 // The hashing logic here must match the hashing logic at
10 // ppapi/proxy/interface_list.cc.
16 #include "base/hash.h"
17 #include "base/macros.h"
19 int main(int argc
, char **argv
) {
21 fprintf(stderr
, "Usage: %s <interface1> <interface2> <...>\n", argv
[0]);
22 fprintf(stderr
, "\n");
23 fprintf(stderr
, "Prints hashes for interface names.\n");
24 fprintf(stderr
, "Example: %s \"PPB_Var;1.1\" \"PPB_FileIO;1.2\"\n",
28 for (int i
= 1; i
< argc
; i
++) {
29 uint32 data
= base::Hash(argv
[i
], strlen(argv
[i
]));
31 // Strip off the signed bit because UMA doesn't support negative values,
32 // but takes a signed int as input.
33 int hash
= static_cast<int>(data
& 0x7fffffff);
34 printf("<int value=\"%d\" label=\"%s\"/>\n", hash
, argv
[i
]);