| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2017 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 """Blink frame presubmit script |
| 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 for more details about the presubmit API built into gcl. |
| 9 """ |
| 10 |
| 11 |
| 12 def _RunUmaHistogramChecks(input_api, output_api): # pylint: disable=C0103 |
| 13 import sys |
| 14 |
| 15 original_sys_path = sys.path |
| 16 try: |
| 17 sys.path = sys.path + [input_api.os_path.join( |
| 18 input_api.PresubmitLocalPath(), '..', '..', '..', '..', |
| 19 'tools', 'metrics', 'histograms')] |
| 20 import update_histogram_enum # pylint: disable=F0401 |
| 21 finally: |
| 22 sys.path = original_sys_path |
| 23 |
| 24 source_path = '' |
| 25 for f in input_api.AffectedFiles(): |
| 26 if f.LocalPath().endswith('UseCounterFeature.def'): |
| 27 source_path = f.LocalPath() |
| 28 break |
| 29 else: |
| 30 return [] |
| 31 |
| 32 start_marker = '^' |
| 33 end_marker = '^kNumberOfFeatures' |
| 34 presubmit_error = update_histogram_enum.CheckPresubmitErrors( |
| 35 histogram_enum_name='FeatureObserver', |
| 36 update_script_name='update_use_counter_feature_enum.py', |
| 37 source_enum_path=source_path, |
| 38 start_marker=start_marker, |
| 39 end_marker=end_marker, |
| 40 strip_k_prefix=True) |
| 41 if presubmit_error: |
| 42 return [output_api.PresubmitPromptWarning(presubmit_error, |
| 43 items=[source_path])] |
| 44 return [] |
| 45 |
| 46 |
| 47 def CheckChangeOnUpload(input_api, output_api): # pylint: disable=C0103 |
| 48 results = [] |
| 49 results.extend(_RunUmaHistogramChecks(input_api, output_api)) |
| 50 return results |
| 51 |
| 52 |
| 53 def CheckChangeOnCommit(input_api, output_api): # pylint: disable=C0103 |
| 54 results = [] |
| 55 results.extend(_RunUmaHistogramChecks(input_api, output_api)) |
| 56 return results |
| OLD | NEW |