1<!DOCTYPE html> 2<!-- 3Copyright (c) 2015 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/chart_track.html"> 9<link rel="import" href="/tracing/ui/tracks/container_track.html"> 10<link rel="import" href="/tracing/ui/tracks/letter_dot_track.html"> 11<link rel="import" href="/tracing/ui/tracks/memory_dump_track_util.html"> 12 13<script> 14'use strict'; 15 16tr.exportTo('tr.ui.tracks', function() { 17 18 var USED_MEMORY_TRACK_HEIGHT = 50; 19 var ALLOCATED_MEMORY_TRACK_HEIGHT = 50; 20 21 /** 22 * A track that displays an array of GlobalMemoryDump objects. 23 * @constructor 24 * @extends {ContainerTrack} 25 */ 26 var GlobalMemoryDumpTrack = tr.ui.b.define( 27 'global-memory-dump-track', tr.ui.tracks.ContainerTrack); 28 29 GlobalMemoryDumpTrack.prototype = { 30 __proto__: tr.ui.tracks.ContainerTrack.prototype, 31 32 decorate: function(viewport) { 33 tr.ui.tracks.ContainerTrack.prototype.decorate.call(this, viewport); 34 this.memoryDumps_ = undefined; 35 }, 36 37 get memoryDumps() { 38 return this.memoryDumps_; 39 }, 40 41 set memoryDumps(memoryDumps) { 42 this.memoryDumps_ = memoryDumps; 43 this.updateContents_(); 44 }, 45 46 updateContents_: function() { 47 this.clearTracks_(); 48 49 // Show no tracks if there are no dumps. 50 if (!this.memoryDumps_ || !this.memoryDumps_.length) 51 return; 52 53 this.appendDumpDotsTrack_(); 54 this.appendUsedMemoryTrack_(); 55 this.appendAllocatedMemoryTrack_(); 56 }, 57 58 appendDumpDotsTrack_: function() { 59 var items = tr.ui.tracks.buildMemoryLetterDots(this.memoryDumps_); 60 if (!items) 61 return; 62 63 var track = new tr.ui.tracks.LetterDotTrack(this.viewport); 64 track.heading = 'Memory Dumps'; 65 track.items = items; 66 this.appendChild(track); 67 }, 68 69 appendUsedMemoryTrack_: function() { 70 var series = tr.ui.tracks.buildGlobalUsedMemoryChartSeries( 71 this.memoryDumps_); 72 if (!series) 73 return; 74 75 var track = new tr.ui.tracks.ChartTrack(this.viewport); 76 track.heading = 'Memory per process'; 77 track.height = USED_MEMORY_TRACK_HEIGHT + 'px'; 78 track.series = series; 79 track.autoSetAllAxes({expandMax: true}); 80 this.appendChild(track); 81 }, 82 83 appendAllocatedMemoryTrack_: function() { 84 var series = tr.ui.tracks.buildGlobalAllocatedMemoryChartSeries( 85 this.memoryDumps_); 86 if (!series) 87 return; 88 89 var track = new tr.ui.tracks.ChartTrack(this.viewport); 90 track.heading = 'Memory per component'; 91 track.height = ALLOCATED_MEMORY_TRACK_HEIGHT + 'px'; 92 track.series = series; 93 track.autoSetAllAxes({expandMax: true}); 94 this.appendChild(track); 95 } 96 }; 97 98 return { 99 GlobalMemoryDumpTrack: GlobalMemoryDumpTrack 100 }; 101}); 102</script> 103