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/tracks/process_track_base.html">
9<link rel="import" href="/tracing/ui/tracks/cpu_track.html">
10<link rel="import" href="/tracing/ui/tracks/spacing_track.html">
11
12<script>
13'use strict';
14
15tr.exportTo('tr.ui.tracks', function() {
16  var Cpu = tr.model.Cpu;
17  var CpuTrack = tr.ui.tracks.cpu_track;
18  var ProcessTrackBase = tr.ui.tracks.ProcessTrackBase;
19  var SpacingTrack = tr.ui.tracks.SpacingTrack;
20
21  /**
22   * @constructor
23   */
24  var KernelTrack = tr.ui.b.define('kernel-track', ProcessTrackBase);
25
26  KernelTrack.prototype = {
27    __proto__: ProcessTrackBase.prototype,
28
29    decorate: function(viewport) {
30      ProcessTrackBase.prototype.decorate.call(this, viewport);
31    },
32
33
34    // Kernel maps to processBase because we derive from ProcessTrackBase.
35    set kernel(kernel) {
36      this.processBase = kernel;
37    },
38
39    get kernel() {
40      return this.processBase;
41    },
42
43    get eventContainer() {
44      return this.kernel;
45    },
46
47    get hasVisibleContent() {
48      return this.children.length > 1;
49    },
50
51    addContainersToTrackMap: function(containerToTrackMap) {
52      tr.ui.tracks.ProcessTrackBase.prototype.addContainersToTrackMap.call(
53        this, containerToTrackMap);
54      containerToTrackMap.addContainer(this.kernel, this);
55    },
56
57    willAppendTracks_: function() {
58      var cpus = tr.b.dictionaryValues(this.kernel.cpus);
59      cpus.sort(tr.model.Cpu.compare);
60
61      var didAppendAtLeastOneTrack = false;
62      for (var i = 0; i < cpus.length; ++i) {
63        var cpu = cpus[i];
64        var track = new tr.ui.tracks.CpuTrack(this.viewport);
65        track.detailedMode = this.expanded;
66        track.cpu = cpu;
67        if (!track.hasVisibleContent)
68          continue;
69        this.appendChild(track);
70        didAppendAtLeastOneTrack = true;
71      }
72      if (didAppendAtLeastOneTrack)
73        this.appendChild(new SpacingTrack(this.viewport));
74    }
75  };
76
77
78  return {
79    KernelTrack: KernelTrack
80  };
81});
82</script>
83
84