| 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 |
| 11 | 11 |
| 12 def _RunUseCounterChecks(input_api, output_api): | 12 def _RunUseCounterChecks(input_api, output_api): |
| 13 for f in input_api.AffectedFiles(): | 13 for f in input_api.AffectedFiles(): |
| 14 if f.LocalPath().endswith('UseCounter.cpp'): | 14 if f.LocalPath().endswith('UseCounter.cpp'): |
| 15 useCounterCpp = f | 15 useCounterCpp = f |
| 16 break | 16 break |
| 17 else: | 17 else: |
| 18 return [] | 18 return [] |
| 19 | 19 |
| 20 largestFoundBucket = 0 | 20 largestFoundBucket = 0 |
| 21 maximumBucket = 0 | 21 maximumBucket = 0 |
| 22 # Looking for a line like "case CSSPropertyGrid: return 453;" | 22 # Looking for a line like "case CSSPropertyGrid: return 453;" |
| 23 bucketFinder = input_api.re.compile(r'.*CSSProperty.*return\s*([0-9]+).*') | 23 bucketFinder = input_api.re.compile(r'.*CSSProperty.*return\s*([0-9]+).*') |
| 24 # Looking for a line like "int maximumCSSSampleId() { return 452; }" | 24 # Looking for a line like "int maximumCSSSampleId() { return 452; }" |
| 25 maximumFinder = input_api.re.compile( | 25 maximumFinder = input_api.re.compile( |
| 26 r'int maximumCSSSampleId\(\) { return ([0-9]+)') | 26 r'constexpr int kMaximumCSSSampleId = ([0-9]+);') |
| 27 for line in useCounterCpp.NewContents(): | 27 for line in useCounterCpp.NewContents(): |
| 28 bucketMatch = bucketFinder.match(line) | 28 bucketMatch = bucketFinder.match(line) |
| 29 if bucketMatch: | 29 if bucketMatch: |
| 30 bucket = int(bucketMatch.group(1)) | 30 bucket = int(bucketMatch.group(1)) |
| 31 largestFoundBucket = max(largestFoundBucket, bucket) | 31 largestFoundBucket = max(largestFoundBucket, bucket) |
| 32 else: | 32 else: |
| 33 maximumMatch = maximumFinder.match(line) | 33 maximumMatch = maximumFinder.match(line) |
| 34 if maximumMatch: | 34 if maximumMatch: |
| 35 maximumBucket = int(maximumMatch.group(1)) | 35 maximumBucket = int(maximumMatch.group(1)) |
| 36 | 36 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 results.extend(_RunUseCounterChecks(input_api, output_api)) | 90 results.extend(_RunUseCounterChecks(input_api, output_api)) |
| 91 results.extend(_RunUmaHistogramChecks(input_api, output_api)) | 91 results.extend(_RunUmaHistogramChecks(input_api, output_api)) |
| 92 return results | 92 return results |
| 93 | 93 |
| 94 | 94 |
| 95 def CheckChangeOnCommit(input_api, output_api): | 95 def CheckChangeOnCommit(input_api, output_api): |
| 96 results = [] | 96 results = [] |
| 97 results.extend(_RunUseCounterChecks(input_api, output_api)) | 97 results.extend(_RunUseCounterChecks(input_api, output_api)) |
| 98 results.extend(_RunUmaHistogramChecks(input_api, output_api)) | 98 results.extend(_RunUmaHistogramChecks(input_api, output_api)) |
| 99 return results | 99 return results |
| OLD | NEW |