| Index: media/PRESUBMIT.py
|
| diff --git a/media/PRESUBMIT.py b/media/PRESUBMIT.py
|
| index d87000bcc96d997f3ac684c54923c342e5446d21..02bd02bf01b13a3588e909b9ac1ea54eb4b71d68 100644
|
| --- a/media/PRESUBMIT.py
|
| +++ b/media/PRESUBMIT.py
|
| @@ -8,6 +8,19 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
|
| for more details about the presubmit API built into depot_tools.
|
| """
|
|
|
| +import re
|
| +import string
|
| +
|
| +# Well-defined simple classes containing only <= 4 ints, or <= 2 floats.
|
| +BASE_TIME_TYPES = [
|
| + 'base::Time',
|
| + 'base::TimeDelta',
|
| + 'base::TimeTicks',
|
| +]
|
| +
|
| +BASE_TIME_TYPES_RE = re.compile(r'\bconst (%s)&' %
|
| + string.join(BASE_TIME_TYPES, '|'))
|
| +
|
| def _FilterFile(affected_file):
|
| """Return true if the file could contain code requiring a presubmit check."""
|
| return affected_file.LocalPath().endswith(
|
| @@ -159,10 +172,29 @@ def _CheckForHistogramOffByOne(input_api, output_api):
|
| return []
|
|
|
|
|
| +def _CheckPassByValue(input_api, output_api):
|
| + """Check that base::Time and derived classes are passed by value, and not by
|
| + const reference """
|
| +
|
| + problems = []
|
| +
|
| + for f in input_api.AffectedSourceFiles(_FilterFile):
|
| + for line_number, line in f.ChangedContents():
|
| + if BASE_TIME_TYPES_RE.search(line):
|
| + problems.append('%s:%d' % (f, line_number))
|
| +
|
| + if problems:
|
| + return [output_api.PresubmitError(
|
| + 'base::Time and derived classes should be passed by value and not by\n'
|
| + 'const ref, see base/time/time.h for more information.', problems)]
|
| + return []
|
| +
|
| +
|
| def _CheckChange(input_api, output_api):
|
| results = []
|
| results.extend(_CheckForUseOfWrongClock(input_api, output_api))
|
| results.extend(_CheckForMessageLoopProxy(input_api, output_api))
|
| + results.extend(_CheckPassByValue(input_api, output_api))
|
| results.extend(_CheckForHistogramOffByOne(input_api, output_api))
|
| results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api)
|
| return results
|
|
|