| <!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="/model/attribute.html"> |
| |
| <script> |
| 'use strict'; |
| |
| /** |
| * @fileoverview Provides the MemoryAllocatorDump class. |
| */ |
| tr.exportTo('tr.model', function() { |
| /** |
| * @constructor |
| */ |
| function MemoryAllocatorDump(containerMemoryDump, fullName, opt_guid) { |
| this.fullName = fullName; |
| this.parent = undefined; |
| this.children = []; |
| this.attributes = {}; |
| |
| // The associated container memory dump. |
| this.containerMemoryDump = containerMemoryDump; |
| |
| // Ownership relationship between memory allocator dumps. |
| this.owns = undefined; |
| this.ownedBy = []; |
| |
| // Retention relationship between memory allocator dumps. |
| this.retains = []; |
| this.retainedBy = []; |
| |
| // For debugging purposes. |
| this.guid = opt_guid; |
| }; |
| |
| MemoryAllocatorDump.prototype = { |
| get name() { |
| return this.fullName.substring(this.fullName.lastIndexOf('/') + 1); |
| }, |
| |
| addAttribute: function(name, value) { |
| if (name in this.attributes) |
| throw new Error('Duplicate attribute name: ' + name + '.'); |
| this.attributes[name] = value; |
| }, |
| |
| aggregateAttributes: function(opt_model) { |
| var attributes = {}; |
| |
| this.children.forEach(function(child) { |
| child.aggregateAttributes(opt_model); |
| tr.b.iterItems(child.attributes, function(name) { |
| attributes[name] = true; |
| }, this); |
| }, this); |
| |
| tr.b.iterItems(attributes, function(name) { |
| var childAttributes = this.children.map(function(child) { |
| return child.attributes[name]; |
| }, this); |
| var currentAttribute = this.attributes[name]; |
| this.attributes[name] = tr.model.Attribute.aggregate( |
| childAttributes, currentAttribute, opt_model); |
| }, this); |
| } |
| }; |
| |
| /** |
| * @constructor |
| */ |
| function MemoryAllocatorDumpLink(source, target, opt_importance) { |
| this.source = source; |
| this.target = target; |
| this.importance = opt_importance; |
| } |
| |
| return { |
| MemoryAllocatorDump: MemoryAllocatorDump, |
| MemoryAllocatorDumpLink: MemoryAllocatorDumpLink |
| }; |
| }); |
| </script> |