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.utils');
8 tvcm.require('tracing.analysis.slice_view');
9 tvcm.require('tracing.analysis.util');
10 tvcm.require('tracing.analysis.analysis_link');
11 tvcm.requireTemplate('tracing.analysis.cpu_slice_view');
13 tvcm.exportTo('tracing.analysis', function() {
14 var tsRound = tracing.analysis.tsRound;
19 var CpuSliceView = tvcm.ui.define('cpu-slice-view',
20 tracing.analysis.SliceView);
22 CpuSliceView.prototype = {
23 __proto__: tracing.analysis.SliceView.prototype,
25 decorate: function() {
26 tracing.analysis.SliceView.prototype.decorate.call(this);
27 this.classList.add('cpu-slice-view');
30 updateContents: function() {
31 this.textContent = '';
32 this.appendChild(tvcm.instantiateTemplate('#cpu-slice-view-template'));
34 var cpuSlice = this.slice;
35 var thread = cpuSlice.threadThatWasRunning;
38 this.querySelector('#process-name').textContent =
39 thread.parent.userFriendlyName;
40 this.querySelector('#thread-name').textContent =
41 thread.userFriendlyName;
43 this.querySelector('#process-name').parentElement.style.display =
45 this.querySelector('#thread-name').textContent = cpuSlice.title;
47 this.querySelector('#start').textContent = tsRound(cpuSlice.start) + 'ms';
48 this.querySelector('#duration').textContent =
49 tsRound(cpuSlice.duration) + 'ms';
50 var runningThreadEl = this.querySelector('#running-thread');
51 var timeSlice = cpuSlice.getAssociatedTimeslice();
53 runningThreadEl.parentElement.style.display = 'none';
55 var threadLink = new tracing.analysis.AnalysisLink();
56 threadLink.textContent = 'Click to select';
57 threadLink.selectionGenerator = function() {
58 var selection = new tracing.Selection();
59 selection.push(timeSlice);
62 runningThreadEl.appendChild(threadLink);
67 tracing.analysis.SliceView.register(
68 'tracing.analysis.CpuSlice', CpuSliceView);
71 CpuSliceView: CpuSliceView