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

Side by Side Diff: media/PRESUBMIT.py

Issue 2668813002: Remove LazyInstance usage from media/ (Closed)
Patch Set: Fix new LazyInstance. Add PRESUBMIT. Created 3 years, 10 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
« no previous file with comments | « content/renderer/media/webrtc/rtc_stats.cc ('k') | media/audio/audio_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if BASE_TIME_TYPES_RE.search(line): 160 if BASE_TIME_TYPES_RE.search(line):
161 problems.append('%s:%d' % (f, line_number)) 161 problems.append('%s:%d' % (f, line_number))
162 162
163 if problems: 163 if problems:
164 return [output_api.PresubmitError( 164 return [output_api.PresubmitError(
165 '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'
166 'const ref, see base/time/time.h for more information.', problems)] 166 'const ref, see base/time/time.h for more information.', problems)]
167 return [] 167 return []
168 168
169 169
170 def _CheckForUseOfLazyInstance(input_api, output_api):
171 """Check that base::Time and derived classes are passed by value, and not by
jrummell 2017/02/11 00:10:55 Comment needs updating?
DaleCurtis 2017/02/11 00:13:35 Done.
172 const reference """
173
174 problems = []
175
176 lazy_instance_re = re.compile(r'(^|\W)base::LazyInstance<')
177
178 for f in input_api.AffectedSourceFiles(_FilterFile):
179 for line_number, line in f.ChangedContents():
180 if lazy_instance_re.search(line):
181 problems.append('%s:%d' % (f, line_number))
182
183 if problems:
184 return [output_api.PresubmitError(
185 'base::LazyInstance is deprecated; use a thread safe static.', problems)]
186 return []
187
188
170 def _CheckChange(input_api, output_api): 189 def _CheckChange(input_api, output_api):
171 results = [] 190 results = []
172 results.extend(_CheckForUseOfWrongClock(input_api, output_api)) 191 results.extend(_CheckForUseOfWrongClock(input_api, output_api))
173 results.extend(_CheckPassByValue(input_api, output_api)) 192 results.extend(_CheckPassByValue(input_api, output_api))
174 results.extend(_CheckForHistogramOffByOne(input_api, output_api)) 193 results.extend(_CheckForHistogramOffByOne(input_api, output_api))
194 results.extend(_CheckForUseOfLazyInstance(input_api, output_api))
175 return results 195 return results
176 196
177 197
178 def CheckChangeOnUpload(input_api, output_api): 198 def CheckChangeOnUpload(input_api, output_api):
179 return _CheckChange(input_api, output_api) 199 return _CheckChange(input_api, output_api)
180 200
181 201
182 def CheckChangeOnCommit(input_api, output_api): 202 def CheckChangeOnCommit(input_api, output_api):
183 return _CheckChange(input_api, output_api) 203 return _CheckChange(input_api, output_api)
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc/rtc_stats.cc ('k') | media/audio/audio_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698