Chromium Code Reviews| Index: media/PRESUBMIT.py |
| diff --git a/media/PRESUBMIT.py b/media/PRESUBMIT.py |
| index aafe23a2f9fd19fd482c762d878ebdb48ae43014..ced9069008213df5900cf6076fcf0bc0f7f2387e 100644 |
| --- a/media/PRESUBMIT.py |
| +++ b/media/PRESUBMIT.py |
| @@ -8,15 +8,15 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| for more details about the presubmit API built into gcl. |
| """ |
| +def _FilterFile(affected_file): |
| + """Return true if the file could contain code requiring a presubmit check.""" |
| + return affected_file.LocalPath().endswith( |
| + ('.h', '.cc', '.cpp', '.cxx', '.mm')) |
| + |
| def _CheckForUseOfWrongClock(input_api, output_api): |
| """Make sure new lines of media code don't use a clock susceptible to skew.""" |
| - def FilterFile(affected_file): |
| - """Return true if the file could contain code referencing base::Time.""" |
| - return affected_file.LocalPath().endswith( |
| - ('.h', '.cc', '.cpp', '.cxx', '.mm')) |
| - |
| # Regular expression that should detect any explicit references to the |
| # base::Time type (or base::Clock/DefaultClock), whether in using decls, |
| # typedefs, or to call static methods. |
| @@ -45,7 +45,7 @@ def _CheckForUseOfWrongClock(input_api, output_api): |
| r'(' + using_base_time_decl_pattern + r')|(' + |
| base_time_konstant_pattern + r')') |
| problems = [] |
| - for f in input_api.AffectedSourceFiles(FilterFile): |
| + for f in input_api.AffectedSourceFiles(_FilterFile): |
| for line_number, line in f.ChangedContents(): |
| if problem_re.search(line): |
| if not exception_re.search(line): |
| @@ -63,16 +63,38 @@ def _CheckForUseOfWrongClock(input_api, output_api): |
| else: |
| return [] |
| +def _CheckForMessageLoopProxy(input_api, output_api): |
| + """Make sure media code only uses MessageLoopProxy for accessing the current |
|
DaleCurtis
2014/01/07 20:00:42
I'm not sure what you mean here. Can you elaborat
scherkus (not reviewing)
2014/01/07 20:06:10
we want to catch any use of MessageLoopProxy that
DaleCurtis
2014/01/07 20:13:46
Are you expecting SingleThreadTaskRunner or TaskRu
scherkus (not reviewing)
2014/01/07 21:40:22
I'm expecting anything other than MLP, but in most
|
| + loop.""" |
| + |
| + message_loop_proxy_re = r'\bMessageLoopProxy(::current\(\))?' |
| + |
| + bad_files = [] |
| + for f in input_api.AffectedSourceFiles(_FilterFile): |
| + contents = input_api.ReadFile(f, 'rb') |
| + for match in input_api.re.finditer(message_loop_proxy_re, contents): |
| + if match.lastindex == 1: |
| + continue |
| + |
| + # No need to check remaining matches in an offending file. |
| + bad_files.append(f) |
| + break |
| + |
| + if bad_files: |
| + return [output_api.PresubmitError( |
| + 'These files reference MessageLoopProxy for uses other than accessing ' |
| + 'the current loop:', bad_files)] |
| + |
| + return [] |
| def _CheckChange(input_api, output_api): |
| results = [] |
| results.extend(_CheckForUseOfWrongClock(input_api, output_api)) |
| + results.extend(_CheckForMessageLoopProxy(input_api, output_api)) |
| return results |
| - |
|
DaleCurtis
2014/01/07 20:00:42
Python style is two lines between global methods.
scherkus (not reviewing)
2014/01/07 20:06:10
whoops! done
|
| def CheckChangeOnUpload(input_api, output_api): |
| return _CheckChange(input_api, output_api) |
| - |
| def CheckChangeOnCommit(input_api, output_api): |
| return _CheckChange(input_api, output_api) |