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