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

Side by Side Diff: PRESUBMIT.py

Issue 1276523003: Don't trigger HW acceleration from Toasts on low-end devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Check Toast acceleration only on LOLLIPOP+ Created 5 years, 4 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 | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 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. 5 """Top-level presubmit script for Chromium.
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 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 import checkstyle 1305 import checkstyle
1306 finally: 1306 finally:
1307 # Restore sys.path to what it was before. 1307 # Restore sys.path to what it was before.
1308 sys.path = original_sys_path 1308 sys.path = original_sys_path
1309 1309
1310 return checkstyle.RunCheckstyle( 1310 return checkstyle.RunCheckstyle(
1311 input_api, output_api, 'tools/android/checkstyle/chromium-style-5.0.xml', 1311 input_api, output_api, 'tools/android/checkstyle/chromium-style-5.0.xml',
1312 black_list=_EXCLUDED_PATHS + input_api.DEFAULT_BLACK_LIST) 1312 black_list=_EXCLUDED_PATHS + input_api.DEFAULT_BLACK_LIST)
1313 1313
1314 1314
1315 def _CheckAndroidToastUsage(input_api, output_api):
1316 """Checks that code uses org.chromium.ui.widget.Toast instead of
1317 android.widget.Toast (Chromium Toast doesn't force hardware
1318 acceleration on low-end devices, saving memory).
1319 """
1320 toast_import_pattern = input_api.re.compile(
1321 r'^import android\.widget\.Toast;$')
1322
1323 errors = []
1324
1325 sources = lambda affected_file: input_api.FilterSourceFile(
1326 affected_file,
1327 black_list=(_EXCLUDED_PATHS +
1328 _TEST_CODE_EXCLUDED_PATHS +
1329 input_api.DEFAULT_BLACK_LIST +
1330 (r'^chromecast[\\\/].*',
1331 r'^remoting[\\\/].*')),
1332 white_list=(r'.*\.java$',))
1333
1334 for f in input_api.AffectedSourceFiles(sources):
1335 for line_num, line in f.ChangedContents():
1336 if toast_import_pattern.search(line):
1337 errors.append("%s:%d" % (f.LocalPath(), line_num))
1338
1339 results = []
1340
1341 if errors:
1342 results.append(output_api.PresubmitError(
1343 'android.widget.Toast usage is detected. Android toasts use hardware'
1344 ' acceleration, and can be\ncostly on low-end devices. Please use'
1345 ' org.chromium.ui.widget.Toast instead.\n'
1346 'Contact dskiba@chromium.org if you have any questions.',
1347 errors))
1348
1349 return results
1350
1351
1315 def _CheckAndroidCrLogUsage(input_api, output_api): 1352 def _CheckAndroidCrLogUsage(input_api, output_api):
1316 """Checks that new logs using org.chromium.base.Log: 1353 """Checks that new logs using org.chromium.base.Log:
1317 - Are using 'TAG' as variable name for the tags (warn) 1354 - Are using 'TAG' as variable name for the tags (warn)
1318 - Are using the suggested name format for the tags: "cr.<PackageTag>" (warn) 1355 - Are using the suggested name format for the tags: "cr.<PackageTag>" (warn)
1319 - Are using a tag that is shorter than 23 characters (error) 1356 - Are using a tag that is shorter than 23 characters (error)
1320 """ 1357 """
1321 cr_log_import_pattern = input_api.re.compile( 1358 cr_log_import_pattern = input_api.re.compile(
1322 r'^import org\.chromium\.base\.Log;$', input_api.re.MULTILINE) 1359 r'^import org\.chromium\.base\.Log;$', input_api.re.MULTILINE)
1323 class_in_base_pattern = input_api.re.compile( 1360 class_in_base_pattern = input_api.re.compile(
1324 r'^package org\.chromium\.base;$', input_api.re.MULTILINE) 1361 r'^package org\.chromium\.base;$', input_api.re.MULTILINE)
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
1523 results.append(output_api.PresubmitError( 1560 results.append(output_api.PresubmitError(
1524 "%s:%d: Use of deprecated JS %s, use %s instead" % 1561 "%s:%d: Use of deprecated JS %s, use %s instead" %
1525 (fpath.LocalPath(), lnum, deprecated, replacement))) 1562 (fpath.LocalPath(), lnum, deprecated, replacement)))
1526 return results 1563 return results
1527 1564
1528 1565
1529 def _AndroidSpecificOnUploadChecks(input_api, output_api): 1566 def _AndroidSpecificOnUploadChecks(input_api, output_api):
1530 """Groups checks that target android code.""" 1567 """Groups checks that target android code."""
1531 results = [] 1568 results = []
1532 results.extend(_CheckAndroidCrLogUsage(input_api, output_api)) 1569 results.extend(_CheckAndroidCrLogUsage(input_api, output_api))
1570 results.extend(_CheckAndroidToastUsage(input_api, output_api))
1533 return results 1571 return results
1534 1572
1535 1573
1536 def _CommonChecks(input_api, output_api): 1574 def _CommonChecks(input_api, output_api):
1537 """Checks common to both upload and commit.""" 1575 """Checks common to both upload and commit."""
1538 results = [] 1576 results = []
1539 results.extend(input_api.canned_checks.PanProjectChecks( 1577 results.extend(input_api.canned_checks.PanProjectChecks(
1540 input_api, output_api, 1578 input_api, output_api,
1541 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS)) 1579 excluded_paths=_EXCLUDED_PATHS + _TESTRUNNER_PATHS))
1542 results.extend(_CheckAuthorizedAuthor(input_api, output_api)) 1580 results.extend(_CheckAuthorizedAuthor(input_api, output_api))
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1882 for master in masters: 1920 for master in masters:
1883 try_config.setdefault(master, {}) 1921 try_config.setdefault(master, {})
1884 for builder in masters[master]: 1922 for builder in masters[master]:
1885 # Do not trigger presubmit builders, since they're likely to fail 1923 # Do not trigger presubmit builders, since they're likely to fail
1886 # (e.g. OWNERS checks before finished code review), and we're 1924 # (e.g. OWNERS checks before finished code review), and we're
1887 # running local presubmit anyway. 1925 # running local presubmit anyway.
1888 if 'presubmit' not in builder: 1926 if 'presubmit' not in builder:
1889 try_config[master][builder] = ['defaulttests'] 1927 try_config[master][builder] = ['defaulttests']
1890 1928
1891 return try_config 1929 return try_config
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/ChromeTabbedActivity.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698