| <!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="/core/trace_model/timed_event.html"> |
| <link rel="import" href="/core/analysis/util.html"> |
| |
| <script> |
| 'use strict'; |
| |
| /** |
| * @fileoverview Provides the Slice class. |
| */ |
| tv.exportTo('tv.c.trace_model', function() { |
| /** |
| * A Slice represents an interval of time plus parameters associated |
| * with that interval. |
| * |
| * @constructor |
| */ |
| function Slice(category, title, colorId, start, args, opt_duration, |
| opt_cpuStart, opt_cpuDuration) { |
| tv.c.trace_model.TimedEvent.call(this, start); |
| |
| this.category = category || ''; |
| this.title = title; |
| this.colorId = colorId; |
| this.args = args; |
| this.startStackFrame = undefined; |
| this.endStackFrame = undefined; |
| this.didNotFinish = false; |
| this.inFlowEvents = []; |
| this.outFlowEvents = []; |
| this.subSlices = []; |
| this.selfTime = undefined; |
| this.cpuSelfTime = undefined; |
| this.important = false; |
| |
| if (opt_duration !== undefined) |
| this.duration = opt_duration; |
| |
| if (opt_cpuStart !== undefined) |
| this.cpuStart = opt_cpuStart; |
| |
| if (opt_cpuDuration !== undefined) |
| this.cpuDuration = opt_cpuDuration; |
| } |
| |
| Slice.prototype = { |
| __proto__: tv.c.trace_model.TimedEvent.prototype, |
| |
| |
| get analysisTypeName() { |
| return this.title; |
| }, |
| |
| get userFriendlyName() { |
| return 'Slice ' + this.title + ' at ' + |
| tv.c.analysis.tsString(this.start); |
| }, |
| |
| findDescendentSlice: function(targetTitle) { |
| if (!this.subSlices) |
| return undefined; |
| |
| for (var i = 0; i < this.subSlices.length; i++) { |
| if (this.subSlices[i].title == targetTitle) |
| return this.subSlices[i]; |
| var slice = this.subSlices[i].findDescendentSlice(targetTitle); |
| if (slice) return slice; |
| } |
| return undefined; |
| } |
| }; |
| |
| tv.c.trace_model.EventRegistry.register( |
| Slice, |
| { |
| name: 'slice', |
| pluralName: 'slices', |
| singleViewElementName: 'tv-c-single-slice-sub-view', |
| multiViewElementName: 'tv-c-multi-slice-sub-view' |
| }); |
| |
| return { |
| Slice: Slice |
| }; |
| }); |
| </script> |
| |