3 Copyright (c) 2013 The Chromium Authors. All rights reserved.
4 Use of this source code is governed by a BSD-style license that can be
5 found in the LICENSE file.
8 <link rel="import" href="/tracing/analysis/slice_view.html">
9 <link rel="import" href="/tracing/analysis/util.html">
10 <link rel="import" href="/tracing/analysis/analysis_link.html">
11 <link rel="import" href="/base/utils.html">
13 <template id="cpu-slice-view-template">
15 <tr class="analysis-table-row">
16 <td colspan=2><b>CPU Time Slice</b></td>
18 <tr class="analysis-table-row">
19 <td>Running process:</td><td id="process-name"></td>
21 <tr class="analysis-table-row">
22 <td>Running thread:</td><td id="thread-name"></td>
24 <tr class="analysis-table-row">
25 <td>Start:</td><td id="start"></td>
27 <tr class="analysis-table-row">
28 <td>Duration:</td><td id="duration"></td>
30 <tr class="analysis-table-row">
31 <td>Active slices:</td><td id="running-thread"></td>
39 tv.exportTo('tracing.analysis', function() {
40 var THIS_DOC = document.currentScript.ownerDocument;
41 var tsRound = tracing.analysis.tsRound;
46 var CpuSliceView = tv.ui.define('cpu-slice-view',
47 tracing.analysis.SliceView);
49 CpuSliceView.prototype = {
50 __proto__: tracing.analysis.SliceView.prototype,
52 decorate: function() {
53 tracing.analysis.SliceView.prototype.decorate.call(this);
54 this.classList.add('cpu-slice-view');
57 updateContents: function() {
58 this.textContent = '';
59 this.appendChild(tv.instantiateTemplate('#cpu-slice-view-template',
62 var cpuSlice = this.slice;
63 var thread = cpuSlice.threadThatWasRunning;
66 this.querySelector('#process-name').textContent =
67 thread.parent.userFriendlyName;
68 this.querySelector('#thread-name').textContent =
69 thread.userFriendlyName;
71 this.querySelector('#process-name').parentElement.style.display =
73 this.querySelector('#thread-name').textContent = cpuSlice.title;
75 this.querySelector('#start').textContent = tsRound(cpuSlice.start) + 'ms';
76 this.querySelector('#duration').textContent =
77 tsRound(cpuSlice.duration) + 'ms';
78 var runningThreadEl = this.querySelector('#running-thread');
79 var timeSlice = cpuSlice.getAssociatedTimeslice();
81 runningThreadEl.parentElement.style.display = 'none';
83 var threadLink = new tracing.analysis.AnalysisLink();
84 threadLink.textContent = 'Click to select';
85 threadLink.selectionGenerator = function() {
86 var selection = new tracing.Selection();
87 selection.push(timeSlice);
90 runningThreadEl.appendChild(threadLink);
95 tracing.analysis.SliceView.register(
96 'tracing.analysis.CpuSlice', CpuSliceView);
99 CpuSliceView: CpuSliceView