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

Side by Side Diff: media/PRESUBMIT.py

Issue 16823003: Replace erroneous use of base::Time with base::TimeTicks throughout media code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/PresubmitPromptWarning/PresubmitPromptOrNotify/ Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | media/audio/audio_low_latency_input_output_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 # found in the LICENSE file.
4
5 """Top-level presubmit script for Chromium media component.
6
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl.
9 """
10
11
12 def _CheckForUseOfWrongClock(input_api, output_api):
13 """Make sure new lines of media code don't use a clock susceptible to skew."""
14
15 def FilterFile(affected_file):
16 """Return true if the file could contain code referencing base::Time."""
17 return affected_file.LocalPath().endswith(
18 ('.h', '.cc', '.cpp', '.cxx', '.mm'))
19
20 # Regular expression that should detect any explicit references to the
21 # base::Time type (or base::Clock/DefaultClock), whether in using decls,
22 # typedefs, or to call static methods.
23 base_time_type_pattern = r'base::(Time|Clock|DefaultClock)(\W|$)'
24
25 # Regular expression that should detect references to the base::Time class
26 # members, such as a call to base::Time::Now. Exceptions: References to the
27 # kXXX constants are ignored.
28 base_time_member_pattern = r'(^|\W)(Time|Clock|DefaultClock)::[^k]'
29
30 problem_re = input_api.re.compile(
31 r'(' + base_time_type_pattern + r')|(' + base_time_member_pattern + r')')
32 problems = []
33 for f in input_api.AffectedSourceFiles(FilterFile):
34 for line_number, line in f.ChangedContents():
35 if problem_re.search(line):
36 problems.append(
37 ' %s:%d\n %s' % (f.LocalPath(), line_number, line.strip()))
38
39 if problems:
40 return [output_api.PresubmitPromptOrNotify(
41 'You added one or more references to the base::Time class and/or one\n'
42 'of its member functions (or base::Clock/DefaultClock). In media\n'
43 'code, it is rarely correct to use a clock susceptible to time skew!\n'
44 'Instead, could you use base::TimeTicks to track the passage of\n'
45 'real-world time?\n\n' +
46 '\n'.join(problems))]
47 else:
48 return []
49
50
51 def _CheckChange(input_api, output_api):
52 results = []
53 results.extend(_CheckForUseOfWrongClock(input_api, output_api))
54 return results
55
56
57 def CheckChangeOnUpload(input_api, output_api):
58 return _CheckChange(input_api, output_api)
59
60
61 def CheckChangeOnCommit(input_api, output_api):
62 return _CheckChange(input_api, output_api)
OLDNEW
« no previous file with comments | « no previous file | media/audio/audio_low_latency_input_output_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698