android_webview
apps
ash
base
build
build_overrides
buildtools
cc
chrome
chromecast
chromeos
cloud_print
components
content
app
app_shim_remote_cocoa
browser
accessibility
android
appcache
audio
background_fetch
background_sync
blob_storage
bluetooth
broadcast_channel
browser_plugin
browsing_data
cache_storage
client_hints
cocoa
code_cache
compositor
contacts
content_index
conversions
cookie_store
device
device_sensors
devtools
display_cutout
dom_storage
download
file_system
font_unique_name_lookup
frame_host
generic_sensor
geolocation
gpu
hid
hyphenation
idle
image_capture
indexed_db
installedapp
keyboard_lock
loader
locks
manifest
media
media_session
memory
native_file_system
net
notifications
origin_trials
payments
permissions
picture_in_picture
portal
presentation
process_internals
push_messaging
renderer_host
resources
scheduler
screen_enumeration
screen_orientation
screenlock_monitor
serial
service_manager
service_worker
shape_detection
sms
speech
ssl
tracing
wake_lock
web_contents
web_package
webauth
webrtc
websockets
webtransport
webui
worker_host
zygote_host
BUILD.gn
DEPS
OWNERS
PRESUBMIT.py
SITE_ISOLATION_OWNERS
about_url_loader_factory.cc
about_url_loader_factory.h
after_startup_task_utils.cc
after_startup_task_utils.h
back_forward_cache_browsertest.cc
bad_message.cc
bad_message.h
battery_monitor_browsertest.cc
bookmarklet_browsertest.cc
browser_associated_interface_unittest.cc
browser_child_process_host_impl.cc
browser_child_process_host_impl.h
browser_child_process_host_impl_receiver_bindings.cc
browser_context.cc
browser_interface_binders.cc
browser_interface_binders.h
browser_interface_broker_impl.h
browser_main.cc
browser_main.h
browser_main_loop.cc
browser_main_loop.h
browser_main_loop_unittest.cc
browser_main_runner_impl.cc
browser_main_runner_impl.h
browser_process_sub_thread.cc
browser_process_sub_thread.h
browser_thread_browsertest.cc
browser_thread_impl.cc
browser_thread_impl.h
browser_thread_unittest.cc
browser_url_handler_impl.cc
browser_url_handler_impl.h
browser_url_handler_impl_unittest.cc
browsing_instance.cc
browsing_instance.h
builtin_service_manifests.cc
builtin_service_manifests.h
byte_stream.cc
byte_stream.h
byte_stream_unittest.cc
can_commit_status.h
child_process_launcher.cc
child_process_launcher.h
child_process_launcher_browsertest.cc
child_process_launcher_helper.cc
child_process_launcher_helper.h
child_process_launcher_helper_android.cc
child_process_launcher_helper_fuchsia.cc
child_process_launcher_helper_linux.cc
child_process_launcher_helper_mac.cc
child_process_launcher_helper_posix.cc
child_process_launcher_helper_posix.h
child_process_launcher_helper_win.cc
child_process_security_policy_browsertest.cc
child_process_security_policy_impl.cc
child_process_security_policy_impl.h
child_process_security_policy_unittest.cc
child_process_task_port_provider_mac.cc
child_process_task_port_provider_mac.h
child_process_task_port_provider_mac_unittest.cc
content_service_browsertest.cc
content_service_delegate_impl.cc
content_service_delegate_impl.h
context_factory.cc
cross_origin_opener_policy_browsertest.cc
cross_site_transfer_browsertest.cc
data_decoder_browsertest.cc
data_url_loader_factory.cc
data_url_loader_factory.h
database_browsertest.cc
do_not_track_browsertest.cc
feature_observer.cc
feature_observer.h
field_trial_recorder.cc
field_trial_recorder.h
field_trial_synchronizer.cc
field_trial_synchronizer.h
find_in_page_client.cc
find_in_page_client.h
find_request_manager.cc
find_request_manager.h
find_request_manager_browsertest.cc
font_list_async.cc
font_service.cc
font_service.h
form_controls_browsertest.cc
histogram_controller.cc
histogram_controller.h
histogram_subscriber.h
histogram_synchronizer.cc
histogram_synchronizer.h
histograms_internals_ui.cc
histograms_internals_ui.h
host_zoom_level_context.cc
host_zoom_level_context.h
host_zoom_map_impl.cc
host_zoom_map_impl.h
host_zoom_map_impl_browsertest.cc
host_zoom_map_impl_unittest.cc
initiator_csp_context.cc
initiator_csp_context.h
interface_provider_filtering.cc
interface_provider_filtering.h
isolated_origin_browsertest.cc
isolated_origin_util.cc
isolated_origin_util.h
isolation_context.cc
isolation_context.h
keyboard_lock_browsertest.cc
keyboard_lock_browsertest.h
keyboard_lock_browsertest_mac.mm
log_console_message.cc
log_console_message.h
message_port_provider.cc
message_port_provider_browsertest.cc
mime_registry_impl.cc
mime_registry_impl.h
mojo_sandbox_browsertest.cc
navigation_browsertest.cc
navigation_mhtml_browsertest.cc
navigation_subresource_loader_params.cc
navigation_subresource_loader_params.h
net_info_browsertest.cc
network_context_client_base_impl.cc
network_context_client_base_impl.h
network_context_client_base_impl_unittest.cc
network_service_browsertest.cc
network_service_client.cc
network_service_client.h
network_service_instance_impl.cc
network_service_instance_impl.h
network_service_restart_browsertest.cc
notification_service_impl.cc
notification_service_impl.h
notification_service_impl_unittest.cc
oop_browsertest.cc
pepper_flash_settings_helper_impl.cc
pepper_flash_settings_helper_impl.h
performance_memory_browsertest.cc
plugin_content_origin_whitelist.cc
plugin_content_origin_whitelist.h
plugin_data_remover_impl.cc
plugin_data_remover_impl.h
plugin_list.cc
plugin_list.h
plugin_list_unittest.cc
plugin_private_storage_helper.cc
plugin_private_storage_helper.h
plugin_service_impl.cc
plugin_service_impl.h
plugin_service_impl_browsertest.cc
plugin_service_impl_unittest.cc
pointer_lock_browsertest.cc
pointer_lock_browsertest.h
pointer_lock_browsertest_mac.mm
posix_file_descriptor_info_impl.cc
posix_file_descriptor_info_impl.h
posix_file_descriptor_info_impl_unittest.cc
power_monitor_browsertest.cc
ppapi_plugin_process_host.cc
ppapi_plugin_process_host.h
ppapi_plugin_process_host_receiver_bindings.cc
quota_dispatcher_host.cc
quota_dispatcher_host.h
resolve_proxy_msg_helper.cc
resolve_proxy_msg_helper.h
resolve_proxy_msg_helper_unittest.cc
resource_context_impl.cc
resource_context_impl.h
resource_coordinator_service.cc
resource_loading_browsertest.cc
sandbox_host_linux.cc
sandbox_host_linux.h
sandbox_ipc_linux.cc
sandbox_ipc_linux.h
sandbox_mac_unittest.mm
sandbox_parameters_mac.h
sandbox_parameters_mac.mm
sandbox_support_mac_impl.h
sandbox_support_mac_impl.mm
scoped_active_url.cc
scoped_active_url.h
security_exploit_browsertest.cc
service_process_host_browsertest.cc
service_process_host_impl.cc
session_history_browsertest.cc
shareable_file_reference_unittest.cc
site_instance_impl.cc
site_instance_impl.h
site_instance_impl_unittest.cc
site_per_process_browsertest.cc
site_per_process_browsertest.h
site_per_process_hit_test_browsertest.cc
site_per_process_mac_browsertest.mm
site_per_process_unload_browsertest.cc
snapshot_browsertest.cc
ssl_private_key_impl.cc
ssl_private_key_impl.h
startup_data_impl.cc
startup_data_impl.h
startup_helper.cc
startup_helper.h
startup_task_runner.cc
startup_task_runner.h
startup_task_runner_unittest.cc
storage_partition_impl.cc
storage_partition_impl.h
storage_partition_impl_browsertest.cc
storage_partition_impl_map.cc
storage_partition_impl_map.h
storage_partition_impl_map_unittest.cc
storage_partition_impl_unittest.cc
system_connector_impl.cc
system_connector_impl.h
theme_helper.cc
theme_helper.h
theme_helper_mac.h
theme_helper_mac.mm
typemaps.gni
url_loader_factory_getter.cc
url_loader_factory_getter.h
url_loader_factory_params_helper.cc
url_loader_factory_params_helper.h
utility_process_host.cc
utility_process_host.h
utility_process_host_browsertest.cc
utility_process_host_receiver_bindings.cc
v8_snapshot_files.cc
v8_snapshot_files.h
vibration_browsertest.cc
video_capture_service.cc
web_contents_receiver_set_browsertest.cc
webkit_browsertest.cc
worker_network_isolation_key_browsertest.cc
zoom_browsertest.cc
child
common
gpu
ppapi_plugin
public
renderer
shell
test
utility
zygote
BUILD.gn
DEPS
OWNERS
README.md
content_resources.grd
dev_ui_content_resources.grd
courgette
crypto
dbus
device
docs
extensions
fuchsia
gin
google_apis
google_update
gpu
headless
infra
ios
ipc
jingle
media
mojo
native_client_sdk
net
pdf
ppapi
printing
remoting
rlz
sandbox
services
skia
sql
storage
styleguide
testing
third_party
tools
ui
url
weblayer
.clang-format
.clang-tidy
.eslintrc.js
.git-blame-ignore-revs
.gitattributes
.gitignore
.gn
.vpython
.vpython3
.yapfignore
AUTHORS
BUILD.gn
CODE_OF_CONDUCT.md
DEPS
ENG_REVIEW_OWNERS
LICENSE
LICENSE.chromium_os
OWNERS
PRESUBMIT.py
PRESUBMIT_test.py
PRESUBMIT_test_mocks.py
README.md
WATCHLISTS
codereview.settings

This CL fixes presubmit_scheme_histograms.py and presubmit_bad_message_reasons.py which after r462591 would always report presubmit errors (because it started returning a tuple from HistogramNeedsUpdate which always coerces to True in the broken presubmit scripts). After r462591 HistogramNeedsUpdate effectively checks all histogram-enum-related presubmits (both for updating histograms.xml and for detecting duplicate values). Therefore the current CL renames this function to CheckPresubmitErrors and makes it return a presubmit error (rather than a tuple of (needs_updating, duplicates)). This refactoring has a nice side benefit - after this CL, all presubmits going through CheckPresubmitErrors will check for duplicate values (r462591 only added this check for UseCounter histograms). This CL also tweaks content/browser/PRESUBMIT.py so that it applies *both* to upload-time and commit-time checks (without this change |git cl presubmit| would not hit the checks related to content/browser/bad_message.h - they would only be hit when running |git cl presubmit --upload|). Manual testing done: - Make changes in content/browser/bad_message.h, chrome/browser/extensions/chrome_content_browser_client_extensions_part.cc, third_party/WebKit/Source/code/frame - Run git cl presubmit and verify that the presubmit checks detect 1) duplicates and 2) the need to update histograms.xml BUG=577772 TEST=See "Manual testing done" above. TBR=sky@chromium.org, jochen@chromium.org, rdevlin.cronin@chromium.org Review-Url: https://codereview.chromium.org/2841823007 Cr-Commit-Position: refs/heads/master@{#468003}
35 lines
1.2 KiB
Python
35 lines
1.2 KiB
Python
# Copyright 2017 The Chromium Authors. All rights reserved.
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
# found in the LICENSE file.
|
|
|
|
"""Chromium presubmit script to check that BadMessage enums in histograms.xml
|
|
match the corresponding bad_message.h file.
|
|
"""
|
|
|
|
def CheckChangeOnCommit(input_api, output_api):
|
|
return _CommonChecks(input_api, output_api)
|
|
|
|
def CheckChangeOnUpload(input_api, output_api):
|
|
return _CommonChecks(input_api, output_api)
|
|
|
|
def _RunHistogramChecks(input_api, output_api, histogram_name):
|
|
try:
|
|
# Setup sys.path so that we can call histograms code.
|
|
import sys
|
|
original_sys_path = sys.path
|
|
sys.path = sys.path + [input_api.os_path.join(
|
|
input_api.change.RepositoryRoot(),
|
|
'tools', 'metrics', 'histograms')]
|
|
|
|
import presubmit_bad_message_reasons
|
|
return presubmit_bad_message_reasons.PrecheckBadMessage(input_api,
|
|
output_api, histogram_name)
|
|
except Exception as e:
|
|
return [output_api.PresubmitError("Error verifying histogram (%s)."
|
|
% str(e))]
|
|
finally:
|
|
sys.path = original_sys_path
|
|
|
|
def _CommonChecks(input_api, output_api):
|
|
return _RunHistogramChecks(input_api, output_api, "BadMessageReasonContent")
|