diff options
author | Joel Fernandes <joelaf@google.com> | 2017-06-14 12:28:42 -0700 |
---|---|---|
committer | KP Singh <kpsingh@google.com> | 2017-06-15 00:19:08 +0200 |
commit | ee6fb473add14fb3e2947bb57c7e1fc86c172a46 (patch) | |
tree | c066a6a34a0aba85280fda46c6409facf106e10e | |
parent | 1954b37df094fce96ed345344da920dd248597d9 (diff) | |
download | trappy-ee6fb473add14fb3e2947bb57c7e1fc86c172a46.tar.gz |
systrace: Make systrace reuse hasnt_started from base class
Since Patrick changed hasnt_started to use the regex for checking if a line is
valid, its better if we don't use the hardcoded logic we have now that checks
if the trace line begins with '#'. Instead lets piggy back onto the base class
if systrace thinks the line shouldn't be skipped. This makes it a more
consistent design.
Signed-off-by: Joel Fernandes <joelaf@google.com>
Reviewed-by: KP Singh <kpsingh@google.com>
-rw-r--r-- | trappy/systrace.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/trappy/systrace.py b/trappy/systrace.py index e18abf8..0a7f42b 100644 --- a/trappy/systrace.py +++ b/trappy/systrace.py @@ -27,24 +27,26 @@ the trace the headers that start with # """ - def __init__(self): + def __init__(self, tracer): self.before_begin_trace = True - self.before_script_trace_data = True self.before_actual_trace = True + self.tracer = tracer def __call__(self, line): if self.before_begin_trace: if line.startswith("<!-- BEGIN TRACE -->") or \ line.startswith("<title>Android System Trace</title>"): self.before_begin_trace = False - elif self.before_script_trace_data: + elif self.before_actual_trace: if line.startswith(' <script class="trace-data"') or \ line.startswith(" var linuxPerfData"): - self.before_script_trace_data = False - elif not line.startswith("#"): - self.before_actual_trace = False + self.before_actual_trace = False - return self.before_actual_trace + if not self.before_actual_trace: + base_call = super(SysTrace, self.tracer).trace_hasnt_started() + return base_call(line) + else: + return True class SysTrace(GenericFTrace): """A wrapper that parses all events of a SysTrace run @@ -67,7 +69,7 @@ class SysTrace(GenericFTrace): pass def trace_hasnt_started(self): - return drop_before_trace() + return drop_before_trace(self) def trace_hasnt_finished(self): """Return a function that returns True while the current line is still part of the trace |