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. 4 5import telemetry.timeline.event as event 6 7class AsyncSlice(event.TimelineEvent): 8 ''' A AsyncSlice represents an interval of time during which an 9 asynchronous operation is in progress. An AsyncSlice consumes no CPU time 10 itself and so is only associated with Threads at its start and end point. 11 ''' 12 def __init__(self, category, name, timestamp, args=None, 13 duration=0, start_thread=None, end_thread=None, 14 thread_start=None, thread_duration=None): 15 super(AsyncSlice, self).__init__( 16 category, name, timestamp, duration, thread_start, thread_duration, 17 args) 18 self.parent_slice = None 19 self.start_thread = start_thread 20 self.end_thread = end_thread 21 self.sub_slices = [] 22 self.id = None 23 24 def AddSubSlice(self, sub_slice): 25 assert sub_slice.parent_slice == self 26 self.sub_slices.append(sub_slice) 27 28 def IterEventsInThisContainerRecrusively(self): 29 for sub_slice in self.sub_slices: 30 yield sub_slice 31