OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Extract UserMetrics "actions" strings from the Chrome source. | 7 """Extract UserMetrics "actions" strings from the Chrome source. |
8 | 8 |
9 This program generates the list of known actions we expect to see in the | 9 This program generates the list of known actions we expect to see in the |
10 user behavior logs. It walks the Chrome source, looking for calls to | 10 user behavior logs. It walks the Chrome source, looking for calls to |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
167 """Add actions that are in code which is not checked out by default | 167 """Add actions that are in code which is not checked out by default |
168 | 168 |
169 Arguments | 169 Arguments |
170 actions: set of actions to add to. | 170 actions: set of actions to add to. |
171 """ | 171 """ |
172 actions.add('PDF.PrintPage') | 172 actions.add('PDF.PrintPage') |
173 actions.add('PDF.FitToHeightButton') | 173 actions.add('PDF.FitToHeightButton') |
174 actions.add('PDF.FitToWidthButton') | 174 actions.add('PDF.FitToWidthButton') |
175 actions.add('PDF.LoadFailure') | 175 actions.add('PDF.LoadFailure') |
176 actions.add('PDF.LoadSuccess') | 176 actions.add('PDF.LoadSuccess') |
177 actions.add('PDF.SaveButton') | |
178 actions.add('PDF.PrintButton') | |
Ilya Sherman
2013/09/14 03:07:30
nit: Please alphabetize (I know the list is alread
jam
2013/09/15 21:58:14
Done.
| |
177 actions.add('PDF.PreviewDocumentLoadFailure') | 179 actions.add('PDF.PreviewDocumentLoadFailure') |
178 actions.add('PDF.ZoomFromBrowser') | 180 actions.add('PDF.ZoomFromBrowser') |
179 actions.add('PDF.ZoomOutButton') | 181 actions.add('PDF.ZoomOutButton') |
180 actions.add('PDF.ZoomInButton') | 182 actions.add('PDF.ZoomInButton') |
181 actions.add('PDF_Unsupported_Rights_Management') | 183 actions.add('PDF_Unsupported_Rights_Management') |
182 actions.add('PDF_Unsupported_XFA') | 184 actions.add('PDF_Unsupported_XFA') |
183 actions.add('PDF_Unsupported_3D') | 185 actions.add('PDF_Unsupported_3D') |
184 actions.add('PDF_Unsupported_Movie') | 186 actions.add('PDF_Unsupported_Movie') |
185 actions.add('PDF_Unsupported_Sound') | 187 actions.add('PDF_Unsupported_Sound') |
186 actions.add('PDF_Unsupported_Screen') | 188 actions.add('PDF_Unsupported_Screen') |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 def GrepForRendererActions(path, actions): | 472 def GrepForRendererActions(path, actions): |
471 """Grep a source file for calls to RenderThread::RecordUserMetrics. | 473 """Grep a source file for calls to RenderThread::RecordUserMetrics. |
472 | 474 |
473 Arguments: | 475 Arguments: |
474 path: path to the file | 476 path: path to the file |
475 actions: set of actions to add to | 477 actions: set of actions to add to |
476 """ | 478 """ |
477 # We look for the ViewHostMsg_UserMetricsRecordAction constructor. | 479 # We look for the ViewHostMsg_UserMetricsRecordAction constructor. |
478 # This should be on one line. | 480 # This should be on one line. |
479 action_re = re.compile( | 481 action_re = re.compile( |
480 r'[^a-zA-Z]RenderThread::RecordUserMetrics\("([^"]*)') | 482 r'[^a-zA-Z]RenderThread::Get\(\)->RecordUserMetrics\("([^"]*)') |
483 action_re2 = re.compile( | |
484 r'[^a-zA-Z]RenderThreadImpl::current\(\)->RecordUserMetrics\("([^"]*)') | |
Ilya Sherman
2013/09/14 03:07:30
Hmm, why doesn't the RenderThread class use the Us
jam
2013/09/15 21:58:14
UserMetricsAction is used in the browser process,
Ilya Sherman
2013/09/16 19:50:03
Yes, I see that that's currently the case. My que
| |
481 line_number = 0 | 485 line_number = 0 |
Ilya Sherman
2013/09/14 03:07:30
As long as you're editing nearby code, let's get r
jam
2013/09/15 21:58:14
Done.
| |
482 for line in open(path): | 486 for line in open(path): |
483 match = action_re.search(line) | 487 match = action_re.search(line) |
484 if match: # Plain call to RecordAction | 488 if match: # Call to RecordUserMetrics through Content API |
489 actions.add(match.group(1)) | |
490 continue | |
491 match = action_re2.search(line) | |
492 if match: # Call to RecordUserMetrics inside Content | |
485 actions.add(match.group(1)) | 493 actions.add(match.group(1)) |
486 | 494 |
487 def AddLiteralActions(actions): | 495 def AddLiteralActions(actions): |
488 """Add literal actions specified via calls to UserMetrics functions. | 496 """Add literal actions specified via calls to UserMetrics functions. |
489 | 497 |
490 Arguments: | 498 Arguments: |
491 actions: set of actions to add to. | 499 actions: set of actions to add to. |
492 """ | 500 """ |
493 EXTENSIONS = ('.cc', '.mm', '.c', '.m') | 501 EXTENSIONS = ('.cc', '.mm', '.c', '.m') |
494 | 502 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
621 else: | 629 else: |
622 print action | 630 print action |
623 | 631 |
624 if hash_output: | 632 if hash_output: |
625 print "Done. Do not forget to add chromeactions.txt to your changelist" | 633 print "Done. Do not forget to add chromeactions.txt to your changelist" |
626 return 0 | 634 return 0 |
627 | 635 |
628 | 636 |
629 if '__main__' == __name__: | 637 if '__main__' == __name__: |
630 sys.exit(main(sys.argv)) | 638 sys.exit(main(sys.argv)) |
OLD | NEW |