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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 match = action_re.search(line) | 162 match = action_re.search(line) |
163 if match: # Plain call to RecordAction | 163 if match: # Plain call to RecordAction |
164 actions.add(match.group(1)) | 164 actions.add(match.group(1)) |
165 | 165 |
166 def AddClosedSourceActions(actions): | 166 def AddClosedSourceActions(actions): |
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') | |
173 actions.add('PDF.FitToHeightButton') | 172 actions.add('PDF.FitToHeightButton') |
174 actions.add('PDF.FitToWidthButton') | 173 actions.add('PDF.FitToWidthButton') |
175 actions.add('PDF.LoadFailure') | 174 actions.add('PDF.LoadFailure') |
176 actions.add('PDF.LoadSuccess') | 175 actions.add('PDF.LoadSuccess') |
177 actions.add('PDF.PreviewDocumentLoadFailure') | 176 actions.add('PDF.PreviewDocumentLoadFailure') |
| 177 actions.add('PDF.PrintButton') |
| 178 actions.add('PDF.PrintPage') |
| 179 actions.add('PDF.SaveButton') |
178 actions.add('PDF.ZoomFromBrowser') | 180 actions.add('PDF.ZoomFromBrowser') |
| 181 actions.add('PDF.ZoomInButton') |
179 actions.add('PDF.ZoomOutButton') | 182 actions.add('PDF.ZoomOutButton') |
180 actions.add('PDF.ZoomInButton') | 183 actions.add('PDF_Unsupported_3D') |
| 184 actions.add('PDF_Unsupported_Attachment') |
| 185 actions.add('PDF_Unsupported_Bookmarks') |
| 186 actions.add('PDF_Unsupported_Digital_Signature') |
| 187 actions.add('PDF_Unsupported_Movie') |
| 188 actions.add('PDF_Unsupported_Portfolios_Packages') |
181 actions.add('PDF_Unsupported_Rights_Management') | 189 actions.add('PDF_Unsupported_Rights_Management') |
| 190 actions.add('PDF_Unsupported_Screen') |
| 191 actions.add('PDF_Unsupported_Shared_Form') |
| 192 actions.add('PDF_Unsupported_Shared_Review') |
| 193 actions.add('PDF_Unsupported_Sound') |
182 actions.add('PDF_Unsupported_XFA') | 194 actions.add('PDF_Unsupported_XFA') |
183 actions.add('PDF_Unsupported_3D') | |
184 actions.add('PDF_Unsupported_Movie') | |
185 actions.add('PDF_Unsupported_Sound') | |
186 actions.add('PDF_Unsupported_Screen') | |
187 actions.add('PDF_Unsupported_Portfolios_Packages') | |
188 actions.add('PDF_Unsupported_Attachment') | |
189 actions.add('PDF_Unsupported_Digital_Signature') | |
190 actions.add('PDF_Unsupported_Shared_Review') | |
191 actions.add('PDF_Unsupported_Shared_Form') | |
192 actions.add('PDF_Unsupported_Bookmarks') | |
193 | 195 |
194 def AddAndroidActions(actions): | 196 def AddAndroidActions(actions): |
195 """Add actions that are used by Chrome on Android. | 197 """Add actions that are used by Chrome on Android. |
196 | 198 |
197 Arguments | 199 Arguments |
198 actions: set of actions to add to. | 200 actions: set of actions to add to. |
199 """ | 201 """ |
200 actions.add('DataReductionProxy_PromoDisplayed'); | 202 actions.add('DataReductionProxy_PromoDisplayed'); |
201 actions.add('DataReductionProxy_PromoLearnMore'); | 203 actions.add('DataReductionProxy_PromoLearnMore'); |
202 actions.add('DataReductionProxy_TurnedOn'); | 204 actions.add('DataReductionProxy_TurnedOn'); |
(...skipping 267 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\("([^"]*)') |
481 line_number = 0 | 483 action_re2 = re.compile( |
| 484 r'[^a-zA-Z]RenderThreadImpl::current\(\)->RecordUserMetrics\("([^"]*)') |
482 for line in open(path): | 485 for line in open(path): |
483 match = action_re.search(line) | 486 match = action_re.search(line) |
484 if match: # Plain call to RecordAction | 487 if match: # Call to RecordUserMetrics through Content API |
| 488 actions.add(match.group(1)) |
| 489 continue |
| 490 match = action_re2.search(line) |
| 491 if match: # Call to RecordUserMetrics inside Content |
485 actions.add(match.group(1)) | 492 actions.add(match.group(1)) |
486 | 493 |
487 def AddLiteralActions(actions): | 494 def AddLiteralActions(actions): |
488 """Add literal actions specified via calls to UserMetrics functions. | 495 """Add literal actions specified via calls to UserMetrics functions. |
489 | 496 |
490 Arguments: | 497 Arguments: |
491 actions: set of actions to add to. | 498 actions: set of actions to add to. |
492 """ | 499 """ |
493 EXTENSIONS = ('.cc', '.mm', '.c', '.m') | 500 EXTENSIONS = ('.cc', '.mm', '.c', '.m') |
494 | 501 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
621 else: | 628 else: |
622 print action | 629 print action |
623 | 630 |
624 if hash_output: | 631 if hash_output: |
625 print "Done. Do not forget to add chromeactions.txt to your changelist" | 632 print "Done. Do not forget to add chromeactions.txt to your changelist" |
626 return 0 | 633 return 0 |
627 | 634 |
628 | 635 |
629 if '__main__' == __name__: | 636 if '__main__' == __name__: |
630 sys.exit(main(sys.argv)) | 637 sys.exit(main(sys.argv)) |
OLD | NEW |