| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 urllib2 | 5 import urllib2 |
| 6 import httplib | 6 import httplib |
| 7 import socket | 7 import socket |
| 8 import json | 8 import json |
| 9 import re | 9 import re |
| 10 import sys | 10 import sys |
| 11 | 11 |
| 12 from telemetry.core import util | 12 from telemetry.core import util |
| 13 from telemetry.core import exceptions | 13 from telemetry.core import exceptions |
| 14 from telemetry.core import user_agent | 14 from telemetry.core import user_agent |
| 15 from telemetry.core import web_contents |
| 15 from telemetry.core import wpr_modes | 16 from telemetry.core import wpr_modes |
| 16 from telemetry.core import wpr_server | 17 from telemetry.core import wpr_server |
| 17 from telemetry.core.chrome import extension_dict_backend | 18 from telemetry.core.chrome import extension_dict_backend |
| 18 from telemetry.core.chrome import tab_list_backend | 19 from telemetry.core.chrome import tab_list_backend |
| 19 from telemetry.core.chrome import tracing_backend | 20 from telemetry.core.chrome import tracing_backend |
| 20 from telemetry.core.chrome import misc_web_contents_backend | 21 from telemetry.core.chrome import misc_web_contents_backend |
| 21 from telemetry.unittest import options_for_unittests | 22 from telemetry.unittest import options_for_unittests |
| 22 | 23 |
| 23 class ExtensionsNotSupportedException(Exception): | 24 class ExtensionsNotSupportedException(Exception): |
| 24 pass | 25 pass |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 return self._chrome_branch_number | 195 return self._chrome_branch_number |
| 195 | 196 |
| 196 @property | 197 @property |
| 197 def supports_tab_control(self): | 198 def supports_tab_control(self): |
| 198 return self._chrome_branch_number >= 1303 | 199 return self._chrome_branch_number >= 1303 |
| 199 | 200 |
| 200 @property | 201 @property |
| 201 def supports_tracing(self): | 202 def supports_tracing(self): |
| 202 return self.is_content_shell or self._chrome_branch_number >= 1385 | 203 return self.is_content_shell or self._chrome_branch_number >= 1385 |
| 203 | 204 |
| 204 def StartTracing(self, custom_categories=None): | 205 def StartTracing(self, custom_categories=None, |
| 206 timeout=web_contents.DEFAULT_WEB_CONTENTS_TIMEOUT): |
| 205 """ custom_categories is an optional string containing a list of | 207 """ custom_categories is an optional string containing a list of |
| 206 comma separated categories that will be traced instead of the | 208 comma separated categories that will be traced instead of the |
| 207 default category set. Example: use | 209 default category set. Example: use |
| 208 "webkit,cc,disabled-by-default-cc.debug" to trace only those three | 210 "webkit,cc,disabled-by-default-cc.debug" to trace only those three |
| 209 event categories. | 211 event categories. |
| 210 """ | 212 """ |
| 211 if self._tracing_backend is None: | 213 if self._tracing_backend is None: |
| 212 self._tracing_backend = tracing_backend.TracingBackend(self._port) | 214 self._tracing_backend = tracing_backend.TracingBackend(self._port) |
| 213 self._tracing_backend.BeginTracing(custom_categories) | 215 self._tracing_backend.BeginTracing(custom_categories, timeout) |
| 214 | 216 |
| 215 def StopTracing(self): | 217 def StopTracing(self): |
| 216 self._tracing_backend.EndTracing() | 218 self._tracing_backend.EndTracing() |
| 217 | 219 |
| 218 def GetTraceResultAndReset(self): | 220 def GetTraceResultAndReset(self): |
| 219 return self._tracing_backend.GetTraceResultAndReset() | 221 return self._tracing_backend.GetTraceResultAndReset() |
| 220 | 222 |
| 221 def GetProcessName(self, cmd_line): | 223 def GetProcessName(self, cmd_line): |
| 222 """Returns a user-friendly name for the process of the given |cmd_line|.""" | 224 """Returns a user-friendly name for the process of the given |cmd_line|.""" |
| 223 if 'nacl_helper_bootstrap' in cmd_line: | 225 if 'nacl_helper_bootstrap' in cmd_line: |
| (...skipping 26 matching lines...) Expand all Loading... |
| 250 def __init__(self, *port_pairs): | 252 def __init__(self, *port_pairs): |
| 251 self._host_port = port_pairs[0].local_port | 253 self._host_port = port_pairs[0].local_port |
| 252 | 254 |
| 253 @property | 255 @property |
| 254 def url(self): | 256 def url(self): |
| 255 assert self._host_port | 257 assert self._host_port |
| 256 return 'http://127.0.0.1:%i' % self._host_port | 258 return 'http://127.0.0.1:%i' % self._host_port |
| 257 | 259 |
| 258 def Close(self): | 260 def Close(self): |
| 259 self._host_port = None | 261 self._host_port = None |
| OLD | NEW |