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

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 spacing 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..de7bc1eabda77376b9829b1b7017f5c0145d18c5 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,35 @@ 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 = r'\bMessageLoopProxy(::current\(\))?'
+
+ bad_files = []
+ for f in input_api.AffectedSourceFiles(_FilterFile):
+ contents = input_api.ReadFile(f, 'rb')
DaleCurtis 2014/01/07 20:13:46 Instead of reading the file you should only need t
scherkus (not reviewing) 2014/01/07 21:40:22 Done. (I initially had it read the whole file to
+ 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
« 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