blob: dda5d4fa4646abaaf5a67dee469f3945648c1171 [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="/core/trace_model/timed_event.html">
<script>
'use strict';
/**
* @fileoverview Provides the ContainerMemoryDump class.
*/
tv.exportTo('tv.c.trace_model', function() {
/**
* The ContainerMemoryDump represents an abstract container memory dump.
* @constructor
*/
function ContainerMemoryDump(start) {
tv.c.trace_model.TimedEvent.call(this, start);
this.memoryAllocatorDumps_ = undefined;
this.memoryAllocatorDumpsByFullName_ = undefined;
};
ContainerMemoryDump.prototype = {
__proto__: tv.c.trace_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>