f5bd548c749bab91a7bbc9bcab4e5968fc1a7a85
[platform/framework/web/crosswalk.git] / src / third_party / trace-viewer / trace_viewer / tracing / trace_model / timed_event.html
1 <!DOCTYPE html>
2 <!--
3 Copyright (c) 2013 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="/tracing/trace_model/event.html">
9 <link rel="import" href="/tvcm/guid.html">
10
11 <script>
12 'use strict';
13
14 /**
15  * @fileoverview Provides the TimedEvent class.
16  */
17 tvcm.exportTo('tracing.trace_model', function() {
18   /**
19    * A TimedEvent is the base type for any piece of data in the trace model with
20    * a specific start and duration.
21    *
22    * @constructor
23    */
24   function TimedEvent(start) {
25     tracing.trace_model.Event.call(this);
26     this.start = start;
27     this.duration = 0;
28   }
29
30   TimedEvent.prototype = {
31     __proto__: tracing.trace_model.Event.prototype,
32
33     get end() {
34       return this.start + this.duration;
35     },
36
37     addBoundsToRange: function(range) {
38       range.addValue(this.start);
39       range.addValue(this.end);
40     },
41
42     bounds: function(that) {
43       // Due to inaccuracy of floating-point calculation, the end times of
44       // slices from a B/E pair (whose end = start + original_end - start)
45       // and an X event (whose end = start + duration) at the same time may
46       // become not equal. Round back to micros (which is the source data
47       // precision) to ensure equality below.
48       var this_end_micros = Math.round(this.end * 1000);
49       var that_end_micros = Math.round(that.end * 1000);
50       return this.start <= that.start && this_end_micros >= that_end_micros;
51     }
52   };
53
54   return {
55     TimedEvent: TimedEvent
56   };
57 });
58 </script>