| 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 CSSPropertyFoo: 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 "static int maximumCSSSampleId() { return 452; }" | 24 # Looking for a line like "static int maximumCSSSampleId() { return 452; }" |
| 25 maximumFinder = input_api.re.compile( | 25 maximumFinder = input_api.re.compile( |
| 26 r'static int maximumCSSSampleId\(\) { return ([0-9]+)') | 26 r'static int maximumCSSSampleId\(\) { return ([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: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 48 | 48 |
| 49 return [] | 49 return [] |
| 50 | 50 |
| 51 | 51 |
| 52 def CheckChangeOnUpload(input_api, output_api): | 52 def CheckChangeOnUpload(input_api, output_api): |
| 53 return _RunUseCounterChecks(input_api, output_api) | 53 return _RunUseCounterChecks(input_api, output_api) |
| 54 | 54 |
| 55 | 55 |
| 56 def CheckChangeOnCommit(input_api, output_api): | 56 def CheckChangeOnCommit(input_api, output_api): |
| 57 return _RunUseCounterChecks(input_api, output_api) | 57 return _RunUseCounterChecks(input_api, output_api) |
| OLD | NEW |