summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-07 22:26:40 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-07 22:26:40 +0000
commit8c966dd42d7022179ad93cead6da00109295d497 (patch)
tree9e143c59a79176ccccca6898a324761213e71e80
parent0a77849fde4f5deadf1646e69fdffc94e0c9d4e5 (diff)
downloadchromium_src-8c966dd42d7022179ad93cead6da00109295d497.zip
chromium_src-8c966dd42d7022179ad93cead6da00109295d497.tar.gz
chromium_src-8c966dd42d7022179ad93cead6da00109295d497.tar.bz2
Add presubmit check for correct MessageLoopProxy usage in src/media/.
In most cases SingleThreadTaskRunner can be used instead. BUG=315922 R=dalecurtis@chromium.org Review URL: https://codereview.chromium.org/101503007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243408 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--media/PRESUBMIT.py36
1 files changed, 30 insertions, 6 deletions
diff --git a/media/PRESUBMIT.py b/media/PRESUBMIT.py
index aafe23a..2557697 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):
@@ -64,9 +64,33 @@ def _CheckForUseOfWrongClock(input_api, output_api):
return []
+def _CheckForMessageLoopProxy(input_api, output_api):
+ """Make sure media code only uses MessageLoopProxy for accessing the current
+ loop."""
+
+ message_loop_proxy_re = input_api.re.compile(
+ r'\bMessageLoopProxy(?!::current\(\))')
+
+ problems = []
+ for f in input_api.AffectedSourceFiles(_FilterFile):
+ for line_number, line in f.ChangedContents():
+ if message_loop_proxy_re.search(line):
+ problems.append('%s:%d' % (f.LocalPath(), line_number))
+
+ if problems:
+ return [output_api.PresubmitError(
+ 'MessageLoopProxy should only be used for accessing the current loop.\n'
+ 'Use the TaskRunner interfaces instead as they are more explicit about\n'
+ 'the run-time characteristics. In most cases, SingleThreadTaskRunner\n'
+ 'is a drop-in replacement for MessageLoopProxy.', problems)]
+
+ return []
+
+
def _CheckChange(input_api, output_api):
results = []
results.extend(_CheckForUseOfWrongClock(input_api, output_api))
+ results.extend(_CheckForMessageLoopProxy(input_api, output_api))
return results