| OLD | NEW |
| 1 # Copyright 2012 The Chromium Authors. All rights reserved. | 1 # Copyright 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import inspect | 5 import inspect |
| 6 import os | 6 import os |
| 7 import re | 7 import re |
| 8 import urlparse | 8 import urlparse |
| 9 | 9 |
| 10 _next_page_id = 0 | 10 _next_page_id = 0 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 def CanRunOnBrowser(self, browser_info): | 50 def CanRunOnBrowser(self, browser_info): |
| 51 """Override this to returns whether this page can be run on specific | 51 """Override this to returns whether this page can be run on specific |
| 52 browser. | 52 browser. |
| 53 | 53 |
| 54 Args: | 54 Args: |
| 55 browser_info: an instance of telemetry.core.browser_info.BrowserInfo | 55 browser_info: an instance of telemetry.core.browser_info.BrowserInfo |
| 56 """ | 56 """ |
| 57 assert browser_info | 57 assert browser_info |
| 58 return True | 58 return True |
| 59 | 59 |
| 60 def AsDict(self): |
| 61 """Converts a page object to a dict suitable for JSON output.""" |
| 62 d = { |
| 63 'id': self._id, |
| 64 'url': self._url, |
| 65 } |
| 66 if self._name: |
| 67 d['name'] = self._name |
| 68 return d |
| 69 |
| 60 @property | 70 @property |
| 61 def page_set(self): | 71 def page_set(self): |
| 62 return self._page_set | 72 return self._page_set |
| 63 | 73 |
| 64 @property | 74 @property |
| 65 def name(self): | 75 def name(self): |
| 66 return self._name | 76 return self._name |
| 67 | 77 |
| 68 @property | 78 @property |
| 69 def url(self): | 79 def url(self): |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 return self.name | 162 return self.name |
| 153 if not self.is_file: | 163 if not self.is_file: |
| 154 return self.url | 164 return self.url |
| 155 all_urls = [p.url.rstrip('/') for p in self.page_set if p.is_file] | 165 all_urls = [p.url.rstrip('/') for p in self.page_set if p.is_file] |
| 156 common_prefix = os.path.dirname(os.path.commonprefix(all_urls)) | 166 common_prefix = os.path.dirname(os.path.commonprefix(all_urls)) |
| 157 return self.url[len(common_prefix):].strip('/') | 167 return self.url[len(common_prefix):].strip('/') |
| 158 | 168 |
| 159 @property | 169 @property |
| 160 def archive_path(self): | 170 def archive_path(self): |
| 161 return self.page_set.WprFilePathForPage(self) | 171 return self.page_set.WprFilePathForPage(self) |
| OLD | NEW |