1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 'use strict'; 6 7 base.require('tracks.container_track'); 8 base.require('tracks.counter_track'); 9 base.require('tracks.thread_track'); 10 base.require('filter'); 11 base.require('ui'); 12 13 base.exportTo('tracing.tracks', function() { 14 15 /** 16 * Visualizes a Process by building ThreadTracks and CounterTracks. 17 * @constructor 18 */ 19 var ProcessTrack = 20 tracing.ui.define(tracing.tracks.ContainerTrack); 21 22 ProcessTrack.prototype = { 23 24 __proto__: tracing.tracks.ContainerTrack.prototype, 25 26 decorate: function() { 27 this.classList.add('process-track'); 28 this.categoryFilter_ = new tracing.Filter(); 29 }, 30 31 get process() { 32 return this.process_; 33 }, 34 35 set process(process) { 36 this.process_ = process; 37 this.updateChildTracks_(); 38 }, 39 40 applyCategoryFilter_: function() { 41 this.visible = (this.categoryFilter.matchProcess(this.process) && 42 !!this.numVisibleChildTracks); 43 }, 44 45 updateChildTracks_: function() { 46 this.detach(); 47 if (this.process_) { 48 // Add counter tracks for this process. 49 var counters = []; 50 for (var tid in this.process.counters) { 51 counters.push(this.process.counters[tid]); 52 } 53 counters.sort(tracing.model.Counter.compare); 54 55 // Create the counters for this process. 56 counters.forEach(function(counter) { 57 var track = new tracing.tracks.CounterTrack(); 58 track.heading = counter.name + ':'; 59 track.counter = counter; 60 this.addTrack_(track); 61 }.bind(this)); 62 63 // Get a sorted list of threads. 64 var threads = []; 65 for (var tid in this.process.threads) 66 threads.push(this.process.threads[tid]); 67 threads.sort(tracing.model.Thread.compare); 68 69 // Create the threads. 70 threads.forEach(function(thread) { 71 var track = new tracing.tracks.ThreadTrack(); 72 track.heading = thread.userFriendlyName + ':'; 73 track.tooltip = thread.userFriendlyDetails; 74 track.thread = thread; 75 this.addTrack_(track); 76 }.bind(this)); 77 } 78 } 79 }; 80 81 return { 82 ProcessTrack: ProcessTrack 83 }; 84 }); 85