Home | History | Annotate | Download | only in tracks
      1 // Copyright (c) 2013 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('tracing.tracks.process_track_base');
      8 base.require('tracing.tracks.cpu_track');
      9 base.require('tracing.tracks.spacing_track');
     10 
     11 base.exportTo('tracing.tracks', function() {
     12   var Cpu = tracing.trace_model.Cpu;
     13   var CpuTrack = tracing.tracks.cpu_track;
     14   var ProcessTrackBase = tracing.tracks.ProcessTrackBase;
     15   var SpacingTrack = tracing.tracks.SpacingTrack;
     16 
     17   /**
     18    * @constructor
     19    */
     20   var KernelTrack = ui.define('kernel-track', ProcessTrackBase);
     21 
     22   KernelTrack.prototype = {
     23     __proto__: ProcessTrackBase.prototype,
     24 
     25     decorate: function(viewport) {
     26       tracing.tracks.ProcessTrackBase.prototype.decorate.call(this, viewport);
     27     },
     28 
     29 
     30     // Kernel maps to processBase because we derive from ProcessTrackBase.
     31     set kernel(kernel) {
     32       this.processBase = kernel;
     33     },
     34 
     35     get kernel() {
     36       return this.processBase;
     37     },
     38 
     39     willAppendTracks_: function() {
     40       var categoryFilter = this.categoryFilter;
     41 
     42       var cpus = base.dictionaryValues(this.kernel.cpus);
     43       cpus.sort(tracing.trace_model.Cpu.compare);
     44 
     45       var didAppendAtLeastOneTrack = false;
     46       for (var i = 0; i < cpus.length; ++i) {
     47         var cpu = cpus[i];
     48         if (!categoryFilter.matchCpu(cpu))
     49           return;
     50         var track = new tracing.tracks.CpuTrack(this.viewport);
     51         track.categoryFilter = categoryFilter;
     52         track.cpu = cpu;
     53         if (!track.hasVisibleContent)
     54           continue;
     55         this.appendChild(track);
     56         didAppendAtLeastOneTrack = true;
     57       }
     58       if (didAppendAtLeastOneTrack)
     59         this.appendChild(new SpacingTrack(this.viewport));
     60     }
     61   };
     62 
     63 
     64   return {
     65     KernelTrack: KernelTrack
     66   };
     67 });
     68