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, |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 actions.add('Accel_BrightnessDown_F6') | 216 actions.add('Accel_BrightnessDown_F6') |
217 actions.add('Accel_BrightnessUp_F7') | 217 actions.add('Accel_BrightnessUp_F7') |
218 | 218 |
219 # Actions sent by Chrome OS update engine. | 219 # Actions sent by Chrome OS update engine. |
220 actions.add('Updater.ServerCertificateChanged') | 220 actions.add('Updater.ServerCertificateChanged') |
221 actions.add('Updater.ServerCertificateFailed') | 221 actions.add('Updater.ServerCertificateFailed') |
222 | 222 |
223 # Actions sent by Chrome OS cryptohome. | 223 # Actions sent by Chrome OS cryptohome. |
224 actions.add('Cryptohome.PKCS11InitFail') | 224 actions.add('Cryptohome.PKCS11InitFail') |
225 | 225 |
| 226 def AddExtensionActions(actions): |
| 227 """Add actions reported by extensions via chrome.experimental.metrics API. |
| 228 |
| 229 Arguments: |
| 230 actions: set of actions to add to. |
| 231 """ |
| 232 # Actions sent by Chrome OS File Browser. |
| 233 actions.add('FileBrowser.CreateNewFolder') |
| 234 |
226 def GrepForActions(path, actions): | 235 def GrepForActions(path, actions): |
227 """Grep a source file for calls to UserMetrics functions. | 236 """Grep a source file for calls to UserMetrics functions. |
228 | 237 |
229 Arguments: | 238 Arguments: |
230 path: path to the file | 239 path: path to the file |
231 actions: set of actions to add to | 240 actions: set of actions to add to |
232 """ | 241 """ |
233 global number_of_files_total | 242 global number_of_files_total |
234 number_of_files_total = number_of_files_total + 1 | 243 number_of_files_total = number_of_files_total + 1 |
235 # we look for the UserMetricsAction structure constructor | 244 # we look for the UserMetricsAction structure constructor |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
406 AddWebUIActions(actions) | 415 AddWebUIActions(actions) |
407 AddRendererActions(actions) | 416 AddRendererActions(actions) |
408 | 417 |
409 AddLiteralActions(actions) | 418 AddLiteralActions(actions) |
410 | 419 |
411 # print "Scanned {0} number of files".format(number_of_files_total) | 420 # print "Scanned {0} number of files".format(number_of_files_total) |
412 # print "Found {0} entries".format(len(actions)) | 421 # print "Found {0} entries".format(len(actions)) |
413 | 422 |
414 AddClosedSourceActions(actions) | 423 AddClosedSourceActions(actions) |
415 AddChromeOSActions(actions) | 424 AddChromeOSActions(actions) |
| 425 AddExtensionActions(actions) |
416 | 426 |
417 if hash_output: | 427 if hash_output: |
418 f = open(chromeactions_path, "w") | 428 f = open(chromeactions_path, "w") |
419 | 429 |
420 | 430 |
421 # Print out the actions as a sorted list. | 431 # Print out the actions as a sorted list. |
422 for action in sorted(actions): | 432 for action in sorted(actions): |
423 if hash_output: | 433 if hash_output: |
424 hash = hashlib.md5() | 434 hash = hashlib.md5() |
425 hash.update(action) | 435 hash.update(action) |
426 print >>f, '0x%s\t%s' % (hash.hexdigest()[:16], action) | 436 print >>f, '0x%s\t%s' % (hash.hexdigest()[:16], action) |
427 else: | 437 else: |
428 print action | 438 print action |
429 | 439 |
430 if hash_output: | 440 if hash_output: |
431 print "Done. Do not forget to add chromeactions.txt to your changelist" | 441 print "Done. Do not forget to add chromeactions.txt to your changelist" |
432 | 442 |
433 if '__main__' == __name__: | 443 if '__main__' == __name__: |
434 main(sys.argv) | 444 main(sys.argv) |
OLD | NEW |