• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!DOCTYPE html>
2<!--
3Copyright (c) 2015 The Chromium Authors. All rights reserved.
4Use of this source code is governed by a BSD-style license that can be
5found in the LICENSE file.
6-->
7
8<link rel="import" href="/tracing/base/base.html">
9<link rel="import" href="/tracing/base/guid.html">
10<link rel="import" href="/tracing/base/range.html">
11
12<script>
13'use strict';
14
15tr.exportTo('tr.model', function() {
16
17  /**
18   * EventContainer is a base class for any class in the trace model that
19   * contains child events or child EventContainers.
20   *
21   * For all EventContainers, updateBounds() must be called after modifying the
22   * container's events if an up-to-date bounds is expected.
23   *
24   * @constructor
25   */
26  function EventContainer() {
27    this.guid_ = tr.b.GUID.allocate();
28    this.important = true;
29    this.bounds_ = new tr.b.Range();
30  }
31
32  EventContainer.prototype = {
33    get guid() {
34      return this.guid_;
35    },
36
37    /**
38     * @return {String} A stable and unique identifier that describes this
39     * container's position in the event tree relative to the root. If an event
40     * container 'B' is a child to another event container 'A', then container
41     * B's stable ID would be 'A.B'.
42     */
43    get stableId() {
44      throw new Error('Not implemented');
45    },
46
47    /**
48     * Returns the bounds of the event container, which describe the range
49     * of timestamps for all ancestor events.
50     */
51    get bounds() {
52      return this.bounds_;
53    },
54
55    // TODO(charliea): A default implementation of this method could likely be
56    // provided that uses 'iterateAllEvents'.
57    /**
58     * Updates the bounds of the event container. After updating, this.bounds
59     * will describe the range of timestamps of all ancestor events.
60     */
61    updateBounds: function() {
62      throw new Error('Not implemented');
63    },
64
65    // TODO(charliea): A default implementation of this method could likely be
66    // provided that uses 'iterateAllEvents'.
67    /**
68     * Shifts the timestamps for ancestor events by 'amount' milliseconds.
69     */
70    shiftTimestampsForward: function(amount) {
71      throw new Error('Not implemented');
72    },
73
74    /**
75     * Iterates over all child events.
76     */
77    iterateAllEventsInThisContainer: function(eventTypePredicate,
78                                              callback, opt_this) {
79      throw new Error('Not implemented');
80    },
81
82    /**
83     * Iterates over all child containers.
84     */
85    iterateAllChildEventContainers: function(callback, opt_this) {
86      throw new Error('Not implemented');
87    },
88
89    /**
90     * Iterates over all ancestor events.
91     */
92    iterateAllEvents: function(callback, opt_this) {
93      this.iterateAllEventContainers(function(ec) {
94        ec.iterateAllEventsInThisContainer(
95            function(eventType) { return true; },
96            callback, opt_this);
97      });
98    },
99
100    /**
101     * Iterates over this container and all ancestor containers.
102     */
103    iterateAllEventContainers: function(callback, opt_this) {
104      function visit(ec) {
105        callback.call(opt_this, ec);
106        ec.iterateAllChildEventContainers(visit);
107      }
108      visit(this);
109    }
110  };
111
112  return {
113    EventContainer: EventContainer
114  };
115});
116</script>
117