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/ui/analysis/object_snapshot_view.html"> 9<link rel="import" href="/tracing/ui/analysis/object_instance_view.html"> 10<link rel="import" href="/tracing/ui/tracks/multi_row_track.html"> 11<link rel="import" href="/tracing/ui/tracks/object_instance_track.html"> 12<link rel="import" href="/tracing/base/sorted_array_utils.html"> 13<link rel="import" href="/tracing/ui/base/ui.html"> 14 15<script> 16'use strict'; 17 18tr.exportTo('tr.ui.tracks', function() { 19 /** 20 * A track that displays a ObjectInstanceGroup. 21 * @constructor 22 * @extends {ContainerTrack} 23 */ 24 var ObjectInstanceGroupTrack = tr.ui.b.define( 25 'object-instance-group-track', tr.ui.tracks.MultiRowTrack); 26 27 ObjectInstanceGroupTrack.prototype = { 28 29 __proto__: tr.ui.tracks.MultiRowTrack.prototype, 30 31 decorate: function(viewport) { 32 tr.ui.tracks.MultiRowTrack.prototype.decorate.call(this, viewport); 33 this.classList.add('object-instance-group-track'); 34 this.objectInstances_ = undefined; 35 }, 36 37 get objectInstances() { 38 return this.itemsToGroup; 39 }, 40 41 set objectInstances(objectInstances) { 42 this.setItemsToGroup(objectInstances); 43 }, 44 45 addSubTrack_: function(objectInstances) { 46 var hasMultipleRows = this.subRows.length > 1; 47 var track = new tr.ui.tracks.ObjectInstanceTrack(this.viewport); 48 track.objectInstances = objectInstances; 49 this.appendChild(track); 50 return track; 51 }, 52 53 buildSubRows_: function(objectInstances) { 54 objectInstances.sort(function(x, y) { 55 return x.creationTs - y.creationTs; 56 }); 57 58 var subRows = []; 59 for (var i = 0; i < objectInstances.length; i++) { 60 var objectInstance = objectInstances[i]; 61 62 var found = false; 63 for (var j = 0; j < subRows.length; j++) { 64 var subRow = subRows[j]; 65 var lastItemInSubRow = subRow[subRow.length - 1]; 66 if (objectInstance.creationTs >= lastItemInSubRow.deletionTs) { 67 found = true; 68 subRow.push(objectInstance); 69 break; 70 } 71 } 72 if (!found) { 73 var subRow = [objectInstance]; 74 subRows.push(subRow); 75 } 76 } 77 return subRows; 78 }, 79 updateHeadingAndTooltip_: function() { 80 } 81 }; 82 83 return { 84 ObjectInstanceGroupTrack: ObjectInstanceGroupTrack 85 }; 86}); 87</script> 88