Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(361)

Side by Side Diff: Source/devtools/front_end/HeapSnapshot.js

Issue 209653003: Introduce HeapSnapshotItem interface (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 /** 31 /**
32 * @interface
33 */
34 WebInspector.HeapSnapshotItem = function() { }
35
36 WebInspector.HeapSnapshotItem.prototype = {
37 /**
38 * @return {number}
39 */
40 itemIndex: function() { },
41
42 /**
43 * @return {!Object}
44 */
45 serialize: function() { }
46 };
47
48 /**
32 * @constructor 49 * @constructor
50 * @implements {WebInspector.HeapSnapshotItem}
33 * @param {!WebInspector.HeapSnapshot} snapshot 51 * @param {!WebInspector.HeapSnapshot} snapshot
34 * @param {number=} edgeIndex 52 * @param {number=} edgeIndex
35 */ 53 */
36 WebInspector.HeapSnapshotEdge = function(snapshot, edgeIndex) 54 WebInspector.HeapSnapshotEdge = function(snapshot, edgeIndex)
37 { 55 {
38 this._snapshot = snapshot; 56 this._snapshot = snapshot;
39 this._edges = snapshot._containmentEdges; 57 this._edges = snapshot._containmentEdges;
40 this.edgeIndex = edgeIndex || 0; 58 this.edgeIndex = edgeIndex || 0;
41 } 59 }
42 60
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 125
108 /** 126 /**
109 * @return {string} 127 * @return {string}
110 */ 128 */
111 type: function() 129 type: function()
112 { 130 {
113 return this._snapshot._edgeTypes[this._type()]; 131 return this._snapshot._edgeTypes[this._type()];
114 }, 132 },
115 133
116 /** 134 /**
135 * @override
136 * @return {number}
137 */
138 itemIndex: function()
139 {
140 return this.edgeIndex;
141 },
142
143 /**
144 * @override
117 * @return {!WebInspector.HeapSnapshotEdge.Serialized} 145 * @return {!WebInspector.HeapSnapshotEdge.Serialized}
118 */ 146 */
119 serialize: function() 147 serialize: function()
120 { 148 {
121 var node = this.node(); 149 var node = this.node();
122 return new WebInspector.HeapSnapshotEdge.Serialized(this.name(), node.se rialize(), this.nodeIndex(), this.type(), node.distance()); 150 return new WebInspector.HeapSnapshotEdge.Serialized(this.name(), node.se rialize(), this.nodeIndex(), this.type(), node.distance());
123 }, 151 },
124 152
125 _type: function() 153 _type: function()
126 { 154 {
127 return this._edges[this.edgeIndex + this._snapshot._edgeTypeOffset]; 155 return this._edges[this.edgeIndex + this._snapshot._edgeTypeOffset];
128 } 156 }
129 }; 157 };
130 158
131 159
132
133 /** 160 /**
134 * @interface 161 * @interface
135 */ 162 */
136 WebInspector.HeapSnapshotItemIterator = function() { } 163 WebInspector.HeapSnapshotItemIterator = function() { }
137 164
138 WebInspector.HeapSnapshotItemIterator.prototype = { 165 WebInspector.HeapSnapshotItemIterator.prototype = {
139 /** 166 /**
140 * @return {boolean} 167 * @return {boolean}
141 */ 168 */
142 hasNext: function() { }, 169 hasNext: function() { },
143 170
144 /** 171 /**
145 * @return {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!W ebInspector.HeapSnapshotRetainerEdge} 172 * @return {!WebInspector.HeapSnapshotItem}
146 */ 173 */
147 item: function() { }, 174 item: function() { },
148 175
149 next: function() { } 176 next: function() { }
150 }; 177 };
151 178
152 179
153 /** 180 /**
154 * @interface 181 * @interface
155 */ 182 */
156 WebInspector.HeapSnapshotItemIndexProvider = function() { } 183 WebInspector.HeapSnapshotItemIndexProvider = function() { }
157 184
158 WebInspector.HeapSnapshotItemIndexProvider.prototype = { 185 WebInspector.HeapSnapshotItemIndexProvider.prototype = {
159 /** 186 /**
160 * @param {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!We bInspector.HeapSnapshotRetainerEdge} item
161 * @return {number}
162 */
163 indexForItem: function(item) { },
164
165 /**
166 * @param {number} newIndex 187 * @param {number} newIndex
167 * @return {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!W ebInspector.HeapSnapshotRetainerEdge} 188 * @return {!WebInspector.HeapSnapshotItem}
168 */ 189 */
169 itemForIndex: function(newIndex) { }, 190 itemForIndex: function(newIndex) { },
170 }; 191 };
171 192
172 /** 193 /**
173 * @constructor 194 * @constructor
174 * @implements {WebInspector.HeapSnapshotItemIndexProvider} 195 * @implements {WebInspector.HeapSnapshotItemIndexProvider}
175 * @param {!WebInspector.HeapSnapshot} snapshot 196 * @param {!WebInspector.HeapSnapshot} snapshot
176 */ 197 */
177 WebInspector.HeapSnapshotNodeIndexProvider = function(snapshot) 198 WebInspector.HeapSnapshotNodeIndexProvider = function(snapshot)
178 { 199 {
179 this._node = snapshot.createNode(); 200 this._node = snapshot.createNode();
180 } 201 }
181 202
182 WebInspector.HeapSnapshotNodeIndexProvider.prototype = { 203 WebInspector.HeapSnapshotNodeIndexProvider.prototype = {
183 /** 204 /**
184 * @param {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!We bInspector.HeapSnapshotRetainerEdge} item
185 * @return {number}
186 */
187 indexForItem: function(item)
188 {
189 var node = /** @type {!WebInspector.HeapSnapshotNode} */ (item);
190 return node.nodeIndex;
191 },
192
193 /**
194 * @param {number} index 205 * @param {number} index
195 * @return {!WebInspector.HeapSnapshotNode} 206 * @return {!WebInspector.HeapSnapshotNode}
196 */ 207 */
197 itemForIndex: function(index) 208 itemForIndex: function(index)
198 { 209 {
199 this._node.nodeIndex = index; 210 this._node.nodeIndex = index;
200 return this._node; 211 return this._node;
201 } 212 }
202 }; 213 };
203 214
204 215
205 /** 216 /**
206 * @constructor 217 * @constructor
207 * @implements {WebInspector.HeapSnapshotItemIndexProvider} 218 * @implements {WebInspector.HeapSnapshotItemIndexProvider}
208 * @param {!WebInspector.HeapSnapshot} snapshot 219 * @param {!WebInspector.HeapSnapshot} snapshot
209 */ 220 */
210 WebInspector.HeapSnapshotEdgeIndexProvider = function(snapshot) 221 WebInspector.HeapSnapshotEdgeIndexProvider = function(snapshot)
211 { 222 {
212 this._edge = snapshot.createEdge(0); 223 this._edge = snapshot.createEdge(0);
213 } 224 }
214 225
215 WebInspector.HeapSnapshotEdgeIndexProvider.prototype = { 226 WebInspector.HeapSnapshotEdgeIndexProvider.prototype = {
216 /** 227 /**
217 * @param {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!We bInspector.HeapSnapshotRetainerEdge} item
218 * @return {number}
219 */
220 indexForItem: function(item)
221 {
222 var edge = /** @type {!WebInspector.HeapSnapshotEdge} */ (item);
223 return edge.edgeIndex;
224 },
225
226 /**
227 * @param {number} index 228 * @param {number} index
228 * @return {!WebInspector.HeapSnapshotEdge} 229 * @return {!WebInspector.HeapSnapshotEdge}
229 */ 230 */
230 itemForIndex: function(index) 231 itemForIndex: function(index)
231 { 232 {
232 this._edge.edgeIndex = index; 233 this._edge.edgeIndex = index;
233 return this._edge; 234 return this._edge;
234 } 235 }
235 }; 236 };
236 237
237 238
238 /** 239 /**
239 * @constructor 240 * @constructor
240 * @implements {WebInspector.HeapSnapshotItemIndexProvider} 241 * @implements {WebInspector.HeapSnapshotItemIndexProvider}
241 * @param {!WebInspector.HeapSnapshot} snapshot 242 * @param {!WebInspector.HeapSnapshot} snapshot
242 */ 243 */
243 WebInspector.HeapSnapshotRetainerEdgeIndexProvider = function(snapshot) 244 WebInspector.HeapSnapshotRetainerEdgeIndexProvider = function(snapshot)
244 { 245 {
245 this._retainerEdge = snapshot.createRetainingEdge(0); 246 this._retainerEdge = snapshot.createRetainingEdge(0);
246 } 247 }
247 248
248 WebInspector.HeapSnapshotRetainerEdgeIndexProvider.prototype = { 249 WebInspector.HeapSnapshotRetainerEdgeIndexProvider.prototype = {
249 /** 250 /**
250 * @param {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!We bInspector.HeapSnapshotRetainerEdge} item
251 * @return {number}
252 */
253 indexForItem: function(item)
254 {
255 var edge = /** @type {!WebInspector.HeapSnapshotRetainerEdge} */ (item);
256 return edge.retainerIndex();
257 },
258
259 /**
260 * @param {number} index 251 * @param {number} index
261 * @return {!WebInspector.HeapSnapshotRetainerEdge} 252 * @return {!WebInspector.HeapSnapshotRetainerEdge}
262 */ 253 */
263 itemForIndex: function(index) 254 itemForIndex: function(index)
264 { 255 {
265 this._retainerEdge.setRetainerIndex(index); 256 this._retainerEdge.setRetainerIndex(index);
266 return this._retainerEdge; 257 return this._retainerEdge;
267 } 258 }
268 }; 259 };
269 260
(...skipping 27 matching lines...) Expand all
297 }, 288 },
298 289
299 next: function() 290 next: function()
300 { 291 {
301 this.edge.edgeIndex += this.edge._snapshot._edgeFieldsCount; 292 this.edge.edgeIndex += this.edge._snapshot._edgeFieldsCount;
302 } 293 }
303 }; 294 };
304 295
305 /** 296 /**
306 * @constructor 297 * @constructor
298 * @implements {WebInspector.HeapSnapshotItem}
307 * @param {!WebInspector.HeapSnapshot} snapshot 299 * @param {!WebInspector.HeapSnapshot} snapshot
308 * @param {number} retainerIndex 300 * @param {number} retainerIndex
309 */ 301 */
310 WebInspector.HeapSnapshotRetainerEdge = function(snapshot, retainerIndex) 302 WebInspector.HeapSnapshotRetainerEdge = function(snapshot, retainerIndex)
311 { 303 {
312 this._snapshot = snapshot; 304 this._snapshot = snapshot;
313 this.setRetainerIndex(retainerIndex); 305 this.setRetainerIndex(retainerIndex);
314 } 306 }
315 307
316 /** 308 /**
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 408
417 /** 409 /**
418 * @return {string} 410 * @return {string}
419 */ 411 */
420 toString: function() 412 toString: function()
421 { 413 {
422 return this._edge().toString(); 414 return this._edge().toString();
423 }, 415 },
424 416
425 /** 417 /**
418 * @override
419 * @return {number}
420 */
421 itemIndex: function()
422 {
423 return this._retainerIndex;
424 },
425
426 /**
427 * @override
426 * @return {!WebInspector.HeapSnapshotRetainerEdge.Serialized} 428 * @return {!WebInspector.HeapSnapshotRetainerEdge.Serialized}
427 */ 429 */
428 serialize: function() 430 serialize: function()
429 { 431 {
430 var node = this.node(); 432 var node = this.node();
431 return new WebInspector.HeapSnapshotRetainerEdge.Serialized(this.name(), node.serialize(), this.nodeIndex(), this.type(), node.distance()); 433 return new WebInspector.HeapSnapshotRetainerEdge.Serialized(this.name(), node.serialize(), this.nodeIndex(), this.type(), node.distance());
432 }, 434 },
433 435
434 /** 436 /**
435 * @return {string} 437 * @return {string}
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 }, 474 },
473 475
474 next: function() 476 next: function()
475 { 477 {
476 this.retainer.setRetainerIndex(this.retainer.retainerIndex() + 1); 478 this.retainer.setRetainerIndex(this.retainer.retainerIndex() + 1);
477 } 479 }
478 }; 480 };
479 481
480 /** 482 /**
481 * @constructor 483 * @constructor
484 * @implements {WebInspector.HeapSnapshotItem}
485 * @param {!WebInspector.HeapSnapshot} snapshot
482 * @param {number=} nodeIndex 486 * @param {number=} nodeIndex
483 */ 487 */
484 WebInspector.HeapSnapshotNode = function(snapshot, nodeIndex) 488 WebInspector.HeapSnapshotNode = function(snapshot, nodeIndex)
485 { 489 {
486 this._snapshot = snapshot; 490 this._snapshot = snapshot;
487 this.nodeIndex = nodeIndex; 491 this.nodeIndex = nodeIndex || 0;
488 } 492 }
489 493
490 /** 494 /**
491 * @constructor 495 * @constructor
492 * @param {string} id 496 * @param {string} id
493 * @param {string} name 497 * @param {string} name
494 * @param {number} distance 498 * @param {number} distance
495 * @param {number|undefined} nodeIndex 499 * @param {number|undefined} nodeIndex
496 * @param {number} retainedSize 500 * @param {number} retainedSize
497 * @param {number} selfSize 501 * @param {number} selfSize
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 /** 628 /**
625 * @return {number} 629 * @return {number}
626 */ 630 */
627 traceNodeId: function() 631 traceNodeId: function()
628 { 632 {
629 var snapshot = this._snapshot; 633 var snapshot = this._snapshot;
630 return snapshot._nodes[this.nodeIndex + snapshot._nodeTraceNodeIdOffset] ; 634 return snapshot._nodes[this.nodeIndex + snapshot._nodeTraceNodeIdOffset] ;
631 }, 635 },
632 636
633 /** 637 /**
638 * @override
639 * @return {number}
640 */
641 itemIndex: function()
642 {
643 return this.nodeIndex;
644 },
645
646 /**
647 * @override
634 * @return {!WebInspector.HeapSnapshotNode.Serialized} 648 * @return {!WebInspector.HeapSnapshotNode.Serialized}
635 */ 649 */
636 serialize: function() 650 serialize: function()
637 { 651 {
638 return new WebInspector.HeapSnapshotNode.Serialized(this.id(), this.name (), this.distance(), this.nodeIndex, this.retainedSize(), this.selfSize(), this. type()); 652 return new WebInspector.HeapSnapshotNode.Serialized(this.id(), this.name (), this.distance(), this.nodeIndex, this.retainedSize(), this.selfSize(), this. type());
639 }, 653 },
640 654
641 /** 655 /**
642 * @return {number} 656 * @return {number}
643 */ 657 */
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 WebInspector.HeapSnapshotIndexRangeIterator.prototype = { 754 WebInspector.HeapSnapshotIndexRangeIterator.prototype = {
741 /** 755 /**
742 * @return {boolean} 756 * @return {boolean}
743 */ 757 */
744 hasNext: function() 758 hasNext: function()
745 { 759 {
746 return this._position < this._indexes.length 760 return this._position < this._indexes.length
747 }, 761 },
748 762
749 /** 763 /**
750 * @return {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!W ebInspector.HeapSnapshotRetainerEdge} 764 * @return {!WebInspector.HeapSnapshotItem}
751 */ 765 */
752 item: function() 766 item: function()
753 { 767 {
754 var index = this._indexes[this._position]; 768 var index = this._indexes[this._position];
755 return this._itemProvider.itemForIndex(index); 769 return this._itemProvider.itemForIndex(index);
756 }, 770 },
757 771
758 next: function() 772 next: function()
759 { 773 {
760 ++this._position; 774 ++this._position;
(...skipping 16 matching lines...) Expand all
777 WebInspector.HeapSnapshotFilteredIterator.prototype = { 791 WebInspector.HeapSnapshotFilteredIterator.prototype = {
778 /** 792 /**
779 * @return {boolean} 793 * @return {boolean}
780 */ 794 */
781 hasNext: function() 795 hasNext: function()
782 { 796 {
783 return this._iterator.hasNext(); 797 return this._iterator.hasNext();
784 }, 798 },
785 799
786 /** 800 /**
787 * @return {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!W ebInspector.HeapSnapshotRetainerEdge} 801 * @return {!WebInspector.HeapSnapshotItem}
788 */ 802 */
789 item: function() 803 item: function()
790 { 804 {
791 return this._iterator.item(); 805 return this._iterator.item();
792 }, 806 },
793 807
794 next: function() 808 next: function()
795 { 809 {
796 this._iterator.next(); 810 this._iterator.next();
797 this._skipFilteredItems(); 811 this._skipFilteredItems();
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 this._sortedSuffixLength = 0; 2078 this._sortedSuffixLength = 0;
2065 } 2079 }
2066 2080
2067 WebInspector.HeapSnapshotItemProvider.prototype = { 2081 WebInspector.HeapSnapshotItemProvider.prototype = {
2068 _createIterationOrder: function() 2082 _createIterationOrder: function()
2069 { 2083 {
2070 if (this._iterationOrder) 2084 if (this._iterationOrder)
2071 return; 2085 return;
2072 this._iterationOrder = []; 2086 this._iterationOrder = [];
2073 for (var iterator = this._iterator; iterator.hasNext(); iterator.next()) 2087 for (var iterator = this._iterator; iterator.hasNext(); iterator.next())
2074 this._iterationOrder.push(this._indexProvider.indexForItem(iterator. item())); 2088 this._iterationOrder.push(iterator.item().itemIndex());
2075 }, 2089 },
2076 2090
2077 /** 2091 /**
2078 * @return {boolean} 2092 * @return {boolean}
2079 */ 2093 */
2080 isEmpty: function() 2094 isEmpty: function()
2081 { 2095 {
2082 return this._isEmpty; 2096 return this._isEmpty;
2083 }, 2097 },
2084 2098
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 * @param {number} windowRight 2325 * @param {number} windowRight
2312 */ 2326 */
2313 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight) 2327 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight)
2314 { 2328 {
2315 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l eftBound, rightBound, windowLeft, windowRight); 2329 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l eftBound, rightBound, windowLeft, windowRight);
2316 }, 2330 },
2317 2331
2318 __proto__: WebInspector.HeapSnapshotItemProvider.prototype 2332 __proto__: WebInspector.HeapSnapshotItemProvider.prototype
2319 } 2333 }
2320 2334
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698