blob: 7ae41b156798aeba655361d1d8a688da1d97a811 [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="/model/timed_event.html">
<script>
'use strict';
/**
* @fileoverview Provides the ContainerMemoryDump class.
*/
tr.exportTo('tr.model', function() {
/**
* The ContainerMemoryDump represents an abstract container memory dump.
* @constructor
*/
function ContainerMemoryDump(start) {
tr.model.TimedEvent.call(this, start);
this.memoryAllocatorDumps_ = undefined;
this.memoryAllocatorDumpsByFullName_ = undefined;
};
ContainerMemoryDump.prototype = {
__proto__: tr.model.TimedEvent.prototype,
shiftTimestampsForward: function(amount) {
this.start += amount;
},
get memoryAllocatorDumps() {
return this.memoryAllocatorDumps_;
},
set memoryAllocatorDumps(memoryAllocatorDumps) {
this.memoryAllocatorDumps_ = memoryAllocatorDumps;
// Clear the index and generate it lazily.
this.memoryAllocatorDumpsByFullName_ = undefined;
},
getMemoryAllocatorDumpByFullName: function(fullName) {
if (this.memoryAllocatorDumps_ === undefined)
return undefined;
// Lazily generate the index if necessary.
if (this.memoryAllocatorDumpsByFullName_ === undefined) {
var index = {};
function addDumpsToIndex(dumps) {
dumps.forEach(function(dump) {
index[dump.fullName] = dump;
addDumpsToIndex(dump.children);
});
};
addDumpsToIndex(this.memoryAllocatorDumps_);
this.memoryAllocatorDumpsByFullName_ = index;
}
return this.memoryAllocatorDumpsByFullName_[fullName];
}
};
return {
ContainerMemoryDump: ContainerMemoryDump
};
});
</script>