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

Unified Diff: third_party/WebKit/Source/core/frame/PRESUBMIT.py

Issue 1745913002: Add histograms presubmit check for UseCounter.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Style fix Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/update_histogram_enum.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/frame/PRESUBMIT.py
diff --git a/third_party/WebKit/Source/core/frame/PRESUBMIT.py b/third_party/WebKit/Source/core/frame/PRESUBMIT.py
index eba4c2f66424070ec1a33f4ddb8ae72efd61c7ba..67c2ee8d78ee2c2a3b3eb6efafd59171cd2f0ae0 100644
--- a/third_party/WebKit/Source/core/frame/PRESUBMIT.py
+++ b/third_party/WebKit/Source/core/frame/PRESUBMIT.py
@@ -49,9 +49,51 @@ def _RunUseCounterChecks(input_api, output_api):
return []
+def _RunUmaHistogramChecks(input_api, output_api):
+ 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
+ finally:
+ sys.path = original_sys_path
+
+ source_path = ''
+ for f in input_api.AffectedFiles():
+ if f.LocalPath().endswith('UseCounter.h'):
+ source_path = f.LocalPath()
+ break
+ else:
+ return []
+
+ START_MARKER = '^enum Feature {'
+ END_MARKER = '^NumberOfFeatures'
+ if update_histogram_enum.HistogramNeedsUpdate(
+ histogram_enum_name='FeatureObserver',
+ source_enum_path=source_path,
+ start_marker=START_MARKER,
+ end_marker=END_MARKER):
+ return [output_api.PresubmitPromptWarning(
+ 'UseCounter::Feature has been updated and the UMA mapping needs to '
+ 'be regenerated. Please run update_use_counter_feature_enum.py in '
+ 'src/tools/metrics/histograms/ to update the mapping.',
+ items=[source_path])]
+
+ return []
+
+
def CheckChangeOnUpload(input_api, output_api):
- return _RunUseCounterChecks(input_api, output_api)
+ results = []
+ results.extend(_RunUseCounterChecks(input_api, output_api))
+ results.extend(_RunUmaHistogramChecks(input_api, output_api))
+ return results
def CheckChangeOnCommit(input_api, output_api):
- return _RunUseCounterChecks(input_api, output_api)
+ results = []
+ results.extend(_RunUseCounterChecks(input_api, output_api))
+ results.extend(_RunUmaHistogramChecks(input_api, output_api))
+ return results
« no previous file with comments | « no previous file | tools/metrics/histograms/update_histogram_enum.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698