| <!DOCTYPE html> |
| <!-- |
| Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| Use of this source code is governed by a BSD-style license that can be |
| found in the LICENSE file. |
| --> |
| |
| <link rel="import" href="/tracing/base/guid.html"> |
| <link rel="import" href="/tracing/model/event.html"> |
| <link rel="import" href="/tracing/value/time_display_mode.html"> |
| |
| <script> |
| 'use strict'; |
| |
| tr.exportTo('tr.model', function() { |
| /** |
| * TimedEvent is a base type for any entity in the trace model with a specific |
| * start and duration. |
| * |
| * @constructor |
| */ |
| function TimedEvent(start) { |
| tr.model.Event.call(this); |
| this.start = start; |
| this.duration = 0; |
| this.cpuStart = undefined; |
| this.cpuDuration = undefined; |
| } |
| |
| TimedEvent.prototype = { |
| __proto__: tr.model.Event.prototype, |
| |
| get end() { |
| return this.start + this.duration; |
| }, |
| |
| addBoundsToRange: function(range) { |
| range.addValue(this.start); |
| range.addValue(this.end); |
| }, |
| |
| // Returns true if 'that' TimedEvent is fully contained within 'this' timed |
| // event. |
| bounds: function(that, opt_precisionUnit) { |
| if (opt_precisionUnit === undefined) |
| opt_precisionUnit = tr.v.TimeDisplayModes.ms; |
| |
| var startsBefore = opt_precisionUnit.roundedLess(that.start, this.start); |
| var endsAfter = opt_precisionUnit.roundedLess(this.end, that.end); |
| return !startsBefore && !endsAfter; |
| } |
| }; |
| |
| return { |
| TimedEvent: TimedEvent |
| }; |
| }); |
| </script> |