1<!DOCTYPE html> 2<!-- 3Copyright (c) 2013 The Chromium Authors. All rights reserved. 4Use of this source code is governed by a BSD-style license that can be 5found in the LICENSE file. 6--> 7 8<link rel="import" href="/tracing/model/event_set.html"> 9<link rel="import" href="/tracing/ui/analysis/analysis_link.html"> 10<link rel="import" href="/tracing/ui/analysis/analysis_sub_view.html"> 11<link rel="import" href="/tracing/ui/analysis/generic_object_view.html"> 12<link rel="import" href="/tracing/ui/analysis/object_instance_view.html"> 13<link rel="import" href="/tracing/ui/analysis/single_event_sub_view.html"> 14 15<polymer-element name="tr-ui-a-single-object-instance-sub-view" 16 extends="tr-ui-a-sub-view"> 17 <template> 18 <style> 19 :host { 20 display: block; 21 } 22 23 #snapshots > * { 24 display: block; 25 } 26 27 :host { 28 overflow: auto; 29 display: block; 30 } 31 32 * { 33 -webkit-user-select: text; 34 } 35 36 .title { 37 border-bottom: 1px solid rgb(128, 128, 128); 38 font-size: 110%; 39 font-weight: bold; 40 } 41 42 td, th { 43 font-family: monospace; 44 vertical-align: top; 45 } 46 </style> 47 <div id='content'></div> 48 </template> 49 <script> 50 'use strict'; 51 52 Polymer({ 53 created: function() { 54 this.currentSelection_ = undefined; 55 }, 56 57 get requiresTallView() { 58 if (this.$.content.children.length === 0) 59 return false; 60 if (this.$.content.children[0] instanceof 61 tr.ui.analysis.ObjectInstanceView) 62 return this.$.content.children[0].requiresTallView; 63 }, 64 65 get selection() { 66 return this.currentSelection_; 67 }, 68 69 set selection(selection) { 70 if (selection.length !== 1) 71 throw new Error('Only supports single item selections'); 72 if (!(selection[0] instanceof tr.model.ObjectInstance)) 73 throw new Error('Only supports object instances'); 74 75 this.$.content.textContent = ''; 76 this.currentSelection_ = selection; 77 78 var instance = selection[0]; 79 var typeInfo = tr.ui.analysis.ObjectInstanceView.getTypeInfo( 80 instance.category, instance.typeName); 81 if (typeInfo) { 82 var customView = new typeInfo.constructor(); 83 this.$.content.appendChild(customView); 84 customView.modelEvent = instance; 85 } else { 86 this.appendGenericAnalysis_(instance); 87 } 88 }, 89 90 appendGenericAnalysis_: function(instance) { 91 var html = ''; 92 html += '<div class="title">' + 93 instance.typeName + ' ' + 94 instance.id + '</div>\n'; 95 html += '<table>'; 96 html += '<tr>'; 97 html += '<tr><td>creationTs:</td><td>' + 98 instance.creationTs + '</td></tr>\n'; 99 if (instance.deletionTs != Number.MAX_VALUE) { 100 html += '<tr><td>deletionTs:</td><td>' + 101 instance.deletionTs + '</td></tr>\n'; 102 } else { 103 html += '<tr><td>deletionTs:</td><td>not deleted</td></tr>\n'; 104 } 105 html += '<tr><td>snapshots:</td><td id="snapshots"></td></tr>\n'; 106 html += '</table>'; 107 this.$.content.innerHTML = html; 108 var snapshotsEl = this.$.content.querySelector('#snapshots'); 109 instance.snapshots.forEach(function(snapshot) { 110 var snapshotLink = document.createElement('tr-ui-a-analysis-link'); 111 snapshotLink.selection = new tr.model.EventSet(snapshot); 112 snapshotsEl.appendChild(snapshotLink); 113 }); 114 } 115 }); 116 </script> 117</polymer-element> 118