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

Unified Diff: chrome/tools/extract_actions.py

Issue 7558024: Add UMA metrics for blocked plugins. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 9 years, 4 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 | « chrome/tools/chromeactions.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/tools/extract_actions.py
diff --git a/chrome/tools/extract_actions.py b/chrome/tools/extract_actions.py
index 3b9cbcb7ca0d2e160f199f66f194b3aec6e255e4..03025ff052ed4f0de310c4f6d8b0ae876e71952a 100755
--- a/chrome/tools/extract_actions.py
+++ b/chrome/tools/extract_actions.py
@@ -305,6 +305,23 @@ def WalkDirectory(root_path, actions, extensions, callback):
if ext in extensions:
callback(os.path.join(path, file), actions)
+def GrepForMsgActions(path, actions):
+ """Grep a source file for ViewHostMsg_UserMetricsRecordAction.
+
+ Arguments:
+ path: path to the file
+ actions: set of actions to add to
+ """
+ # We look for the ViewHostMsg_UserMetricsRecordAction constructor.
+ # This should be on one line.
+ action_re = re.compile(
+ r'[^a-zA-Z]ViewHostMsg_UserMetricsRecordAction\("([^"]*)')
+ line_number = 0
+ for line in open(path):
+ match = action_re.search(line)
+ if match: # Plain call to RecordAction
+ actions.add(match.group(1))
+
def AddLiteralActions(actions):
"""Add literal actions specified via calls to UserMetrics functions.
@@ -334,6 +351,20 @@ def AddWebUIActions(actions):
'resources')
WalkDirectory(resources_root, actions, ('.html'), GrepForWebUIActions)
+def AddMsgActions(actions):
+ """Add user actions sent via ViewHostMsg_UserMetricsRecordAction.
+
+ Arguments:
+ actions: set of actions to add to.
+ """
+ EXTENSIONS = ('.cc', '.mm', '.c', '.m')
+
+ chrome_renderer_root = os.path.join(path_utils.ScriptDir(), '..', 'renderer')
+ content_renderer_root = os.path.join(path_utils.ScriptDir(), '..', '..',
+ 'content', 'renderer')
+ WalkDirectory(chrome_renderer_root, actions, EXTENSIONS, GrepForMsgActions)
+ WalkDirectory(content_renderer_root, actions, EXTENSIONS, GrepForMsgActions)
+
def main(argv):
if '--hash' in argv:
hash_output = True
@@ -361,6 +392,7 @@ def main(argv):
# AddWebKitEditorActions(actions)
AddAboutFlagsActions(actions)
AddWebUIActions(actions)
+ AddMsgActions(actions)
AddLiteralActions(actions)
« no previous file with comments | « chrome/tools/chromeactions.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698