Remove ExtensionPermission2* histograms.
[chromium-blink-merge.git] / tools / metrics / histograms / update_use_counter_feature_enum.py
blobedfdf99fed6a4d0917ffe8b6b964885bd89c0dcd
1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 """Scans the Chromium source of UseCounter, formats the Feature enum for
7 histograms.xml and merges it. This script can also generate a python code
8 snippet to put in uma.py of Chromium Dashboard. Make sure that you review the
9 output for correctness.
10 """
12 import optparse
13 import os
14 import sys
16 from update_histogram_enum import ReadHistogramValues
17 from update_histogram_enum import UpdateHistogramEnum
20 def PrintEnumForDashboard(enum_dict):
21 """Prints enum_items formatted for use in uma.py of Chromium dashboard."""
22 for key in sorted(enum_dict.iterkeys()):
23 print ' %d: \'%s\',' % (key, enum_dict[key])
26 if __name__ == '__main__':
27 parser = optparse.OptionParser()
28 parser.add_option('--for-dashboard', action='store_true', dest='dashboard',
29 default=False,
30 help='Print enum definition formatted for use in uma.py of '
31 'Chromium dashboard developed at '
32 'https://github.com/GoogleChrome/chromium-dashboard')
33 options, args = parser.parse_args()
35 source_path = 'third_party/WebKit/Source/core/frame/UseCounter.h'
37 START_MARKER = '^enum Feature {'
38 END_MARKER = '^NumberOfFeatures'
40 if options.dashboard:
41 enum_dict = ReadHistogramValues(source_path, START_MARKER, END_MARKER)
42 PrintEnumForDashboard(enum_dict)
43 else:
44 UpdateHistogramEnum(
45 histogram_enum_name='FeatureObserver',
46 source_enum_path=source_path,
47 start_marker=START_MARKER,
48 end_marker=END_MARKER)