| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Extract UserMetrics "actions" strings from the Chrome source. | 6 """Extract UserMetrics "actions" strings from the Chrome source. |
| 7 | 7 |
| 8 This program generates the list of known actions we expect to see in the | 8 This program generates the list of known actions we expect to see in the |
| 9 user behavior logs. It walks the Chrome source, looking for calls to | 9 user behavior logs. It walks the Chrome source, looking for calls to |
| 10 UserMetrics functions, extracting actions and warning on improper calls, | 10 UserMetrics functions, extracting actions and warning on improper calls, |
| 11 as well as generating the lists of possible actions in situations where | 11 as well as generating the lists of possible actions in situations where |
| 12 there are many possible actions. | 12 there are many possible actions. |
| 13 | 13 |
| 14 See also: | 14 See also: |
| 15 chrome/browser/user_metrics.h | 15 content/browser/user_metrics.h |
| 16 http://wiki.corp.google.com/twiki/bin/view/Main/ChromeUserExperienceMetrics | 16 http://wiki.corp.google.com/twiki/bin/view/Main/ChromeUserExperienceMetrics |
| 17 | 17 |
| 18 If run with a "--hash" argument, chromeactions.txt will be updated. | 18 If run with a "--hash" argument, chromeactions.txt will be updated. |
| 19 """ | 19 """ |
| 20 | 20 |
| 21 __author__ = 'evanm (Evan Martin)' | 21 __author__ = 'evanm (Evan Martin)' |
| 22 | 22 |
| 23 import hashlib | 23 import hashlib |
| 24 from HTMLParser import HTMLParser | 24 from HTMLParser import HTMLParser |
| 25 import os | 25 import os |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 324 |
| 325 def AddLiteralActions(actions): | 325 def AddLiteralActions(actions): |
| 326 """Add literal actions specified via calls to UserMetrics functions. | 326 """Add literal actions specified via calls to UserMetrics functions. |
| 327 | 327 |
| 328 Arguments: | 328 Arguments: |
| 329 actions: set of actions to add to. | 329 actions: set of actions to add to. |
| 330 """ | 330 """ |
| 331 EXTENSIONS = ('.cc', '.mm', '.c', '.m') | 331 EXTENSIONS = ('.cc', '.mm', '.c', '.m') |
| 332 | 332 |
| 333 # Walk the source tree to process all .cc files. | 333 # Walk the source tree to process all .cc files. |
| 334 chrome_root = os.path.join(path_utils.ScriptDir(), '..') | 334 chrome_root = os.path.normpath(os.path.join(path_utils.ScriptDir(), '..')) |
| 335 WalkDirectory(chrome_root, actions, EXTENSIONS, GrepForActions) | 335 WalkDirectory(chrome_root, actions, EXTENSIONS, GrepForActions) |
| 336 content_root = os.path.join(path_utils.ScriptDir(), '..', '..', 'content') | 336 content_root = os.path.normpath(os.path.join(path_utils.ScriptDir(), |
| 337 '..', '..', 'content')) |
| 337 WalkDirectory(content_root, actions, EXTENSIONS, GrepForActions) | 338 WalkDirectory(content_root, actions, EXTENSIONS, GrepForActions) |
| 338 webkit_root = os.path.join(path_utils.ScriptDir(), '..', '..', 'webkit') | 339 webkit_root = os.path.normpath(os.path.join(path_utils.ScriptDir(), |
| 340 '..', '..', 'webkit')) |
| 339 WalkDirectory(os.path.join(webkit_root, 'glue'), actions, EXTENSIONS, | 341 WalkDirectory(os.path.join(webkit_root, 'glue'), actions, EXTENSIONS, |
| 340 GrepForActions) | 342 GrepForActions) |
| 341 WalkDirectory(os.path.join(webkit_root, 'port'), actions, EXTENSIONS, | 343 WalkDirectory(os.path.join(webkit_root, 'port'), actions, EXTENSIONS, |
| 342 GrepForActions) | 344 GrepForActions) |
| 343 | 345 |
| 344 def AddWebUIActions(actions): | 346 def AddWebUIActions(actions): |
| 345 """Add user actions defined in WebUI files. | 347 """Add user actions defined in WebUI files. |
| 346 | 348 |
| 347 Arguments: | 349 Arguments: |
| 348 actions: set of actions to add to. | 350 actions: set of actions to add to. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 hash.update(action) | 415 hash.update(action) |
| 414 print >>f, '0x%s\t%s' % (hash.hexdigest()[:16], action) | 416 print >>f, '0x%s\t%s' % (hash.hexdigest()[:16], action) |
| 415 else: | 417 else: |
| 416 print action | 418 print action |
| 417 | 419 |
| 418 if hash_output: | 420 if hash_output: |
| 419 print "Done. Do not forget to add chromeactions.txt to your changelist" | 421 print "Done. Do not forget to add chromeactions.txt to your changelist" |
| 420 | 422 |
| 421 if '__main__' == __name__: | 423 if '__main__' == __name__: |
| 422 main(sys.argv) | 424 main(sys.argv) |
| OLD | NEW |