| <!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="/base/ui/color_legend.html"> |
| <link rel="import" href="/core/analysis/memory_dump_sub_view_util.html"> |
| <link rel="import" href="/core/analysis/size_span.html"> |
| <link rel="import" href="/core/analysis/table_builder.html"> |
| <link rel="import" href="/core/trace_model/attribute.html"> |
| |
| <polymer-element name="tv-c-memory-dump-overview-pane"> |
| <template> |
| <style> |
| :host { |
| display: flex; |
| flex-direction: column; |
| } |
| |
| #label { |
| flex: 0 0 auto; |
| padding: 8px; |
| |
| background-color: #eee; |
| border-bottom: 1px solid #8e8e8e; |
| border-top: 1px solid white; |
| |
| font-size: 15px; |
| font-weight: bold; |
| } |
| |
| #table { |
| flex: 1 1 auto; |
| align-self: stretch; |
| } |
| </style> |
| <div id="label">Overview</div> |
| <tracing-analysis-nested-table id="table"> |
| </tracing-analysis-nested-table> |
| </template> |
| <script> |
| 'use strict'; |
| |
| Polymer({ |
| // TODO(petrcermak): Consider sharing more code between |
| // tv-c-memory-dump-overview-pane and tv-c-memory-dump-process pane |
| // (e.g. by defining a common base class tv-c-memory-dump-pane). |
| |
| created: function() { |
| this.processMemoryDumps_ = undefined; |
| }, |
| |
| ready: function() { |
| this.$.table.supportsSelection = true; |
| this.$.table.cellSelectionMode = true; |
| this.$.table.addEventListener('selection-changed', function(tableEvent) { |
| tableEvent.stopPropagation(); |
| var paneEvent = new Event('selected-memory-dump-changed', false, false); |
| this.dispatchEvent(paneEvent); |
| }.bind(this)); |
| }, |
| |
| set processMemoryDumps(processMemoryDumps) { |
| this.processMemoryDumps_ = processMemoryDumps; |
| this.updateContents_(); |
| }, |
| |
| get processMemoryDumps() { |
| return this.processMemoryDumps_; |
| }, |
| |
| get selectedMemoryDump() { |
| var selectedTableRow = this.$.table.selectedTableRow; |
| if (!selectedTableRow) |
| return undefined; |
| |
| var selectedColumnIndex = this.$.table.selectedColumnIndex; |
| if (selectedColumnIndex === undefined) |
| return undefined; |
| |
| var selectedColumn = this.$.table.tableColumns[selectedColumnIndex]; |
| var selectedCell = selectedColumn.cell(selectedTableRow); |
| if (!selectedCell) |
| return undefined; |
| |
| return selectedCell.dump; |
| }, |
| |
| updateContents_: function() { |
| var processMemoryDumps = this.processMemoryDumps_ || []; |
| |
| var rows = processMemoryDumps.map(function(processMemoryDump) { |
| // Used memory (proportional, private, and shared resident) |
| var usedMemorySizes = {}; |
| function addUsedMemorySize(columnKey, dumpKey) { |
| var value = processMemoryDump[dumpKey]; |
| if (value !== undefined) { |
| usedMemorySizes[columnKey] = new tv.c.analysis.MemoryCell( |
| new tv.c.trace_model.ScalarAttribute('bytes', value)); |
| } |
| } |
| addUsedMemorySize('proportional_resident', |
| 'mostRecentTotalProportionalResidentSizeInBytes'); |
| addUsedMemorySize('private_resident', |
| 'mostRecentTotalPrivateResidentSizeInBytes'); |
| addUsedMemorySize('shared_resident', |
| 'mostRecentTotalSharedResidentSizeInBytes'); |
| |
| // Allocator memory (v8, oilpan, ...). |
| var allocatorSizes = {}; |
| if (processMemoryDump.memoryAllocatorDumps !== undefined) { |
| processMemoryDump.memoryAllocatorDumps.forEach(function(dump) { |
| var cell = new tv.c.analysis.MemoryCell( |
| dump.attributes['outer_size']); |
| cell.dump = dump; |
| allocatorSizes[dump.fullName] = cell; |
| }, this); |
| } |
| |
| return { |
| title: processMemoryDump.process.userFriendlyName, |
| usedMemorySizes: usedMemorySizes, |
| allocatorSizes: allocatorSizes |
| }; |
| }, this); |
| this.$.table.tableRows = rows; |
| |
| this.updateColumns_(rows); |
| |
| this.$.table.rebuild(); |
| }, |
| |
| updateColumns_: function(rows) { |
| var titleColumn = { |
| title: 'Process', |
| value: function(row) { |
| var titleEl = document.createElement('tv-b-color-legend'); |
| titleEl.label = row.title; |
| return titleEl; |
| }, |
| width: '200px', |
| cmp: function(rowA, rowB) { |
| return rowA.title.localeCompare(rowB.title); |
| }, |
| supportsCellSelection: false |
| }; |
| |
| var usedMemorySizeColumns = tv.c.analysis.MemoryColumn.fromRows( |
| rows, 'usedMemorySizes'); |
| var allocatorSizeColumns = tv.c.analysis.MemoryColumn.fromRows( |
| rows, 'allocatorSizes'); |
| |
| var sizeColumns = usedMemorySizeColumns.concat(allocatorSizeColumns); |
| tv.c.analysis.MemoryColumn.spaceEqually(sizeColumns); |
| |
| var columns = [titleColumn].concat(sizeColumns); |
| this.$.table.tableColumns = columns; |
| } |
| }); |
| </script> |
| </polymer-element> |