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
3 // found in the LICENSE file.
7 tvcm.require('tvcm.guid');
8 tvcm.require('tracing.trace_model.event');
11 * @fileoverview Provides the TimedEvent class.
13 tvcm.exportTo('tracing.trace_model', function() {
15 * A TimedEvent is the base type for any piece of data in the trace model with
16 * a specific start and duration.
20 function TimedEvent(start) {
21 tracing.trace_model.Event.call(this);
26 TimedEvent.prototype = {
27 __proto__: tracing.trace_model.Event.prototype,
30 return this.start + this.duration;
33 addBoundsToRange: function(range) {
34 range.addValue(this.start);
35 range.addValue(this.end);
38 bounds: function(that) {
39 // Due to inaccuracy of floating-point calculation, the end times of
40 // slices from a B/E pair (whose end = start + original_end - start)
41 // and an X event (whose end = start + duration) at the same time may
42 // become not equal. Round back to micros (which is the source data
43 // precision) to ensure equality below.
44 var this_end_micros = Math.round(this.end * 1000);
45 var that_end_micros = Math.round(that.end * 1000);
46 return this.start <= that.start && this_end_micros >= that_end_micros;
51 TimedEvent: TimedEvent