Chris Craik | ad0b04f | 2015-07-21 13:44:22 -0700 | [diff] [blame] | 1 | # Copyright (c) 2015 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. |
| 4 | |
| 5 | class SystraceAgent(object): |
| 6 | """The base class for systrace agents. |
| 7 | |
| 8 | A systrace agent contains the command-line options and trace categories to |
| 9 | capture. Each systrace agent has its own tracing implementation. |
| 10 | """ |
| 11 | |
| 12 | def __init__(self, options, categories): |
| 13 | """Initialize a systrace agent. |
| 14 | |
| 15 | Args: |
| 16 | options: The command-line options. |
| 17 | categories: The trace categories to capture. |
| 18 | """ |
| 19 | self._options = options |
| 20 | self._categories = categories |
| 21 | |
| 22 | def start(self): |
| 23 | """Start tracing. |
| 24 | """ |
| 25 | raise NotImplementedError() |
| 26 | |
| 27 | def collect_result(self): |
| 28 | """Collect the result of tracing. |
| 29 | |
| 30 | This function will block while collecting the result. For sync mode, it |
| 31 | reads the data, e.g., from stdout, until it finishes. For async mode, it |
| 32 | blocks until the agent is stopped and the data is ready. |
| 33 | """ |
| 34 | raise NotImplementedError() |
| 35 | |
| 36 | def expect_trace(self): |
| 37 | """Check if the agent is returning a trace or not. |
| 38 | |
| 39 | This will be determined in collect_result(). |
| 40 | Returns: |
| 41 | Whether the agent is expecting a trace or not. |
| 42 | """ |
| 43 | raise NotImplementedError() |
| 44 | |
| 45 | def get_trace_data(self): |
| 46 | """Get the trace data. |
| 47 | |
| 48 | Returns: |
| 49 | The trace data. |
| 50 | """ |
| 51 | raise NotImplementedError() |
| 52 | |
| 53 | def get_class_name(self): |
| 54 | """Get the class name |
| 55 | |
| 56 | The class name is used to identify the trace type when the trace is written |
| 57 | to the html file |
| 58 | Returns: |
| 59 | The class name. |
| 60 | """ |
| 61 | raise NotImplementedError() |