OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Blink frame presubmit script | 5 """Blink frame presubmit script |
6 | 6 |
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
8 for more details about the presubmit API built into gcl. | 8 for more details about the presubmit API built into gcl. |
9 """ | 9 """ |
10 | 10 |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 source_path = '' | 67 source_path = '' |
68 for f in input_api.AffectedFiles(): | 68 for f in input_api.AffectedFiles(): |
69 if f.LocalPath().endswith('UseCounter.h'): | 69 if f.LocalPath().endswith('UseCounter.h'): |
70 source_path = f.LocalPath() | 70 source_path = f.LocalPath() |
71 break | 71 break |
72 else: | 72 else: |
73 return [] | 73 return [] |
74 | 74 |
75 start_marker = '^enum Feature : uint32_t {' | 75 start_marker = '^enum Feature : uint32_t {' |
76 end_marker = '^kNumberOfFeatures' | 76 end_marker = '^kNumberOfFeatures' |
77 should_update_histogram, duplicated_values = update_histogram_enum.Histogram
NeedsUpdate( | 77 presubmit_error = update_histogram_enum.CheckPresubmitErrors( |
78 histogram_enum_name='FeatureObserver', | 78 histogram_enum_name='FeatureObserver', |
| 79 update_script_name='update_use_counter_feature_enum.py', |
79 source_enum_path=source_path, | 80 source_enum_path=source_path, |
80 start_marker=start_marker, | 81 start_marker=start_marker, |
81 end_marker=end_marker, | 82 end_marker=end_marker, |
82 strip_k_prefix=True) | 83 strip_k_prefix=True) |
83 if duplicated_values: | 84 if presubmit_error: |
84 return [output_api.PresubmitPromptWarning( | 85 return [output_api.PresubmitPromptWarning(presubmit_error, |
85 'UseCounter::Feature has been updated and there exists duplicated ' | 86 items=[source_path])] |
86 'values between (%s) and (%s)' % duplicated_values, | |
87 items=[source_path])] | |
88 if should_update_histogram: | |
89 return [output_api.PresubmitPromptWarning( | |
90 'UseCounter::Feature has been updated and the UMA mapping needs to ' | |
91 'be regenerated. Please run update_use_counter_feature_enum.py in ' | |
92 'src/tools/metrics/histograms/ to update the mapping.', | |
93 items=[source_path])] | |
94 | |
95 return [] | 87 return [] |
96 | 88 |
97 | 89 |
98 def CheckChangeOnUpload(input_api, output_api): | 90 def CheckChangeOnUpload(input_api, output_api): |
99 results = [] | 91 results = [] |
100 results.extend(_RunUseCounterChecks(input_api, output_api)) | 92 results.extend(_RunUseCounterChecks(input_api, output_api)) |
101 results.extend(_RunUmaHistogramChecks(input_api, output_api)) | 93 results.extend(_RunUmaHistogramChecks(input_api, output_api)) |
102 return results | 94 return results |
103 | 95 |
104 | 96 |
105 def CheckChangeOnCommit(input_api, output_api): | 97 def CheckChangeOnCommit(input_api, output_api): |
106 results = [] | 98 results = [] |
107 results.extend(_RunUseCounterChecks(input_api, output_api)) | 99 results.extend(_RunUseCounterChecks(input_api, output_api)) |
108 results.extend(_RunUmaHistogramChecks(input_api, output_api)) | 100 results.extend(_RunUmaHistogramChecks(input_api, output_api)) |
109 return results | 101 return results |
OLD | NEW |