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

Side by Side Diff: media/PRESUBMIT.py

Issue 2133083002: Remove all remaining traces of MessageLoopProxy. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Top-level presubmit script for Chromium media component. 5 """Top-level presubmit script for Chromium media component.
6 6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into depot_tools. 8 for more details about the presubmit API built into depot_tools.
9 """ 9 """
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 'You added one or more references to the base::Time class and/or one\n' 70 'You added one or more references to the base::Time class and/or one\n'
71 'of its member functions (or base::Clock/DefaultClock). In media\n' 71 'of its member functions (or base::Clock/DefaultClock). In media\n'
72 'code, it is rarely correct to use a clock susceptible to time skew!\n' 72 'code, it is rarely correct to use a clock susceptible to time skew!\n'
73 'Instead, could you use base::TimeTicks to track the passage of\n' 73 'Instead, could you use base::TimeTicks to track the passage of\n'
74 'real-world time?\n\n' + 74 'real-world time?\n\n' +
75 '\n'.join(problems))] 75 '\n'.join(problems))]
76 else: 76 else:
77 return [] 77 return []
78 78
79 79
80 def _CheckForMessageLoopProxy(input_api, output_api):
81 """Make sure media code only uses MessageLoopProxy for accessing the current
82 loop."""
83
84 message_loop_proxy_re = input_api.re.compile(
85 r'\bMessageLoopProxy(?!::current\(\))')
86
87 problems = []
88 for f in input_api.AffectedSourceFiles(_FilterFile):
89 for line_number, line in f.ChangedContents():
90 if message_loop_proxy_re.search(line):
91 problems.append('%s:%d' % (f.LocalPath(), line_number))
92
93 if problems:
94 return [output_api.PresubmitError(
95 'MessageLoopProxy should only be used for accessing the current loop.\n'
96 'Use the TaskRunner interfaces instead as they are more explicit about\n'
97 'the run-time characteristics. In most cases, SingleThreadTaskRunner\n'
98 'is a drop-in replacement for MessageLoopProxy.', problems)]
99
100 return []
101
102
103 def _CheckForHistogramOffByOne(input_api, output_api): 80 def _CheckForHistogramOffByOne(input_api, output_api):
104 """Make sure histogram enum maxes are used properly""" 81 """Make sure histogram enum maxes are used properly"""
105 82
106 # A general-purpose chunk of regex to match whitespace and/or comments 83 # A general-purpose chunk of regex to match whitespace and/or comments
107 # that may be interspersed with the code we're interested in: 84 # that may be interspersed with the code we're interested in:
108 comment = r'/\*.*?\*/|//[^\n]*' 85 comment = r'/\*.*?\*/|//[^\n]*'
109 whitespace = r'(?:[\n\t ]|(?:' + comment + r'))*' 86 whitespace = r'(?:[\n\t ]|(?:' + comment + r'))*'
110 87
111 # The name is assumed to be a literal string. 88 # The name is assumed to be a literal string.
112 histogram_name = r'"[^"]*"' 89 histogram_name = r'"[^"]*"'
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 if problems: 163 if problems:
187 return [output_api.PresubmitError( 164 return [output_api.PresubmitError(
188 'base::Time and derived classes should be passed by value and not by\n' 165 'base::Time and derived classes should be passed by value and not by\n'
189 'const ref, see base/time/time.h for more information.', problems)] 166 'const ref, see base/time/time.h for more information.', problems)]
190 return [] 167 return []
191 168
192 169
193 def _CheckChange(input_api, output_api): 170 def _CheckChange(input_api, output_api):
194 results = [] 171 results = []
195 results.extend(_CheckForUseOfWrongClock(input_api, output_api)) 172 results.extend(_CheckForUseOfWrongClock(input_api, output_api))
196 results.extend(_CheckForMessageLoopProxy(input_api, output_api))
197 results.extend(_CheckPassByValue(input_api, output_api)) 173 results.extend(_CheckPassByValue(input_api, output_api))
198 results.extend(_CheckForHistogramOffByOne(input_api, output_api)) 174 results.extend(_CheckForHistogramOffByOne(input_api, output_api))
199 results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api) 175 results += input_api.canned_checks.CheckPatchFormatted(input_api, output_api)
200 return results 176 return results
201 177
202 178
203 def CheckChangeOnUpload(input_api, output_api): 179 def CheckChangeOnUpload(input_api, output_api):
204 return _CheckChange(input_api, output_api) 180 return _CheckChange(input_api, output_api)
205 181
206 182
207 def CheckChangeOnCommit(input_api, output_api): 183 def CheckChangeOnCommit(input_api, output_api):
208 return _CheckChange(input_api, output_api) 184 return _CheckChange(input_api, output_api)
OLDNEW
« no previous file with comments | « ios/chrome/browser/net/ios_chrome_url_request_context_getter.h ('k') | net/url_request/url_request_context_getter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698