blob: 3abda063566601c5685461c700ff89490f8488b4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
<!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="/tracing/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.levelOfDetail = undefined;
this.memoryAllocatorDumps_ = undefined;
this.memoryAllocatorDumpsByFullName_ = undefined;
};
/**
* Memory dump level of detail. See base::trace_event::MemoryDumpLevelOfDetail
* in the Chromium repository.
*
* @enum
*/
ContainerMemoryDump.LevelOfDetail = {
LIGHT: 0,
DETAILED: 1
};
ContainerMemoryDump.prototype = {
__proto__: tr.model.TimedEvent.prototype,
shiftTimestampsForward: function(amount) {
this.start += amount;
},
get memoryAllocatorDumps() {
return this.memoryAllocatorDumps_;
},
set memoryAllocatorDumps(memoryAllocatorDumps) {
this.memoryAllocatorDumps_ = memoryAllocatorDumps;
this.forceRebuildingMemoryAllocatorDumpByFullNameIndex();
},
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];
},
forceRebuildingMemoryAllocatorDumpByFullNameIndex: function() {
// Clear the index and generate it lazily.
this.memoryAllocatorDumpsByFullName_ = undefined;
},
iterateRootAllocatorDumps: function(fn, opt_this) {
if (this.memoryAllocatorDumps === undefined)
return;
this.memoryAllocatorDumps.forEach(fn, opt_this || this);
}
};
return {
ContainerMemoryDump: ContainerMemoryDump
};
});
</script>
|