| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 logging | 5 import logging |
| 6 import re | 6 import re |
| 7 import sys | 7 import sys |
| 8 | 8 |
| 9 from telemetry.core import exceptions | 9 from telemetry.core import exceptions |
| 10 from telemetry import decorators | 10 from telemetry import decorators |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 "console.timeEnd('" + backend.id + "');" + | 207 "console.timeEnd('" + backend.id + "');" + |
| 208 "console.time.toString().indexOf('[native code]') != -1;") | 208 "console.time.toString().indexOf('[native code]') != -1;") |
| 209 if not success: | 209 if not success: |
| 210 raise Exception('Page stomped on console.time') | 210 raise Exception('Page stomped on console.time') |
| 211 trace_data_builder.AddEventsTo( | 211 trace_data_builder.AddEventsTo( |
| 212 trace_data_module.TAB_ID_PART, [backend.id]) | 212 trace_data_module.TAB_ID_PART, [backend.id]) |
| 213 | 213 |
| 214 assert self._tracing_backend | 214 assert self._tracing_backend |
| 215 return self._tracing_backend.StopTracing(trace_data_builder, timeout) | 215 return self._tracing_backend.StopTracing(trace_data_builder, timeout) |
| 216 | 216 |
| 217 def DumpMemory(self, timeout=30): |
| 218 """Dumps memory. |
| 219 |
| 220 Returns: |
| 221 GUID of the generated dump if successful, None otherwise. |
| 222 |
| 223 Raises: |
| 224 TracingTimeoutException: If more than |timeout| seconds has passed |
| 225 since the last time any data is received. |
| 226 TracingUnrecoverableException: If there is a websocket error. |
| 227 TracingUnexpectedResponseException: If the response contains an error |
| 228 or does not contain the expected result. |
| 229 """ |
| 230 self._CreateTracingBackendIfNeeded() |
| 231 return self._tracing_backend.DumpMemory(timeout) |
| 232 |
| 217 | 233 |
| 218 class _DevToolsContextMapBackend(object): | 234 class _DevToolsContextMapBackend(object): |
| 219 def __init__(self, app_backend, devtools_client): | 235 def __init__(self, app_backend, devtools_client): |
| 220 self._app_backend = app_backend | 236 self._app_backend = app_backend |
| 221 self._devtools_client = devtools_client | 237 self._devtools_client = devtools_client |
| 222 self._contexts = None | 238 self._contexts = None |
| 223 self._inspector_backends_dict = {} | 239 self._inspector_backends_dict = {} |
| 224 | 240 |
| 225 @property | 241 @property |
| 226 def contexts(self): | 242 def contexts(self): |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 # If an InspectorBackend is already created for the tab, | 284 # If an InspectorBackend is already created for the tab, |
| 269 # webSocketDebuggerUrl will be missing, and this is expected. | 285 # webSocketDebuggerUrl will be missing, and this is expected. |
| 270 context_id = context['id'] | 286 context_id = context['id'] |
| 271 if context_id not in self._inspector_backends_dict: | 287 if context_id not in self._inspector_backends_dict: |
| 272 if 'webSocketDebuggerUrl' not in context: | 288 if 'webSocketDebuggerUrl' not in context: |
| 273 logging.debug('webSocketDebuggerUrl missing, removing %s' | 289 logging.debug('webSocketDebuggerUrl missing, removing %s' |
| 274 % context_id) | 290 % context_id) |
| 275 continue | 291 continue |
| 276 valid_contexts.append(context) | 292 valid_contexts.append(context) |
| 277 self._contexts = valid_contexts | 293 self._contexts = valid_contexts |
| OLD | NEW |