1# Copyright 2016 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 5import optparse 6import tempfile 7 8from systrace import trace_result 9from systrace import tracing_agents 10 11 12class FakeAgent2(object): 13 def __init__(self, contents='fake-contents'): 14 self.contents = contents 15 self.stopped = False 16 self.config = None 17 self.filename = None 18 19 # pylint: disable=unused-argument 20 def StartAgentTracing(self, config, timeout=None): 21 self.config = config 22 return True 23 24 # pylint: disable=unused-argument 25 def StopAgentTracing(self, timeout=None): 26 self.stopped = True 27 return True 28 29 # pylint: disable=unused-argument 30 def GetResults(self, timeout=None): 31 trace_data = open(self._PullTrace()).read() 32 return trace_result.TraceResult('fakeDataTwo', trace_data) 33 34 def _PullTrace(self): 35 with tempfile.NamedTemporaryFile(delete=False) as f: 36 self.filename = f.name 37 f.write(self.contents) 38 return f.name 39 40 # pylint: disable=no-self-use 41 def SupportsExplicitClockSync(self): 42 return False 43 44 # pylint: disable=unused-argument, no-self-use 45 def RecordClockSyncMarker(self, sync_id, did_record_sync_marker_callback): 46 print ('Clock sync marker cannot be recorded since explicit clock sync ' 47 'is not supported.') 48 49 def __repr__(self): 50 return 'faketracetwo' 51 52 53class FakeConfig(tracing_agents.TracingConfig): 54 def __init__(self): 55 tracing_agents.TracingConfig.__init__(self) 56 57 58# pylint: disable=unused-argument 59def try_create_agent(config): 60 return FakeAgent2() 61 62def add_options(parser): 63 options = optparse.OptionGroup(parser, 'Fake options.') 64 return options 65 66# pylint: disable=unused-argument 67def get_config(options): 68 return FakeConfig() 69