Chris Craik | 93216d0 | 2015-03-05 13:58:42 -0800 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <!-- |
| 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. |
| 6 | --> |
| 7 | |
Chris Craik | f516a62 | 2015-04-01 17:52:39 -0700 | [diff] [blame] | 8 | <link rel="import" href="/base/ui/color_scheme.html"> |
Chris Craik | 93216d0 | 2015-03-05 13:58:42 -0800 | [diff] [blame] | 9 | <link rel="import" href="/base/sorted_array_utils.html"> |
| 10 | <link rel="import" href="/base/utils.html"> |
| 11 | <link rel="import" href="/core/analysis/analysis_link.html"> |
| 12 | <link rel="import" href="/core/analysis/analysis_sub_view.html"> |
| 13 | <link rel="import" href="/core/analysis/generic_object_view.html"> |
| 14 | <link rel="import" href="/core/analysis/util.html"> |
| 15 | <link rel="import" href="/core/trace_model/trace_model.html"> |
Chris Craik | 93216d0 | 2015-03-05 13:58:42 -0800 | [diff] [blame] | 16 | |
| 17 | <polymer-element name="tv-c-single-thread-time-slice-sub-view" |
| 18 | extends="tracing-analysis-sub-view"> |
| 19 | <template> |
| 20 | <style> |
| 21 | table { |
| 22 | border-collapse: collapse; |
| 23 | border-width: 0; |
| 24 | margin-bottom: 25px; |
| 25 | width: 100%; |
| 26 | } |
| 27 | |
| 28 | table tr > td:first-child { |
| 29 | padding-left: 2px; |
| 30 | } |
| 31 | |
| 32 | table tr > td { |
| 33 | padding: 2px 4px 2px 4px; |
| 34 | vertical-align: text-top; |
| 35 | width: 150px; |
| 36 | } |
| 37 | |
| 38 | table td td { |
| 39 | padding: 0 0 0 0; |
| 40 | width: auto; |
| 41 | } |
| 42 | tr { |
| 43 | vertical-align: top; |
| 44 | } |
| 45 | |
| 46 | tr:nth-child(2n+0) { |
| 47 | background-color: #e2e2e2; |
| 48 | } |
| 49 | </style> |
| 50 | <table> |
| 51 | <tr> |
| 52 | <td>Running process:</td><td id="process-name"></td> |
| 53 | </tr> |
| 54 | <tr> |
| 55 | <td>Running thread:</td><td id="thread-name"></td> |
| 56 | </tr> |
| 57 | <tr> |
| 58 | <td>State:</td> |
| 59 | <td><b><span id="state"></span></b></td> |
| 60 | </tr> |
| 61 | <tr> |
| 62 | <td>Start:</td><td id="start"></td> |
| 63 | </tr> |
| 64 | <tr> |
| 65 | <td>Duration:</td><td id="duration"></td> |
| 66 | </tr> |
| 67 | |
| 68 | <tr> |
| 69 | <td>On CPU:</td><td id="on-cpu"></td> |
| 70 | </tr> |
| 71 | |
| 72 | <tr> |
| 73 | <td>Running instead:</td><td id="running-instead"></td> |
| 74 | </tr> |
| 75 | |
| 76 | <tr> |
| 77 | <td>Args:</td><td id="args"></td> |
| 78 | </tr> |
| 79 | </table> |
| 80 | </template> |
| 81 | |
| 82 | <script> |
| 83 | 'use strict'; |
| 84 | |
| 85 | Polymer({ |
| 86 | created: function() { |
| 87 | this.currentSelection_ = undefined; |
| 88 | }, |
| 89 | |
| 90 | get selection() { |
| 91 | return this.currentSelection_; |
| 92 | }, |
| 93 | |
| 94 | set selection(selection) { |
| 95 | if (selection.length !== 1) |
| 96 | throw new Error('Only supports single slices'); |
| 97 | if (!(selection[0] instanceof tv.c.trace_model.ThreadTimeSlice)) |
| 98 | throw new Error('Only supports thread time slices'); |
| 99 | |
| 100 | this.currentSelection_ = selection; |
| 101 | |
| 102 | var timeSlice = selection[0]; |
| 103 | var thread = timeSlice.thread; |
| 104 | |
| 105 | var shadowRoot = this.shadowRoot; |
| 106 | shadowRoot.querySelector('#state').textContent = timeSlice.title; |
| 107 | var stateColor = tv.b.ui.getColorPalette()[timeSlice.colorId]; |
| 108 | shadowRoot.querySelector('#state').style.backgroundColor = stateColor; |
| 109 | |
| 110 | shadowRoot.querySelector('#process-name').textContent = |
| 111 | thread.parent.userFriendlyName; |
| 112 | shadowRoot.querySelector('#thread-name').textContent = |
| 113 | thread.userFriendlyName; |
| 114 | |
| 115 | shadowRoot.querySelector('#start').textContent = |
Chris Craik | f516a62 | 2015-04-01 17:52:39 -0700 | [diff] [blame] | 116 | tv.c.analysis.tsString(timeSlice.start); |
Chris Craik | 93216d0 | 2015-03-05 13:58:42 -0800 | [diff] [blame] | 117 | shadowRoot.querySelector('#duration').textContent = |
Chris Craik | f516a62 | 2015-04-01 17:52:39 -0700 | [diff] [blame] | 118 | tv.c.analysis.tsString(timeSlice.duration); |
Chris Craik | 93216d0 | 2015-03-05 13:58:42 -0800 | [diff] [blame] | 119 | var onCpuEl = shadowRoot.querySelector('#on-cpu'); |
| 120 | onCpuEl.textContent = ''; |
| 121 | var runningInsteadEl = shadowRoot.querySelector('#running-instead'); |
| 122 | if (timeSlice.cpuOnWhichThreadWasRunning) { |
| 123 | runningInsteadEl.parentElement.removeChild(runningInsteadEl); |
Chris Craik | f516a62 | 2015-04-01 17:52:39 -0700 | [diff] [blame] | 124 | |
| 125 | var cpuLink = document.createElement('tv-c-analysis-link'); |
| 126 | cpuLink.selection = new tv.c.Selection( |
| 127 | timeSlice.getAssociatedCpuSlice()); |
Chris Craik | 93216d0 | 2015-03-05 13:58:42 -0800 | [diff] [blame] | 128 | cpuLink.textContent = |
| 129 | timeSlice.cpuOnWhichThreadWasRunning.userFriendlyName; |
Chris Craik | 93216d0 | 2015-03-05 13:58:42 -0800 | [diff] [blame] | 130 | onCpuEl.appendChild(cpuLink); |
| 131 | } else { |
| 132 | onCpuEl.parentElement.removeChild(onCpuEl); |
| 133 | |
| 134 | var cpuSliceThatTookCpu = timeSlice.getCpuSliceThatTookCpu(); |
| 135 | if (cpuSliceThatTookCpu) { |
Chris Craik | f516a62 | 2015-04-01 17:52:39 -0700 | [diff] [blame] | 136 | var cpuLink = document.createElement('tv-c-analysis-link'); |
| 137 | cpuLink.selection = new tv.c.Selection(cpuSliceThatTookCpu); |
Chris Craik | 93216d0 | 2015-03-05 13:58:42 -0800 | [diff] [blame] | 138 | if (cpuSliceThatTookCpu.thread) |
| 139 | cpuLink.textContent = cpuSliceThatTookCpu.thread.userFriendlyName; |
| 140 | else |
| 141 | cpuLink.textContent = cpuSliceThatTookCpu.title; |
Chris Craik | 93216d0 | 2015-03-05 13:58:42 -0800 | [diff] [blame] | 142 | runningInsteadEl.appendChild(cpuLink); |
| 143 | } else { |
| 144 | runningInsteadEl.parentElement.removeChild(runningInsteadEl); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | var argsEl = shadowRoot.querySelector('#args'); |
| 149 | if (tv.b.dictionaryKeys(timeSlice.args).length > 0) { |
Chris Craik | f516a62 | 2015-04-01 17:52:39 -0700 | [diff] [blame] | 150 | var argsView = |
| 151 | document.createElement('tv-c-analysis-generic-object-view'); |
Chris Craik | 93216d0 | 2015-03-05 13:58:42 -0800 | [diff] [blame] | 152 | argsView.object = timeSlice.args; |
| 153 | |
| 154 | argsEl.parentElement.style.display = ''; |
| 155 | argsEl.textContent = ''; |
| 156 | argsEl.appendChild(argsView); |
| 157 | } else { |
| 158 | argsEl.parentElement.style.display = 'none'; |
| 159 | } |
| 160 | } |
| 161 | }); |
| 162 | </script> |
Chris Craik | 44c2820 | 2015-05-12 17:25:16 -0700 | [diff] [blame^] | 163 | </polymer-element> |