diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 18:14:28 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-23 18:14:28 +0000 |
commit | 89622004872be7f7ddaa24fa1694f76c7b9539b6 (patch) | |
tree | 81b8a42c7649c8cbca99d04305470ccbc1fe61fa /chrome/tools | |
parent | b7544eef7b81458a88597419eed6617c41e6d3dc (diff) | |
download | chromium_src-89622004872be7f7ddaa24fa1694f76c7b9539b6.zip chromium_src-89622004872be7f7ddaa24fa1694f76c7b9539b6.tar.gz chromium_src-89622004872be7f7ddaa24fa1694f76c7b9539b6.tar.bz2 |
UMA cleanup. Replacing calls to RecordAction(char*) to use a new structure.
That way it is easier to keep track of those constants in reporting tools.
TEST=Covered with standard ui tests
Patch by Frank Mantek <fmantek@google.com>.
Review URL: http://codereview.chromium.org/811005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/tools')
-rwxr-xr-x | chrome/tools/extract_actions.py | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/chrome/tools/extract_actions.py b/chrome/tools/extract_actions.py index 8b6a9bf..a2bb529 100755 --- a/chrome/tools/extract_actions.py +++ b/chrome/tools/extract_actions.py @@ -37,8 +37,11 @@ KNOWN_COMPUTED_USERS = [ 'render_view_host.cc', # called using webkit identifiers 'user_metrics.cc', # method definition 'new_tab_ui.cc', # most visited clicks 1-9 + 'extension_metrics_module.cc', # extensions hook for user metrics ] +number_of_files_total = 0 + def AddComputedActions(actions): """Add computed actions to the actions list. @@ -67,7 +70,7 @@ def AddWebKitEditorActions(actions): action_re = re.compile(r'''\{ [\w']+, +\w+, +"(.*)" +\},''') editor_file = os.path.join(path_utils.ScriptDir(), '..', '..', 'webkit', - 'glue', 'editor_client_impl.cc') + 'api', 'src','EditorClientImpl.cc') for line in open(editor_file): match = action_re.search(line) if match: # Plain call to RecordAction @@ -80,22 +83,23 @@ def GrepForActions(path, actions): path: path to the file actions: set of actions to add to """ - - action_re = re.compile(r'[> ]UserMetrics:?:?RecordAction\(L"(.*)"') - other_action_re = re.compile(r'[> ]UserMetrics:?:?RecordAction\(') + global number_of_files_total + number_of_files_total = number_of_files_total + 1 + # we look for the UserMetricsAction structur constructor + # this should be on one line + action_re = re.compile(r'UserMetricsAction\("([^"]*)') computed_action_re = re.compile(r'UserMetrics::RecordComputedAction') + line_number = 0 for line in open(path): + line_number = line_number + 1 match = action_re.search(line) if match: # Plain call to RecordAction actions.add(match.group(1)) - elif other_action_re.search(line): - # Warn if this file shouldn't be mentioning RecordAction. - if os.path.basename(path) != 'user_metrics.cc': - print >>sys.stderr, 'WARNING: %s has funny RecordAction' % path elif computed_action_re.search(line): # Warn if this file shouldn't be calling RecordComputedAction. if os.path.basename(path) not in KNOWN_COMPUTED_USERS: - print >>sys.stderr, 'WARNING: %s has RecordComputedAction' % path + print >>sys.stderr, 'WARNING: {0} has RecordComputedAction at {1}'.\ + format(path, line_number) def WalkDirectory(root_path, actions): for path, dirs, files in os.walk(root_path): @@ -103,13 +107,14 @@ def WalkDirectory(root_path, actions): dirs.remove('.svn') for file in files: ext = os.path.splitext(file)[1] - if ext == '.cc': + if ext in ('.cc', '.mm', '.c', '.m'): GrepForActions(os.path.join(path, file), actions) def main(argv): actions = set() AddComputedActions(actions) - AddWebKitEditorActions(actions) + # TODO(fmantek): bring back webkit editor actions. + # AddWebKitEditorActions(actions) # Walk the source tree to process all .cc files. chrome_root = os.path.join(path_utils.ScriptDir(), '..') @@ -118,6 +123,10 @@ def main(argv): WalkDirectory(os.path.join(webkit_root, 'glue'), actions) WalkDirectory(os.path.join(webkit_root, 'port'), actions) + # print "Scanned {0} number of files".format(number_of_files_total) + # print "Found {0} entries".format(len(actions)) + + # Print out the actions as a sorted list. for action in sorted(actions): print action |