OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 class TimelineModel(object): | 5 class TimelineModel(object): |
6 def __init__(self): | 6 def __init__(self): |
7 self._events = [] | 7 self._events = [] |
8 self._frozen = False | 8 self._frozen = False |
9 | 9 |
10 def AddEvent(self, event): | 10 def AddEvent(self, event): |
11 if self._frozen: | 11 if self._frozen: |
12 raise Exception("Cannot add events once recording is done") | 12 raise Exception("Cannot add events once recording is done") |
13 self._events.extend( | 13 self._events.extend( |
14 event.GetAllChildrenRecursive(include_self=True)) | 14 event.GetAllChildrenRecursive(include_self=True)) |
15 | 15 |
16 def DidFinishRecording(self): | 16 def DidFinishRecording(self): |
17 self._frozen = True | 17 self._frozen = True |
18 | 18 |
19 def GetAllEvents(self): | 19 def GetAllEvents(self): |
20 return self._events | 20 return self._events |
21 | 21 |
22 def GetAllOfName(self, name): | 22 def GetAllOfName(self, name): |
23 return [e for e in self._events if e.name == name] | 23 return [e for e in self._events if e.name == name] |
OLD | NEW |