Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ppapi / PRESUBMIT.py
index 46038fb..4a71f49 100644 (file)
@@ -146,6 +146,38 @@ def CheckUpdatedNaClSDK(input_api, output_api):
                         'PPAPI Interface modified without updating NaCl SDK.',
                         output_api)
 
+# Verify that changes to ppapi/thunk/interfaces_* files have a corresponding
+# change to tools/metrics/histograms/histograms.xml for UMA tracking.
+def CheckHistogramXml(input_api, output_api):
+  # We can't use input_api.LocalPaths() here because we need to know about
+  # changes outside of ppapi/. See tools/depot_tools/presubmit_support.py for
+  # details on input_api.
+  files = input_api.change.AffectedFiles()
+
+  INTERFACE_FILES = ('ppapi/thunk/interfaces_legacy.h',
+                     'ppapi/thunk/interfaces_ppb_private_flash.h',
+                     'ppapi/thunk/interfaces_ppb_private.h',
+                     'ppapi/thunk/interfaces_ppb_private_no_permissions.h',
+                     'ppapi/thunk/interfaces_ppb_public_dev_channel.h',
+                     'ppapi/thunk/interfaces_ppb_public_dev.h',
+                     'ppapi/thunk/interfaces_ppb_public_stable.h')
+  HISTOGRAM_XML_FILE = 'tools/metrics/histograms/histograms.xml'
+  interface_changes = []
+  has_histogram_xml_change = False
+  for filename in files:
+    path = filename.LocalPath()
+    if path in INTERFACE_FILES:
+      interface_changes.append(path)
+    if path == HISTOGRAM_XML_FILE:
+      has_histogram_xml_change = True
+
+  if interface_changes and not has_histogram_xml_change:
+    return [output_api.PresubmitPromptWarning(
+        'Missing change to tools/metrics/histograms/histograms.xml.\n' +
+        'Run pepper_hash_for_uma to make get values for new interfaces.\n' +
+        'Interface changes:\n' + '\n'.join(interface_changes))]
+  return []
+
 def CheckChange(input_api, output_api):
   results = []
 
@@ -157,16 +189,27 @@ def CheckChange(input_api, output_api):
 
   results.extend(CheckUpdatedNaClSDK(input_api, output_api))
 
+  results.extend(CheckHistogramXml(input_api, output_api))
+
   # Verify all modified *.idl have a matching *.h
   files = input_api.LocalPaths()
   h_files = []
   idl_files = []
   generators_changed = False
 
+  # These are autogenerated by the command buffer generator, they don't go
+  # through idl.
+  whitelist = ['ppb_opengles2', 'ppb_opengles2ext_dev']
+
+  # The PDF interface is hand-written.
+  whitelist += ['ppb_pdf', 'ppp_pdf']
+
   # Find all relevant .h and .idl files.
   for filename in files:
     name, ext = os.path.splitext(filename)
     name_parts = name.split(os.sep)
+    if name_parts[-1] in whitelist:
+      continue
     if name_parts[0:2] == ['ppapi', 'c'] and ext == '.h':
       h_files.append('/'.join(name_parts[2:]))
     elif name_parts[0:2] == ['ppapi', 'api'] and ext == '.idl':