Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2403)

Unified Diff: media/PRESUBMIT.py

Issue 101503007: Add presubmit check for correct MessageLoopProxy usage in src/media/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix re Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/PRESUBMIT.py
diff --git a/media/PRESUBMIT.py b/media/PRESUBMIT.py
index aafe23a2f9fd19fd482c762d878ebdb48ae43014..255769720f4f86dd98f64aa352c14a4ba27d5420 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698