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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/HeapSnapshot.js
diff --git a/Source/devtools/front_end/HeapSnapshot.js b/Source/devtools/front_end/HeapSnapshot.js
index 540bab46618c4e04a298d83b5b890413616b3bba..3232dcf0b077ff2eef95212d57809657ee5cf327 100644
--- a/Source/devtools/front_end/HeapSnapshot.js
+++ b/Source/devtools/front_end/HeapSnapshot.js
@@ -30,6 +30,7 @@
/**
* @constructor
+ * @implements {WebInspector.HeapSnapshotItem}
* @param {!WebInspector.HeapSnapshot} snapshot
* @param {number=} edgeIndex
*/
@@ -114,6 +115,16 @@ WebInspector.HeapSnapshotEdge.prototype = {
},
/**
+ * @override
+ * @return {number}
+ */
+ itemIndex: function()
+ {
+ return this.edgeIndex;
+ },
+
+ /**
+ * @override
* @return {!WebInspector.HeapSnapshotEdge.Serialized}
*/
serialize: function()
@@ -129,6 +140,23 @@ WebInspector.HeapSnapshotEdge.prototype = {
};
+/**
+ * @interface
+ */
+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.
+
+WebInspector.HeapSnapshotItem.prototype = {
+ /**
+ * @return {number}
+ */
+ itemIndex: function() { },
+
+ /**
+ * @return {!Object}
+ */
+ serialize: function() { }
+};
+
/**
* @interface
@@ -142,7 +170,7 @@ WebInspector.HeapSnapshotItemIterator.prototype = {
hasNext: function() { },
/**
- * @return {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!WebInspector.HeapSnapshotRetainerEdge}
+ * @return {!WebInspector.HeapSnapshotItem}
*/
item: function() { },
@@ -157,14 +185,8 @@ WebInspector.HeapSnapshotItemIndexProvider = function() { }
WebInspector.HeapSnapshotItemIndexProvider.prototype = {
/**
- * @param {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!WebInspector.HeapSnapshotRetainerEdge} item
- * @return {number}
- */
- indexForItem: function(item) { },
-
- /**
* @param {number} newIndex
- * @return {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!WebInspector.HeapSnapshotRetainerEdge}
+ * @return {!WebInspector.HeapSnapshotItem}
*/
itemForIndex: function(newIndex) { },
};
@@ -181,16 +203,6 @@ WebInspector.HeapSnapshotNodeIndexProvider = function(snapshot)
WebInspector.HeapSnapshotNodeIndexProvider.prototype = {
/**
- * @param {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!WebInspector.HeapSnapshotRetainerEdge} item
- * @return {number}
- */
- indexForItem: function(item)
- {
- var node = /** @type {!WebInspector.HeapSnapshotNode} */ (item);
- return node.nodeIndex;
- },
-
- /**
* @param {number} index
* @return {!WebInspector.HeapSnapshotNode}
*/
@@ -214,16 +226,6 @@ WebInspector.HeapSnapshotEdgeIndexProvider = function(snapshot)
WebInspector.HeapSnapshotEdgeIndexProvider.prototype = {
/**
- * @param {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!WebInspector.HeapSnapshotRetainerEdge} item
- * @return {number}
- */
- indexForItem: function(item)
- {
- var edge = /** @type {!WebInspector.HeapSnapshotEdge} */ (item);
- return edge.edgeIndex;
- },
-
- /**
* @param {number} index
* @return {!WebInspector.HeapSnapshotEdge}
*/
@@ -247,16 +249,6 @@ WebInspector.HeapSnapshotRetainerEdgeIndexProvider = function(snapshot)
WebInspector.HeapSnapshotRetainerEdgeIndexProvider.prototype = {
/**
- * @param {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!WebInspector.HeapSnapshotRetainerEdge} item
- * @return {number}
- */
- indexForItem: function(item)
- {
- var edge = /** @type {!WebInspector.HeapSnapshotRetainerEdge} */ (item);
- return edge.retainerIndex();
- },
-
- /**
* @param {number} index
* @return {!WebInspector.HeapSnapshotRetainerEdge}
*/
@@ -304,6 +296,7 @@ WebInspector.HeapSnapshotEdgeIterator.prototype = {
/**
* @constructor
+ * @implements {WebInspector.HeapSnapshotItem}
* @param {!WebInspector.HeapSnapshot} snapshot
* @param {number} retainerIndex
*/
@@ -423,6 +416,16 @@ WebInspector.HeapSnapshotRetainerEdge.prototype = {
},
/**
+ * @override
+ * @return {number}
+ */
+ itemIndex: function()
+ {
+ return this._retainerIndex;
+ },
+
+ /**
+ * @override
* @return {!WebInspector.HeapSnapshotRetainerEdge.Serialized}
*/
serialize: function()
@@ -479,12 +482,14 @@ WebInspector.HeapSnapshotRetainerEdgeIterator.prototype = {
/**
* @constructor
+ * @implements {WebInspector.HeapSnapshotItem}
+ * @param {!WebInspector.HeapSnapshot} snapshot
* @param {number=} nodeIndex
*/
WebInspector.HeapSnapshotNode = function(snapshot, nodeIndex)
{
this._snapshot = snapshot;
- this.nodeIndex = nodeIndex;
+ this.nodeIndex = nodeIndex || 0;
}
/**
@@ -631,6 +636,16 @@ WebInspector.HeapSnapshotNode.prototype = {
},
/**
+ * @override
+ * @return {number}
+ */
+ itemIndex: function()
+ {
+ return this.nodeIndex;
+ },
+
+ /**
+ * @override
* @return {!WebInspector.HeapSnapshotNode.Serialized}
*/
serialize: function()
@@ -747,7 +762,7 @@ WebInspector.HeapSnapshotIndexRangeIterator.prototype = {
},
/**
- * @return {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!WebInspector.HeapSnapshotRetainerEdge}
+ * @return {!WebInspector.HeapSnapshotItem}
*/
item: function()
{
@@ -784,7 +799,7 @@ WebInspector.HeapSnapshotFilteredIterator.prototype = {
},
/**
- * @return {!WebInspector.HeapSnapshotEdge|!WebInspector.HeapSnapshotNode|!WebInspector.HeapSnapshotRetainerEdge}
+ * @return {!WebInspector.HeapSnapshotItem}
*/
item: function()
{
@@ -2071,7 +2086,7 @@ WebInspector.HeapSnapshotItemProvider.prototype = {
return;
this._iterationOrder = [];
for (var iterator = this._iterator; iterator.hasNext(); iterator.next())
- this._iterationOrder.push(this._indexProvider.indexForItem(iterator.item()));
+ this._iterationOrder.push(iterator.item().itemIndex());
},
/**
« 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