blob: c3abe6e9046de8137361ce917c797fab487c1d67 [file] [log] [blame]
<!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="/base/range.html">
<link rel="import" href="/core/trace_model/thread_time_slice.html">
<script>
'use strict';
/**
* @fileoverview Provides the CpuSlice class.
*/
tv.exportTo('tv.c.trace_model', function() {
var Slice = tv.c.trace_model.Slice;
/**
* A CpuSlice represents a slice of time on a CPU.
*
* @constructor
*/
function CpuSlice(cat, title, colorId, start, args, opt_duration) {
Slice.apply(this, arguments);
this.threadThatWasRunning = undefined;
this.cpu = undefined;
}
CpuSlice.prototype = {
__proto__: Slice.prototype,
get analysisTypeName() {
return 'tv.c.analysis.CpuSlice';
},
getAssociatedTimeslice: function() {
if (!this.threadThatWasRunning)
return undefined;
var timeSlices = this.threadThatWasRunning.timeSlices;
for (var i = 0; i < timeSlices.length; i++) {
var timeSlice = timeSlices[i];
if (timeSlice.start !== this.start)
continue;
if (timeSlice.duration !== this.duration)
continue;
return timeSlice;
}
return undefined;
}
};
tv.c.trace_model.EventRegistry.register(
CpuSlice,
{
name: 'cpuSlice',
pluralName: 'cpuSlices',
singleViewElementName: 'tv-c-single-cpu-slice-sub-view',
multiViewElementName: 'tv-c-a-multi-cpu-slice-sub-view'
});
return {
CpuSlice: CpuSlice
};
});
</script>