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
3# found in the LICENSE file.
5class TracingController(object):
6  def __init__(self, tracing_controller_backend):
7    """Provides control of the tracing systems supported by telemetry."""
8    self._tracing_controller_backend = tracing_controller_backend
10  def Start(self, trace_options, category_filter, timeout=10):
11    """Starts tracing.
13    trace_options specifies which tracing systems to activate. Category filter
14    allows fine-tuning of the data that are collected by the selected tracing
15    systems.
17    Some tracers are process-specific, e.g. chrome tracing, but are not
18    guaranteed to be supported. In order to support tracing of these kinds of
19    tracers, Start will succeed *always*, even if the tracing systems you have
20    requested are not supported.
22    If you absolutely require a particular tracer to exist, then check
23    for its support after you have started the process in question. Or, have
24    your code fail gracefully when the data you require is not present in the
25    resulting trace.
26    """
27    self._tracing_controller_backend.Start(
28        trace_options, category_filter, timeout)
30  def Stop(self):
31    """Stops tracing and returns a TraceValue."""
32    return self._tracing_controller_backend.Stop()
34  @property
35  def is_tracing_running(self):
36    return self._tracing_controller_backend.is_tracing_running
38  def IsChromeTracingSupported(self, browser):
39    """Returns whether chrome tracing is supported on the given browser."""
40    return self._tracing_controller_backend.IsChromeTracingSupported(browser)