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

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 12 matching lines...) Expand all
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 * @constructor 32 * @constructor
33 * @implements {WebInspector.HeapSnapshotItem}
33 * @param {!WebInspector.HeapSnapshot} snapshot 34 * @param {!WebInspector.HeapSnapshot} snapshot
34 * @param {number=} edgeIndex 35 * @param {number=} edgeIndex
35 */ 36 */
36 WebInspector.HeapSnapshotEdge = function(snapshot, edgeIndex) 37 WebInspector.HeapSnapshotEdge = function(snapshot, edgeIndex)
37 { 38 {
38 this._snapshot = snapshot; 39 this._snapshot = snapshot;
39 this._edges = snapshot._containmentEdges; 40 this._edges = snapshot._containmentEdges;
40 this.edgeIndex = edgeIndex || 0; 41 this.edgeIndex = edgeIndex || 0;
41 } 42 }
42 43
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 108
108 /** 109 /**
109 * @return {string} 110 * @return {string}
110 */ 111 */
111 type: function() 112 type: function()
112 { 113 {
113 return this._snapshot._edgeTypes[this._type()]; 114 return this._snapshot._edgeTypes[this._type()];
114 }, 115 },
115 116
116 /** 117 /**
118 * @override
119 * @return {number}
120 */
121 itemIndex: function()
122 {
123 return this.edgeIndex;
124 },
125
126 /**
127 * @override
117 * @return {!WebInspector.HeapSnapshotEdge.Serialized} 128 * @return {!WebInspector.HeapSnapshotEdge.Serialized}
118 */ 129 */
119 serialize: function() 130 serialize: function()
120 { 131 {
121 var node = this.node(); 132 var node = this.node();
122 return new WebInspector.HeapSnapshotEdge.Serialized(this.name(), node.se rialize(), this.nodeIndex(), this.type(), node.distance()); 133 return new WebInspector.HeapSnapshotEdge.Serialized(this.name(), node.se rialize(), this.nodeIndex(), this.type(), node.distance());
123 }, 134 },
124 135
125 _type: function() 136 _type: function()
126 { 137 {
127 return this._edges[this.edgeIndex + this._snapshot._edgeTypeOffset]; 138 return this._edges[this.edgeIndex + this._snapshot._edgeTypeOffset];
128 } 139 }
129 }; 140 };
130 141
131 142
132
133 /** 143 /**
134 * @interface 144 * @interface
145 */
146 WebInspector.HeapSnapshotItem = function() { }
alph 2014/03/24 10:09:29 Plz move the interface to the top, i.e. before the
yurys 2014/03/24 12:05:56 Done.
147
148 WebInspector.HeapSnapshotItem.prototype = {
149 /**
150 * @return {number}
151 */
152 itemIndex: function() { },
153
154 /**
155 * @return {!Object}
156 */
157 serialize: function() { }
158 };
159
160
161 /**
162 * @interface
135 */ 163 */
136 WebInspector.HeapSnapshotItemIterator = function() { } 164 WebInspector.HeapSnapshotItemIterator = function() { }
137 165
138 WebInspector.HeapSnapshotItemIterator.prototype = { 166 WebInspector.HeapSnapshotItemIterator.prototype = {
139 /** 167 /**
140 * @return {boolean} 168 * @return {boolean}
141 */ 169 */
142 hasNext: function() { }, 170 hasNext: function() { },
143 171
144 /** 172 /**
145 * @return {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!W ebInspector.HeapSnapshotRetainerEdge} 173 * @return {!WebInspector.HeapSnapshotItem}
146 */ 174 */
147 item: function() { }, 175 item: function() { },
148 176
149 next: function() { } 177 next: function() { }
150 }; 178 };
151 179
152 180
153 /** 181 /**
154 * @interface 182 * @interface
155 */ 183 */
156 WebInspector.HeapSnapshotItemIndexProvider = function() { } 184 WebInspector.HeapSnapshotItemIndexProvider = function() { }
alph 2014/03/24 10:09:29 HeapSnapshotItemIndexProvider -> HeapSnapshotItemP
yurys 2014/03/24 12:05:56 There is already HeapSnapshotItemProvider class.
157 185
158 WebInspector.HeapSnapshotItemIndexProvider.prototype = { 186 WebInspector.HeapSnapshotItemIndexProvider.prototype = {
159 /** 187 /**
160 * @param {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!We bInspector.HeapSnapshotRetainerEdge} item
161 * @return {number}
162 */
163 indexForItem: function(item) { },
164
165 /**
166 * @param {number} newIndex 188 * @param {number} newIndex
167 * @return {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!W ebInspector.HeapSnapshotRetainerEdge} 189 * @return {!WebInspector.HeapSnapshotItem}
168 */ 190 */
169 itemForIndex: function(newIndex) { }, 191 itemForIndex: function(newIndex) { },
170 }; 192 };
171 193
172 /** 194 /**
173 * @constructor 195 * @constructor
174 * @implements {WebInspector.HeapSnapshotItemIndexProvider} 196 * @implements {WebInspector.HeapSnapshotItemIndexProvider}
175 * @param {!WebInspector.HeapSnapshot} snapshot 197 * @param {!WebInspector.HeapSnapshot} snapshot
176 */ 198 */
177 WebInspector.HeapSnapshotNodeIndexProvider = function(snapshot) 199 WebInspector.HeapSnapshotNodeIndexProvider = function(snapshot)
178 { 200 {
179 this._node = snapshot.createNode(); 201 this._node = snapshot.createNode();
180 } 202 }
181 203
182 WebInspector.HeapSnapshotNodeIndexProvider.prototype = { 204 WebInspector.HeapSnapshotNodeIndexProvider.prototype = {
183 /** 205 /**
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 206 * @param {number} index
195 * @return {!WebInspector.HeapSnapshotNode} 207 * @return {!WebInspector.HeapSnapshotNode}
196 */ 208 */
197 itemForIndex: function(index) 209 itemForIndex: function(index)
198 { 210 {
199 this._node.nodeIndex = index; 211 this._node.nodeIndex = index;
200 return this._node; 212 return this._node;
201 } 213 }
202 }; 214 };
203 215
204 216
205 /** 217 /**
206 * @constructor 218 * @constructor
207 * @implements {WebInspector.HeapSnapshotItemIndexProvider} 219 * @implements {WebInspector.HeapSnapshotItemIndexProvider}
208 * @param {!WebInspector.HeapSnapshot} snapshot 220 * @param {!WebInspector.HeapSnapshot} snapshot
209 */ 221 */
210 WebInspector.HeapSnapshotEdgeIndexProvider = function(snapshot) 222 WebInspector.HeapSnapshotEdgeIndexProvider = function(snapshot)
211 { 223 {
212 this._edge = snapshot.createEdge(0); 224 this._edge = snapshot.createEdge(0);
213 } 225 }
214 226
215 WebInspector.HeapSnapshotEdgeIndexProvider.prototype = { 227 WebInspector.HeapSnapshotEdgeIndexProvider.prototype = {
216 /** 228 /**
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 229 * @param {number} index
228 * @return {!WebInspector.HeapSnapshotEdge} 230 * @return {!WebInspector.HeapSnapshotEdge}
229 */ 231 */
230 itemForIndex: function(index) 232 itemForIndex: function(index)
231 { 233 {
232 this._edge.edgeIndex = index; 234 this._edge.edgeIndex = index;
233 return this._edge; 235 return this._edge;
234 } 236 }
235 }; 237 };
236 238
237 239
238 /** 240 /**
239 * @constructor 241 * @constructor
240 * @implements {WebInspector.HeapSnapshotItemIndexProvider} 242 * @implements {WebInspector.HeapSnapshotItemIndexProvider}
241 * @param {!WebInspector.HeapSnapshot} snapshot 243 * @param {!WebInspector.HeapSnapshot} snapshot
242 */ 244 */
243 WebInspector.HeapSnapshotRetainerEdgeIndexProvider = function(snapshot) 245 WebInspector.HeapSnapshotRetainerEdgeIndexProvider = function(snapshot)
244 { 246 {
245 this._retainerEdge = snapshot.createRetainingEdge(0); 247 this._retainerEdge = snapshot.createRetainingEdge(0);
246 } 248 }
247 249
248 WebInspector.HeapSnapshotRetainerEdgeIndexProvider.prototype = { 250 WebInspector.HeapSnapshotRetainerEdgeIndexProvider.prototype = {
249 /** 251 /**
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 252 * @param {number} index
261 * @return {!WebInspector.HeapSnapshotRetainerEdge} 253 * @return {!WebInspector.HeapSnapshotRetainerEdge}
262 */ 254 */
263 itemForIndex: function(index) 255 itemForIndex: function(index)
264 { 256 {
265 this._retainerEdge.setRetainerIndex(index); 257 this._retainerEdge.setRetainerIndex(index);
266 return this._retainerEdge; 258 return this._retainerEdge;
267 } 259 }
268 }; 260 };
269 261
(...skipping 27 matching lines...) Expand all
297 }, 289 },
298 290
299 next: function() 291 next: function()
300 { 292 {
301 this.edge.edgeIndex += this.edge._snapshot._edgeFieldsCount; 293 this.edge.edgeIndex += this.edge._snapshot._edgeFieldsCount;
302 } 294 }
303 }; 295 };
304 296
305 /** 297 /**
306 * @constructor 298 * @constructor
299 * @implements {WebInspector.HeapSnapshotItem}
307 * @param {!WebInspector.HeapSnapshot} snapshot 300 * @param {!WebInspector.HeapSnapshot} snapshot
308 * @param {number} retainerIndex 301 * @param {number} retainerIndex
309 */ 302 */
310 WebInspector.HeapSnapshotRetainerEdge = function(snapshot, retainerIndex) 303 WebInspector.HeapSnapshotRetainerEdge = function(snapshot, retainerIndex)
311 { 304 {
312 this._snapshot = snapshot; 305 this._snapshot = snapshot;
313 this.setRetainerIndex(retainerIndex); 306 this.setRetainerIndex(retainerIndex);
314 } 307 }
315 308
316 /** 309 /**
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 409
417 /** 410 /**
418 * @return {string} 411 * @return {string}
419 */ 412 */
420 toString: function() 413 toString: function()
421 { 414 {
422 return this._edge().toString(); 415 return this._edge().toString();
423 }, 416 },
424 417
425 /** 418 /**
419 * @override
420 * @return {number}
421 */
422 itemIndex: function()
423 {
424 return this._retainerIndex;
425 },
426
427 /**
428 * @override
426 * @return {!WebInspector.HeapSnapshotRetainerEdge.Serialized} 429 * @return {!WebInspector.HeapSnapshotRetainerEdge.Serialized}
427 */ 430 */
428 serialize: function() 431 serialize: function()
429 { 432 {
430 var node = this.node(); 433 var node = this.node();
431 return new WebInspector.HeapSnapshotRetainerEdge.Serialized(this.name(), node.serialize(), this.nodeIndex(), this.type(), node.distance()); 434 return new WebInspector.HeapSnapshotRetainerEdge.Serialized(this.name(), node.serialize(), this.nodeIndex(), this.type(), node.distance());
432 }, 435 },
433 436
434 /** 437 /**
435 * @return {string} 438 * @return {string}
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 }, 475 },
473 476
474 next: function() 477 next: function()
475 { 478 {
476 this.retainer.setRetainerIndex(this.retainer.retainerIndex() + 1); 479 this.retainer.setRetainerIndex(this.retainer.retainerIndex() + 1);
477 } 480 }
478 }; 481 };
479 482
480 /** 483 /**
481 * @constructor 484 * @constructor
485 * @implements {WebInspector.HeapSnapshotItem}
486 * @param {!WebInspector.HeapSnapshot} snapshot
482 * @param {number=} nodeIndex 487 * @param {number=} nodeIndex
483 */ 488 */
484 WebInspector.HeapSnapshotNode = function(snapshot, nodeIndex) 489 WebInspector.HeapSnapshotNode = function(snapshot, nodeIndex)
485 { 490 {
486 this._snapshot = snapshot; 491 this._snapshot = snapshot;
487 this.nodeIndex = nodeIndex; 492 this.nodeIndex = nodeIndex || 0;
488 } 493 }
489 494
490 /** 495 /**
491 * @constructor 496 * @constructor
492 * @param {string} id 497 * @param {string} id
493 * @param {string} name 498 * @param {string} name
494 * @param {number} distance 499 * @param {number} distance
495 * @param {number|undefined} nodeIndex 500 * @param {number|undefined} nodeIndex
496 * @param {number} retainedSize 501 * @param {number} retainedSize
497 * @param {number} selfSize 502 * @param {number} selfSize
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 /** 629 /**
625 * @return {number} 630 * @return {number}
626 */ 631 */
627 traceNodeId: function() 632 traceNodeId: function()
628 { 633 {
629 var snapshot = this._snapshot; 634 var snapshot = this._snapshot;
630 return snapshot._nodes[this.nodeIndex + snapshot._nodeTraceNodeIdOffset] ; 635 return snapshot._nodes[this.nodeIndex + snapshot._nodeTraceNodeIdOffset] ;
631 }, 636 },
632 637
633 /** 638 /**
639 * @override
640 * @return {number}
641 */
642 itemIndex: function()
643 {
644 return this.nodeIndex;
645 },
646
647 /**
648 * @override
634 * @return {!WebInspector.HeapSnapshotNode.Serialized} 649 * @return {!WebInspector.HeapSnapshotNode.Serialized}
635 */ 650 */
636 serialize: function() 651 serialize: function()
637 { 652 {
638 return new WebInspector.HeapSnapshotNode.Serialized(this.id(), this.name (), this.distance(), this.nodeIndex, this.retainedSize(), this.selfSize(), this. type()); 653 return new WebInspector.HeapSnapshotNode.Serialized(this.id(), this.name (), this.distance(), this.nodeIndex, this.retainedSize(), this.selfSize(), this. type());
639 }, 654 },
640 655
641 /** 656 /**
642 * @return {number} 657 * @return {number}
643 */ 658 */
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 WebInspector.HeapSnapshotIndexRangeIterator.prototype = { 755 WebInspector.HeapSnapshotIndexRangeIterator.prototype = {
741 /** 756 /**
742 * @return {boolean} 757 * @return {boolean}
743 */ 758 */
744 hasNext: function() 759 hasNext: function()
745 { 760 {
746 return this._position < this._indexes.length 761 return this._position < this._indexes.length
747 }, 762 },
748 763
749 /** 764 /**
750 * @return {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!W ebInspector.HeapSnapshotRetainerEdge} 765 * @return {!WebInspector.HeapSnapshotItem}
751 */ 766 */
752 item: function() 767 item: function()
753 { 768 {
754 var index = this._indexes[this._position]; 769 var index = this._indexes[this._position];
755 return this._itemProvider.itemForIndex(index); 770 return this._itemProvider.itemForIndex(index);
756 }, 771 },
757 772
758 next: function() 773 next: function()
759 { 774 {
760 ++this._position; 775 ++this._position;
(...skipping 16 matching lines...) Expand all
777 WebInspector.HeapSnapshotFilteredIterator.prototype = { 792 WebInspector.HeapSnapshotFilteredIterator.prototype = {
778 /** 793 /**
779 * @return {boolean} 794 * @return {boolean}
780 */ 795 */
781 hasNext: function() 796 hasNext: function()
782 { 797 {
783 return this._iterator.hasNext(); 798 return this._iterator.hasNext();
784 }, 799 },
785 800
786 /** 801 /**
787 * @return {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!W ebInspector.HeapSnapshotRetainerEdge} 802 * @return {!WebInspector.HeapSnapshotItem}
788 */ 803 */
789 item: function() 804 item: function()
790 { 805 {
791 return this._iterator.item(); 806 return this._iterator.item();
792 }, 807 },
793 808
794 next: function() 809 next: function()
795 { 810 {
796 this._iterator.next(); 811 this._iterator.next();
797 this._skipFilteredItems(); 812 this._skipFilteredItems();
(...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 this._sortedSuffixLength = 0; 2079 this._sortedSuffixLength = 0;
2065 } 2080 }
2066 2081
2067 WebInspector.HeapSnapshotItemProvider.prototype = { 2082 WebInspector.HeapSnapshotItemProvider.prototype = {
2068 _createIterationOrder: function() 2083 _createIterationOrder: function()
2069 { 2084 {
2070 if (this._iterationOrder) 2085 if (this._iterationOrder)
2071 return; 2086 return;
2072 this._iterationOrder = []; 2087 this._iterationOrder = [];
2073 for (var iterator = this._iterator; iterator.hasNext(); iterator.next()) 2088 for (var iterator = this._iterator; iterator.hasNext(); iterator.next())
2074 this._iterationOrder.push(this._indexProvider.indexForItem(iterator. item())); 2089 this._iterationOrder.push(iterator.item().itemIndex());
2075 }, 2090 },
2076 2091
2077 /** 2092 /**
2078 * @return {boolean} 2093 * @return {boolean}
2079 */ 2094 */
2080 isEmpty: function() 2095 isEmpty: function()
2081 { 2096 {
2082 return this._isEmpty; 2097 return this._isEmpty;
2083 }, 2098 },
2084 2099
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 * @param {number} windowRight 2326 * @param {number} windowRight
2312 */ 2327 */
2313 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight) 2328 sort: function(comparator, leftBound, rightBound, windowLeft, windowRight)
2314 { 2329 {
2315 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l eftBound, rightBound, windowLeft, windowRight); 2330 this._iterationOrder.sortRange(this._buildCompareFunction(comparator), l eftBound, rightBound, windowLeft, windowRight);
2316 }, 2331 },
2317 2332
2318 __proto__: WebInspector.HeapSnapshotItemProvider.prototype 2333 __proto__: WebInspector.HeapSnapshotItemProvider.prototype
2319 } 2334 }
2320 2335
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