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.timeline_container_track'); 8 base.require('tracks.timeline_slice_track'); 9 base.require('timeline_filter'); 10 base.require('timeline_model'); 11 base.require('ui'); 12 base.exportTo('tracks', function() { 13 14 /** 15 * Visualizes a TimelineCpu using a series of of TimelineSliceTracks. 16 * @constructor 17 */ 18 var TimelineCpuTrack = base.ui.define(tracks.TimelineContainerTrack); 19 TimelineCpuTrack.prototype = { 20 __proto__: tracks.TimelineContainerTrack.prototype, 21 22 decorate: function() { 23 this.classList.add('timeline-cpu-track'); 24 }, 25 26 get cpu() { 27 return this.cpu_; 28 }, 29 30 set cpu(cpu) { 31 this.cpu_ = cpu; 32 this.updateChildTracks_(); 33 }, 34 35 get tooltip() { 36 return this.tooltip_; 37 }, 38 39 set tooltip(value) { 40 this.tooltip_ = value; 41 this.updateChildTracks_(); 42 }, 43 44 get heading() { 45 return this.heading_; 46 }, 47 48 set heading(h) { 49 this.heading_ = h; 50 this.updateChildTracks_(); 51 }, 52 53 applyCategoryFilter_: function() { 54 if (this.categoryFilter.matchCpu(this.cpu_)) 55 this.updateChildTracks_(); 56 else 57 this.visible = false; 58 }, 59 60 updateChildTracks_: function() { 61 this.detach(); 62 if (this.cpu_) { 63 var slices = tracing.filterSliceArray(this.categoryFilter_, 64 this.cpu_.slices); 65 if (slices.length) { 66 var track = new tracks.TimelineSliceTrack(); 67 track.slices = slices; 68 track.heading = this.heading_; 69 track.tooltip = this.tooltip_; 70 this.addTrack_(track); 71 } 72 73 for (var counterName in this.cpu_.counters) { 74 var counter = this.cpu_.counters[counterName]; 75 track = new tracks.TimelineCounterTrack(); 76 track.heading = 'CPU ' + this.cpu_.cpuNumber + ' ' + 77 counter.name + ':'; 78 track.counter = counter; 79 this.addTrack_(track); 80 } 81 } 82 this.addControlButtonElements_(false); 83 } 84 }; 85 86 return { 87 TimelineCpuTrack: TimelineCpuTrack 88 }; 89 }); 90