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/generic_object_view.html">
9 <link rel="import" href="/tracing/analysis/slice_view.html">
10 <link rel="import" href="/tracing/analysis/util.html">
11 <link rel="import" href="/tracing/analysis/analysis_link.html">
12 <link rel="import" href="/base/sorted_array_utils.html">
13 <link rel="import" href="/base/utils.html">
14 <link rel="import" href="/tracing/color_scheme.html">
16 <template id="thread-time-slice-view-template">
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">
26 <td><b><span id="state"></span></b></td>
28 <tr class="analysis-table-row">
29 <td>Start:</td><td id="start"></td>
31 <tr class="analysis-table-row">
32 <td>Duration:</td><td id="duration"></td>
35 <tr class="analysis-table-row">
36 <td>On CPU:</td><td id="on-cpu"></td>
39 <tr class="analysis-table-row">
40 <td>Running instead:</td><td id="running-instead"></td>
43 <tr class="analysis-table-row">
44 <td>Args:</td><td id="args"></td>
52 tv.exportTo('tracing.analysis', function() {
53 var THIS_DOC = document.currentScript.ownerDocument;
54 var tsRound = tracing.analysis.tsRound;
59 var ThreadTimeSliceView = tv.ui.define(
60 'thread-time-slice-view', tracing.analysis.SliceView);
62 ThreadTimeSliceView.prototype = {
63 __proto__: tracing.analysis.SliceView.prototype,
65 decorate: function() {
66 tracing.analysis.SliceView.prototype.decorate.call(this);
67 this.classList.add('thread-time-slice-view');
70 updateContents: function() {
71 this.textContent = '';
73 tv.instantiateTemplate('#thread-time-slice-view-template',
76 var timeSlice = this.slice;
77 var thread = timeSlice.thread;
79 this.querySelector('#state').textContent = timeSlice.title;
80 var stateColor = tv.ui.getColorPalette()[timeSlice.colorId];
81 this.querySelector('#state').style.backgroundColor = stateColor;
83 this.querySelector('#process-name').textContent =
84 thread.parent.userFriendlyName;
85 this.querySelector('#thread-name').textContent = thread.userFriendlyName;
87 this.querySelector('#start').textContent =
88 tsRound(timeSlice.start) + 'ms';
89 this.querySelector('#duration').textContent =
90 tsRound(timeSlice.duration) + 'ms';
91 var onCpuEl = this.querySelector('#on-cpu');
92 var runningInsteadEl = this.querySelector('#running-instead');
93 if (timeSlice.cpuOnWhichThreadWasRunning) {
94 runningInsteadEl.parentElement.removeChild(runningInsteadEl);
95 var cpuLink = new tracing.analysis.AnalysisLink();
97 timeSlice.cpuOnWhichThreadWasRunning.userFriendlyName;
98 cpuLink.selectionGenerator = function() {
99 var selection = new tracing.Selection();
100 selection.push(timeSlice.getAssociatedCpuSlice());
103 onCpuEl.appendChild(cpuLink);
105 onCpuEl.parentElement.removeChild(onCpuEl);
107 var cpuSliceThatTookCpu = timeSlice.getCpuSliceThatTookCpu();
108 if (cpuSliceThatTookCpu) {
109 var cpuLink = new tracing.analysis.AnalysisLink();
110 if (cpuSliceThatTookCpu.thread)
111 cpuLink.textContent = cpuSliceThatTookCpu.thread.userFriendlyName;
113 cpuLink.textContent = cpuSliceThatTookCpu.title;
114 cpuLink.selectionGenerator = function() {
115 var selection = new tracing.Selection();
116 selection.push(cpuSliceThatTookCpu);
119 runningInsteadEl.appendChild(cpuLink);
121 runningInsteadEl.parentElement.removeChild(runningInsteadEl);
125 var argsEl = this.querySelector('#args');
126 if (tv.dictionaryKeys(timeSlice.args).length > 0) {
127 var argsView = new tracing.analysis.GenericObjectView();
128 argsView.object = timeSlice.args;
129 argsEl.appendChild(argsView);
131 argsEl.parentElement.removeChild(argsEl);
136 tracing.analysis.SliceView.register(
137 'tracing.analysis.ThreadTimeSlice', ThreadTimeSliceView);
140 ThreadTimeSliceView: ThreadTimeSliceView