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

Unified Diff: tools/metrics/histograms/extract_histograms.py

Issue 1020313002: Add support for obsoleting individual histogram suffixes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/metrics/histograms/extract_histograms.py
diff --git a/tools/metrics/histograms/extract_histograms.py b/tools/metrics/histograms/extract_histograms.py
index 9cacd89d7f6306e36bfb3cd2e7bf0b1008cfc907..b8e49ad310e0a73b51870bf3f8d2693928cf87ed 100644
--- a/tools/metrics/histograms/extract_histograms.py
+++ b/tools/metrics/histograms/extract_histograms.py
@@ -291,6 +291,16 @@ def _ExtractHistogramsFromXmlTree(tree, enums):
return histograms, have_errors
+# Finds an <obsolete> node amongst |node|'s immediate children and returns its
+# content as a string. Returns None if no such node exists.
+def _GetObsoleteReason(node):
+ for child in node.childNodes:
+ if child.localName == 'obsolete':
+ # There can be at most 1 obsolete element per node.
+ return _JoinChildNodes(child)
+ return None
+
+
def _UpdateHistogramsWithSuffixes(tree, histograms):
"""Process <histogram_suffixes> tags and combine with affected histograms.
@@ -355,11 +365,9 @@ def _UpdateHistogramsWithSuffixes(tree, histograms):
have_errors = True
continue
- obsolete_nodes = histogram_suffixes.getElementsByTagName('obsolete')
- obsolete_reason = None
- if obsolete_nodes:
- # There can be at most 1 obsolete element per histogram_suffixes node
- obsolete_reason = _JoinChildNodes(obsolete_nodes[0])
+ # If the suffix group has an obsolete tag, all suffixes it generates inherit
+ # its reason.
+ group_obsolete_reason = _GetObsoleteReason(histogram_suffixes)
name = histogram_suffixes.getAttribute('name')
suffix_nodes = histogram_suffixes.getElementsByTagName(suffix_tag)
@@ -416,6 +424,13 @@ def _UpdateHistogramsWithSuffixes(tree, histograms):
if owners:
histograms[new_histogram_name]['owners'] = owners
+ # If a suffix has an obsolete node, it's marked as obsolete for the
+ # specified reason, overwriting its group's obsoletion reason if the
+ # group itself was obsolete as well.
+ obsolete_reason = _GetObsoleteReason(suffix)
+ if not obsolete_reason:
+ obsolete_reason = group_obsolete_reason
+
# If the suffix has an obsolete tag, all histograms it generates
# inherit it.
if obsolete_reason:
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698