def _RunUmaHistogramChecks(input_api, output_api): # pylint: disable=C0103 import sys original_sys_path = sys.path try: sys.path = sys.path + [input_api.os_path.join( input_api.PresubmitLocalPath(), '..', '..', '..', '..', '..', 'tools', 'metrics', 'histograms')] import update_histogram_enum # pylint: disable=F0401 finally: sys.path = original_sys_path source_path = '' for f in input_api.AffectedFiles(): if f.LocalPath().endswith('web_feature.mojom'): source_path = f.LocalPath() break else: return [] start_marker = '^enum WebFeature {' end_marker = '^kNumberOfFeatures' presubmit_error = update_histogram_enum.CheckPresubmitErrors( histogram_enum_name='FeatureObserver', update_script_name='update_use_counter_feature_enum.py', source_enum_path=source_path, start_marker=start_marker, end_marker=end_marker, strip_k_prefix=True) if presubmit_error: return [output_api.PresubmitPromptWarning(presubmit_error, items=[source_path])] return []
def PrecheckBadMessage(input_api, output_api, histogram_name): source_path = '' # This function is called once per bad_message.h-containing directory. Check # for the |bad_message.h| file, and if present, remember its path. for f in input_api.AffectedFiles(): if f.LocalPath().endswith('bad_message.h'): source_path = f.LocalPath() break # If the |bad_message.h| wasn't found in this change, then there is nothing to # do and histogram.xml does not need to be updated. if source_path == '': return [] START_MARKER = '^enum (class )?BadMessageReason {' END_MARKER = '^BAD_MESSAGE_MAX' presubmit_error = update_histogram_enum.CheckPresubmitErrors( histogram_enum_name=histogram_name, update_script_name='update_bad_message_reasons.py', source_enum_path=source_path, start_marker=START_MARKER, end_marker=END_MARKER) if presubmit_error: return [ output_api.PresubmitPromptWarning(presubmit_error, items=[source_path]) ] return []
def PrecheckShouldAllowOpenURLEnums(input_api, output_api): source_file = 'chrome/browser/extensions/' \ 'chrome_content_browser_client_extensions_part.cc' affected_files = (f.LocalPath() for f in input_api.AffectedFiles()) if source_file not in affected_files: return [] presubmit_error = update_histogram_enum.CheckPresubmitErrors( histogram_enum_name='ShouldAllowOpenURLFailureScheme', update_script_name='update_should_allow_open_url_histograms.py', source_enum_path=source_file, start_marker='^enum ShouldAllowOpenURLFailureScheme {', end_marker='^SCHEME_LAST') if presubmit_error: return [output_api.PresubmitPromptWarning(presubmit_error, items=[source_file])] return []
def _RunUmaHistogramChecks(input_api, output_api): original_sys_path = sys.path try: sys.path = sys.path + [ input_api.os_path.join(input_api.PresubmitLocalPath(), '..', '..', '..', '..', '..', 'tools', 'metrics', 'histograms') ] import update_histogram_enum # pylint: disable=F0401 import update_use_counter_css # pylint: disable=F0401 finally: sys.path = original_sys_path source_path = 'third_party/blink/public/mojom/use_counter/'\ 'css_property_id.mojom' if not source_path in [f.LocalPath() for f in input_api.AffectedFiles()]: return [] # Note: This is similar to update_histogram_enum.CheckPresubmitErrors except # that we use the logic in update_use_counter_css to produce the enum # values. histogram_enum_name = 'MappedCSSProperties' update_script_name = 'update_use_counter_css.py' def read_values(source_path, start_marker, end_marker, strip_k_prefix): return update_use_counter_css.ReadCssProperties(source_path) error = update_histogram_enum.CheckPresubmitErrors( histogram_enum_name, update_script_name, source_path, '', '', histogram_value_reader=read_values) if error: return [output_api.PresubmitPromptWarning(error, items=[source_path])] return []