blob: 940ebc6c001f303bc7d4307b37aa8626ae8624c8 [file] [log] [blame]
<!DOCTYPE html>
<!--
Copyright (c) 2015 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="/ui/tracks/chart_track.html">
<link rel="import" href="/ui/tracks/container_track.html">
<link rel="import" href="/ui/tracks/letter_dot_track.html">
<link rel="import" href="/ui/tracks/memory_dump_track_util.html">
<script>
'use strict';
tr.exportTo('tr.ui.tracks', function() {
var USED_MEMORY_TRACK_HEIGHT = 50;
var ALLOCATED_MEMORY_TRACK_HEIGHT = 50;
/**
* A track that displays an array of GlobalMemoryDump objects.
* @constructor
* @extends {ContainerTrack}
*/
var GlobalMemoryDumpTrack = tr.ui.b.define(
'global-memory-dump-track', tr.ui.tracks.ContainerTrack);
GlobalMemoryDumpTrack.prototype = {
__proto__: tr.ui.tracks.ContainerTrack.prototype,
decorate: function(viewport) {
tr.ui.tracks.ContainerTrack.prototype.decorate.call(this, viewport);
this.memoryDumps_ = undefined;
},
get memoryDumps() {
return this.memoryDumps_;
},
set memoryDumps(memoryDumps) {
this.memoryDumps_ = memoryDumps;
this.updateContents_();
},
updateContents_: function() {
this.clearTracks_();
// Show no tracks if there are no dumps.
if (!this.memoryDumps_ || !this.memoryDumps_.length)
return;
this.appendDumpDotsTrack_();
this.appendUsedMemoryTrack_();
this.appendAllocatedMemoryTrack_();
},
appendDumpDotsTrack_: function() {
var items = tr.ui.tracks.buildMemoryLetterDots(this.memoryDumps_);
if (!items)
return;
var track = new tr.ui.tracks.LetterDotTrack(this.viewport);
track.heading = 'Memory Dumps';
track.items = items;
this.appendChild(track);
},
appendUsedMemoryTrack_: function() {
var series = tr.ui.tracks.buildGlobalUsedMemoryChartSeries(
this.memoryDumps_);
if (!series)
return;
var track = new tr.ui.tracks.ChartTrack(this.viewport);
track.heading = 'Used memory (per process)';
track.height = USED_MEMORY_TRACK_HEIGHT + 'px';
track.series = series;
track.autoSetAllAxes({expandMax: true});
this.appendChild(track);
},
appendAllocatedMemoryTrack_: function() {
var series = tr.ui.tracks.buildGlobalAllocatedMemoryChartSeries(
this.memoryDumps_);
if (!series)
return;
var track = new tr.ui.tracks.ChartTrack(this.viewport);
track.heading = 'Allocated memory (per allocator)';
track.height = ALLOCATED_MEMORY_TRACK_HEIGHT + 'px';
track.series = series;
track.autoSetAllAxes({expandMax: true});
this.appendChild(track);
}
};
return {
GlobalMemoryDumpTrack: GlobalMemoryDumpTrack
};
});
</script>