| <!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="/core/tracks/chart_track.html"> |
| <link rel="import" href="/core/tracks/container_track.html"> |
| <link rel="import" href="/core/tracks/letter_dot_track.html"> |
| <link rel="import" href="/core/tracks/memory_dump_track_util.html"> |
| |
| <script> |
| 'use strict'; |
| |
| tv.exportTo('tv.c.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 = tv.b.ui.define( |
| 'global-memory-dump-track', tv.c.tracks.ContainerTrack); |
| |
| GlobalMemoryDumpTrack.prototype = { |
| __proto__: tv.c.tracks.ContainerTrack.prototype, |
| |
| decorate: function(viewport) { |
| tv.c.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.tracks_.forEach(function(track) { |
| this.removeChild(track); |
| }, this); |
| |
| // 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 = tv.c.tracks.buildMemoryLetterDots(this.memoryDumps_); |
| if (!items) |
| return; |
| |
| var track = new tv.c.tracks.LetterDotTrack(this.viewport); |
| track.heading = 'Memory Dumps'; |
| track.items = items; |
| this.appendChild(track); |
| }, |
| |
| appendUsedMemoryTrack_: function() { |
| var series = tv.c.tracks.buildGlobalUsedMemoryChartSeries( |
| this.memoryDumps_); |
| if (!series) |
| return; |
| |
| var track = new tv.c.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 = tv.c.tracks.buildGlobalAllocatedMemoryChartSeries( |
| this.memoryDumps_); |
| if (!series) |
| return; |
| |
| var track = new tv.c.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> |