Chris Craik | b122baf | 2015-03-05 13:58:42 -0800 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <!-- |
| 3 | Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 4 | Use of this source code is governed by a BSD-style license that can be |
| 5 | found in the LICENSE file. |
| 6 | --> |
| 7 | |
| 8 | <link rel="import" href="/base/base.html"> |
| 9 | |
| 10 | <script> |
| 11 | 'use strict'; |
| 12 | |
| 13 | /** |
| 14 | * @fileoverview Provides the base class for all container classes. |
| 15 | */ |
| 16 | tv.exportTo('tv.c.trace_model', function() { |
| 17 | function EventContainer() { |
Chris Craik | 1983215 | 2015-04-16 15:43:38 -0700 | [diff] [blame] | 18 | this.important = true; |
Chris Craik | 44c2820 | 2015-05-12 17:25:16 -0700 | [diff] [blame^] | 19 | this.bounds = undefined; |
Chris Craik | b122baf | 2015-03-05 13:58:42 -0800 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | EventContainer.prototype = { |
| 23 | /* |
| 24 | * @return {String} An identifier that is made up of this parent's |
| 25 | * stableIdentifier plus this countainer identifier. |
| 26 | */ |
| 27 | get stableId() { |
| 28 | throw new Error('Not implemented'); |
Chris Craik | 44c2820 | 2015-05-12 17:25:16 -0700 | [diff] [blame^] | 29 | }, |
| 30 | |
| 31 | updateBounds: function() { |
| 32 | throw new Error('Not implemented'); |
| 33 | }, |
| 34 | |
| 35 | shiftTimestampsForward: function(amount) { |
| 36 | throw new Error('Not implemented'); |
| 37 | }, |
| 38 | |
| 39 | iterateAllEventsInThisContainer: function(eventTypePredicate, |
| 40 | callback, opt_this) { |
| 41 | throw new Error('Not implemented'); |
| 42 | }, |
| 43 | |
| 44 | iterateAllChildEventContainers: function(callback, opt_this) { |
| 45 | throw new Error('Not implemented'); |
| 46 | }, |
| 47 | |
| 48 | /** |
| 49 | * Iterates all events in the model and calls callback on each event. |
| 50 | * @param {function(event)} callback The callback called for every event. |
| 51 | */ |
| 52 | iterateAllEvents: function(callback, opt_this) { |
| 53 | this.iterateAllEventContainers(function(ec) { |
| 54 | ec.iterateAllEventsInThisContainer( |
| 55 | function(eventType) { return true; }, |
| 56 | callback, opt_this); |
| 57 | }); |
| 58 | }, |
| 59 | |
| 60 | iterateAllEventContainers: function(callback, opt_this) { |
| 61 | function visit(ec) { |
| 62 | callback.call(opt_this, ec); |
| 63 | ec.iterateAllChildEventContainers(visit); |
| 64 | } |
| 65 | visit(this); |
Chris Craik | b122baf | 2015-03-05 13:58:42 -0800 | [diff] [blame] | 66 | } |
| 67 | }; |
| 68 | |
| 69 | return { |
| 70 | EventContainer: EventContainer |
| 71 | }; |
| 72 | }); |
| 73 | </script> |