diff options
author | davidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-29 16:56:21 +0000 |
---|---|---|
committer | davidben@chromium.org <davidben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-29 16:56:21 +0000 |
commit | f88f20bb8ccea880db1700008e8cc15337c84247 (patch) | |
tree | b8dfa914085eae89dd7045b437d7d9f40c5c796b | |
parent | 5a43b168231c7ed97f3f1862abaac2eb139f716b (diff) | |
download | chromium_src-f88f20bb8ccea880db1700008e8cc15337c84247.zip chromium_src-f88f20bb8ccea880db1700008e8cc15337c84247.tar.gz chromium_src-f88f20bb8ccea880db1700008e8cc15337c84247.tar.bz2 |
Add update_net_error_codes.py script for histograms.xml.
Use it to update the NetErrorCodes enum list in histograms.xml
BUG=none
Review URL: https://codereview.chromium.org/305713002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273502 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | tools/metrics/histograms/histograms.xml | 28 | ||||
-rw-r--r-- | tools/metrics/histograms/update_histogram_enum.py | 58 | ||||
-rwxr-xr-x | tools/metrics/histograms/update_net_error_codes.py | 50 |
3 files changed, 104 insertions, 32 deletions
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 1ab8411..a0891c7 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -38903,6 +38903,8 @@ Therefore, the affected-histogram name has to have at least one dot in it. </enum> <enum name="NetErrorCodes" type="int"> +<!-- Generated from ../../../net/base/net_error_list.h --> + <int value="0" label="OK"/> <int value="1" label="IO_PENDING"/> <int value="2" label="FAILED"/> @@ -38926,6 +38928,8 @@ Therefore, the affected-histogram name has to have at least one dot in it. <int value="20" label="BLOCKED_BY_CLIENT"/> <int value="21" label="NETWORK_CHANGED"/> <int value="22" label="BLOCKED_BY_ADMINISTRATOR"/> + <int value="23" label="SOCKET_IS_CONNECTED"/> + <int value="24" label="BLOCKED_ENROLLMENT_CHECK_PENDING"/> <int value="100" label="CONNECTION_CLOSED"/> <int value="101" label="CONNECTION_RESET"/> <int value="102" label="CONNECTION_REFUSED"/> @@ -38969,7 +38973,7 @@ Therefore, the affected-histogram name has to have at least one dot in it. <int value="140" label="HTTPS_PROXY_TUNNEL_RESPONSE"/> <int value="141" label="SSL_CLIENT_AUTH_SIGNATURE_FAILED"/> <int value="142" label="MSG_TOO_BIG"/> - <int value="143" label="KASPERSKY_ANTI_VIRUS_SSL_INTERCEPTION"/> + <int value="143" label="SPDY_SESSION_ALREADY_EXISTS"/> <int value="144" label="LIMIT_VIOLATION"/> <int value="145" label="WS_PROTOCOL_ERROR"/> <int value="146" label="PROTOCOL_SWITCHED"/> @@ -38979,6 +38983,17 @@ Therefore, the affected-histogram name has to have at least one dot in it. <int value="150" label="SSL_PINNED_KEY_NOT_IN_CERT_CHAIN"/> <int value="151" label="CLIENT_AUTH_CERT_TYPE_UNSUPPORTED"/> <int value="152" label="ORIGIN_BOUND_CERT_GENERATION_TYPE_MISMATCH"/> + <int value="153" label="SSL_DECRYPT_ERROR_ALERT"/> + <int value="154" label="WS_THROTTLE_QUEUE_TOO_LARGE"/> + <int value="155" label="TOO_MANY_SOCKET_STREAMS"/> + <int value="156" label="SSL_SERVER_CERT_CHANGED"/> + <int value="157" label="SSL_INAPPROPRIATE_FALLBACK"/> + <int value="158" label="CT_NO_SCTS_VERIFIED_OK"/> + <int value="159" label="SSL_UNRECOGNIZED_NAME_ALERT"/> + <int value="160" label="SOCKET_SET_RECEIVE_BUFFER_SIZE_ERROR"/> + <int value="161" label="SOCKET_SET_SEND_BUFFER_SIZE_ERROR"/> + <int value="162" label="SOCKET_RECEIVE_BUFFER_SIZE_UNCHANGEABLE"/> + <int value="163" label="SOCKET_SEND_BUFFER_SIZE_UNCHANGEABLE"/> <int value="200" label="CERT_COMMON_NAME_INVALID"/> <int value="201" label="CERT_DATE_INVALID"/> <int value="202" label="CERT_AUTHORITY_INVALID"/> @@ -38991,6 +39006,8 @@ Therefore, the affected-histogram name has to have at least one dot in it. <int value="209" label="CERT_NOT_IN_DNS"/> <int value="210" label="CERT_NON_UNIQUE_NAME"/> <int value="211" label="CERT_WEAK_KEY"/> + <int value="212" label="CERT_NAME_CONSTRAINT_VIOLATION"/> + <int value="213" label="CERT_END"/> <int value="300" label="INVALID_URL"/> <int value="301" label="DISALLOWED_URL_SCHEME"/> <int value="302" label="UNKNOWN_URL_SCHEME"/> @@ -39035,6 +39052,9 @@ Therefore, the affected-histogram name has to have at least one dot in it. <int value="355" label="INCOMPLETE_CHUNKED_ENCODING"/> <int value="356" label="QUIC_PROTOCOL_ERROR"/> <int value="357" label="RESPONSE_HEADERS_TRUNCATED"/> + <int value="358" label="QUIC_HANDSHAKE_FAILED"/> + <int value="359" label="REQUEST_FOR_SECURE_RESOURCE_OVER_INSECURE_QUIC"/> + <int value="360" label="SPDY_INADEQUATE_TRANSPORT_SECURITY"/> <int value="400" label="CACHE_MISS"/> <int value="401" label="CACHE_READ_FAILURE"/> <int value="402" label="CACHE_WRITE_FAILURE"/> @@ -39042,8 +39062,8 @@ Therefore, the affected-histogram name has to have at least one dot in it. <int value="404" label="CACHE_OPEN_FAILURE"/> <int value="405" label="CACHE_CREATE_FAILURE"/> <int value="406" label="CACHE_RACE"/> - <int value="407" label="CACHE_CACHE_CHECKSUM_READ_FAILURE"/> - <int value="408" label="CACHE_CACHE_CHECKSUM_MISMATCH"/> + <int value="407" label="CACHE_CHECKSUM_READ_FAILURE"/> + <int value="408" label="CACHE_CHECKSUM_MISMATCH"/> <int value="501" label="INSECURE_RESPONSE"/> <int value="502" label="NO_PRIVATE_KEY_FOR_CERT"/> <int value="503" label="ADD_USER_CERT_FAILED"/> @@ -39066,6 +39086,8 @@ Therefore, the affected-histogram name has to have at least one dot in it. <int value="710" label="KEY_GENERATION_FAILED"/> <int value="711" label="ORIGIN_BOUND_CERT_GENERATION_FAILED"/> <int value="712" label="PRIVATE_KEY_EXPORT_FAILED"/> + <int value="713" label="SELF_SIGNED_CERT_GENERATION_FAILED"/> + <int value="714" label="CERT_DATABASE_CHANGED"/> <int value="800" label="DNS_MALFORMED_RESPONSE"/> <int value="801" label="DNS_SERVER_REQUIRES_TCP"/> <int value="802" label="DNS_SERVER_FAILED"/> diff --git a/tools/metrics/histograms/update_histogram_enum.py b/tools/metrics/histograms/update_histogram_enum.py index 60b56f9..98d70ac 100644 --- a/tools/metrics/histograms/update_histogram_enum.py +++ b/tools/metrics/histograms/update_histogram_enum.py @@ -32,8 +32,8 @@ def Log(message): def ReadHistogramValues(filename, start_marker, end_marker): - """Reads in values from |filename|, returning a list of (label, value) pairs - corresponding to the enum framed by |start_marker| and |end_marker|. + """Reads in values from |filename|, returning a dictionary mapping value to + label corresponding to the enum framed by |start_marker| and |end_marker|. """ # Read the file as a list of lines with open(filename) as f: @@ -96,44 +96,44 @@ def UpdateHistogramDefinitions(histogram_enum_name, source_enum_values, else: raise UserError('No {0} enum node found'.format(name)) - new_children = [] + new_item_nodes = {} + new_comments = [] # Add a "Generated from (...)" comment. - new_children.append( + new_comments.append( document.createComment(' Generated from {0} '.format(source_enum_path))) - # Scan existing nodes in |enum_node| and build |new_children|. - # - For each int node in |enum_node|, if there is a corresponding entry in - # |source_enum_values|, drop the existing node and add a node newly created - # from |source_enum_values| to |new_children|. - # - Drop existing "Generated from (...)" comment in |enum_node|. - # - Copy anything else. + # Create item nodes for each of the enum values. + for value, label in source_enum_values.iteritems(): + new_item_nodes[value] = CreateEnumItemNode(document, value, label) + + # Scan existing nodes in |enum_node| for old values and preserve them. + # - Preserve comments other than the 'Generated from' comment. NOTE: + # this does not preserve the order of the comments in relation to the + # old values. + # - Drop anything else. SOURCE_COMMENT_REGEX = re.compile('^ Generated from ') for child in enum_node.childNodes: if child.nodeName == 'int': value = int(child.attributes['value'].value) - if source_enum_values.has_key(value): - new_children.append( - CreateEnumItemNode(document, value, source_enum_values[value])) - del source_enum_values[value] - else: - new_children.append(child) - # Drop existing source comments if any. - elif (child.nodeType != minidom.Node.COMMENT_NODE or + if not source_enum_values.has_key(value): + new_item_nodes[value] = child + # Preserve existing non-generated comments. + elif (child.nodeType == minidom.Node.COMMENT_NODE and SOURCE_COMMENT_REGEX.match(child.data) is None): - new_children.append(child) - - # Add remaining entries i.e. new enum values, in the |source_enum_values| to - # the |new_children|. - for value in sorted(source_enum_values.iterkeys()): - new_children.append( - CreateEnumItemNode(document, value, source_enum_values[value])) + new_comments.append(child) - # Update |enum_node|. + # Update |enum_node|. First, remove everything existing. while enum_node.hasChildNodes(): enum_node.removeChild(enum_node.lastChild) - for child in new_children: - enum_node.appendChild(child) + + # Add comments at the top. + for comment in new_comments: + enum_node.appendChild(comment) + + # Add in the new enums. + for value in sorted(new_item_nodes.iterkeys()): + enum_node.appendChild(new_item_nodes[value]) def UpdateHistogramFromDict(histogram_enum_name, source_enum_values, @@ -182,4 +182,4 @@ def UpdateHistogramEnum(histogram_enum_name, source_enum_path, end_marker) UpdateHistogramFromDict(histogram_enum_name, source_enum_values, - source_enum_path)
\ No newline at end of file + source_enum_path) diff --git a/tools/metrics/histograms/update_net_error_codes.py b/tools/metrics/histograms/update_net_error_codes.py new file mode 100755 index 0000000..bfb3bcf --- /dev/null +++ b/tools/metrics/histograms/update_net_error_codes.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# Copyright 2014 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. + +"""Updates NetErrorCodes enum in histograms.xml file with values read + from net_error_list.h. + +If the file was pretty-printed, the updated version is pretty-printed too. +""" + +import os.path +import re +import sys + +sys.path.append(os.path.join(os.path.dirname(__file__), '..', 'common')) +from update_histogram_enum import UpdateHistogramFromDict + +NET_ERROR_LIST_PATH = '../../../net/base/net_error_list.h' + +def ReadNetErrorCodes(filename): + """Reads in values from net_error_list.h, returning a dictionary mapping + error code to error name. + """ + # Read the file as a list of lines + with open(filename) as f: + content = f.readlines() + + ERROR_REGEX = re.compile(r'^NET_ERROR\(([\w]+), -([0-9]+)\)') + + # Parse out lines that are net errors. + errors = {} + for line in content: + m = ERROR_REGEX.match(line) + if m: + errors[int(m.group(2))] = m.group(1) + return errors + +def main(): + if len(sys.argv) > 1: + print >>sys.stderr, 'No arguments expected!' + sys.stderr.write(__doc__) + sys.exit(1) + + UpdateHistogramFromDict( + 'NetErrorCodes', ReadNetErrorCodes(NET_ERROR_LIST_PATH), + NET_ERROR_LIST_PATH) + +if __name__ == '__main__': + main() |