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 base.require('base.utils');
8 base.require('tracing.analysis.slice_view');
9 base.require('tracing.analysis.util');
10 base.require('tracing.analysis.analysis_link');
11 base.requireTemplate('tracing.analysis.cpu_slice_view');
13 base.exportTo('tracing.analysis', function() {
14 var tsRound = tracing.analysis.tsRound;
19 var CpuSliceView = ui.define('cpu-slice-view', tracing.analysis.SliceView);
21 CpuSliceView.prototype = {
22 __proto__: tracing.analysis.SliceView.prototype,
24 decorate: function() {
25 tracing.analysis.SliceView.prototype.decorate.call(this);
26 this.classList.add('cpu-slice-view');
29 updateContents: function() {
30 this.textContent = '';
31 this.appendChild(base.instantiateTemplate('#cpu-slice-view-template'));
33 var cpuSlice = this.slice;
34 var thread = cpuSlice.threadThatWasRunning;
37 this.querySelector('#process-name').textContent =
38 thread.parent.userFriendlyName;
39 this.querySelector('#thread-name').textContent =
40 thread.userFriendlyName;
42 this.querySelector('#process-name').parentElement.style.display =
44 this.querySelector('#thread-name').textContent = cpuSlice.title;
46 this.querySelector('#start').textContent = tsRound(cpuSlice.start) + 'ms';
47 this.querySelector('#duration').textContent =
48 tsRound(cpuSlice.duration) + 'ms';
49 var runningThreadEl = this.querySelector('#running-thread');
50 var timeSlice = cpuSlice.getAssociatedTimeslice();
52 runningThreadEl.parentElement.style.display = 'none';
54 var threadLink = new tracing.analysis.AnalysisLink();
55 threadLink.textContent = 'Click to select';
56 threadLink.selectionGenerator = function() {
57 var selection = new tracing.Selection();
58 selection.push(timeSlice);
61 runningThreadEl.appendChild(threadLink);
66 tracing.analysis.SliceView.register(
67 'tracing.analysis.CpuSlice', CpuSliceView);
70 CpuSliceView: CpuSliceView