Ejemplo n.º 1
0
 def _IterInspectorBackends(self):
     for client in chrome_tracing_devtools_manager.GetDevToolsClients(
             self._platform_backend):
         context_map = client.GetUpdatedInspectableContexts()
         for context in context_map.contexts:
             if context['type'] in ['iframe', 'page', 'webview']:
                 yield context_map.GetInspectorBackend(context['id'])
Ejemplo n.º 2
0
    def StopAgentTracing(self, trace_data_builder):
        if not self._trace_config:
            raise ChromeTracingStoppedError(
                'Tracing is not running on platform backend %s.' %
                self._platform_backend)

        if self.IsStartupTracingSupported(self._platform_backend):
            self._RemoveTraceConfigFile()

        # We get all DevTools clients including the stale ones, so that we get an
        # exception if there is a stale client. This is because we will potentially
        # lose data if there is a stale client.
        devtools_clients = (chrome_tracing_devtools_manager.GetDevToolsClients(
            self._platform_backend))
        raised_execption_messages = []
        for client in devtools_clients:
            try:
                client.StopChromeTracing(trace_data_builder)
            except Exception:
                raised_execption_messages.append(
                    'Error when trying to stop Chrome tracing on devtools at port %s:\n%s'
                    % (client.remote_port, ''.join(
                        traceback.format_exception(*sys.exc_info()))))

        if (self._trace_config.enable_android_graphics_memtrack
                and self._platform_backend.GetOSName() == 'android'):
            self._platform_backend.SetGraphicsMemoryTrackingEnabled(False)

        self._trace_config = None
        if raised_execption_messages:
            raise ChromeTracingStoppedError(
                'Exceptions raised when trying to stop Chrome devtool tracing:\n'
                + '\n'.join(raised_execption_messages))
Ejemplo n.º 3
0
    def StopAgentTracing(self):
        if not self._trace_config:
            raise ChromeTracingStoppedError(
                'Tracing is not running on platform backend %s.' %
                self._platform_backend)

        self._RemoveTraceConfigFile()

        # We get all DevTools clients including the stale ones, so that we get an
        # exception if there is a stale client. This is because we will potentially
        # lose data if there is a stale client.
        # TODO(crbug.com/1029812): Check if this actually works. It looks like the
        # call to GetActiveDevToolsClients in RecordClockSyncMarker would have
        # wiped out the stale clients anyway.
        devtools_clients = (chrome_tracing_devtools_manager.GetDevToolsClients(
            self._platform_backend))
        raised_exception_messages = []
        assert len(self._previously_responsive_devtools) == 0
        for client in devtools_clients:
            try:
                client.StopChromeTracing()
                self._previously_responsive_devtools.append(client)

            except Exception:  # pylint: disable=broad-except
                raised_exception_messages.append(
                    """Error when trying to stop Chrome tracing
            on devtools at port %s:\n%s""" % (client.remote_port, ''.join(
                        traceback.format_exception(*sys.exc_info()))))

        if (self._trace_config.enable_android_graphics_memtrack
                and self._platform_backend.GetOSName() == 'android'):
            self._platform_backend.SetGraphicsMemoryTrackingEnabled(False)

        self._trace_config = None
        if raised_exception_messages:
            raise ChromeTracingStoppedError(
                'Exceptions raised when trying to stop Chrome devtool tracing:\n'
                + '\n'.join(raised_exception_messages))
Ejemplo n.º 4
0
 def _IterFirstTabBackends(self):
   for client in chrome_tracing_devtools_manager.GetDevToolsClients(
       self._platform_backend):
     backend = client.FirstTabBackend()
     if backend is not None:
       yield backend