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

Unified Diff: chrome_linux/resources/inspector/HeapSnapshotWorker.js

Issue 33333002: Roll Linux reference build to official build 30.0.1599.33 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/reference_builds/
Patch Set: Created 7 years, 2 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
Index: chrome_linux/resources/inspector/HeapSnapshotWorker.js
===================================================================
--- chrome_linux/resources/inspector/HeapSnapshotWorker.js (revision 229864)
+++ chrome_linux/resources/inspector/HeapSnapshotWorker.js (working copy)
@@ -82,22 +82,15 @@
{this.node.nodeIndex=newIndex;},item:function()
{return this.node;},next:function()
{this.node.nodeIndex=this.node._nextNodeIndex();}}
-WebInspector.HeapSnapshotProgress=function(dispatcher)
-{this._dispatcher=dispatcher;}
-WebInspector.HeapSnapshotProgress.Event={Update:"ProgressUpdate"};WebInspector.HeapSnapshotProgress.prototype={updateStatus:function(status)
-{this._sendUpdateEvent(WebInspector.UIString(status));},updateProgress:function(title,value,total)
-{var percentValue=((total?(value/total):0)*100).toFixed(0);this._sendUpdateEvent(WebInspector.UIString(title,percentValue));},_sendUpdateEvent:function(text)
-{if(this._dispatcher)
-this._dispatcher.sendEvent(WebInspector.HeapSnapshotProgress.Event.Update,text);}}
-WebInspector.HeapSnapshot=function(profile,progress)
-{this.uid=profile.snapshot.uid;this._nodes=profile.nodes;this._containmentEdges=profile.edges;this._metaNode=profile.snapshot.meta;this._strings=profile.strings;this._progress=progress;this._noDistance=-5;this._rootNodeIndex=0;if(profile.snapshot.root_index)
+WebInspector.HeapSnapshot=function(profile)
+{this.uid=profile.snapshot.uid;this._nodes=profile.nodes;this._containmentEdges=profile.edges;this._metaNode=profile.snapshot.meta;this._strings=profile.strings;this._noDistance=-5;this._rootNodeIndex=0;if(profile.snapshot.root_index)
this._rootNodeIndex=profile.snapshot.root_index;this._snapshotDiffs={};this._aggregatesForDiff=null;this._init();}
function HeapSnapshotMetainfo()
{this.node_fields=[];this.node_types=[];this.edge_fields=[];this.edge_types=[];this.type_strings={};this.fields=[];this.types=[];}
function HeapSnapshotHeader()
{this.title="";this.uid=0;this.meta=new HeapSnapshotMetainfo();this.node_count=0;this.edge_count=0;}
WebInspector.HeapSnapshot.prototype={_init:function()
-{var meta=this._metaNode;this._nodeTypeOffset=meta.node_fields.indexOf("type");this._nodeNameOffset=meta.node_fields.indexOf("name");this._nodeIdOffset=meta.node_fields.indexOf("id");this._nodeSelfSizeOffset=meta.node_fields.indexOf("self_size");this._nodeEdgeCountOffset=meta.node_fields.indexOf("edge_count");this._nodeFieldCount=meta.node_fields.length;this._nodeTypes=meta.node_types[this._nodeTypeOffset];this._nodeHiddenType=this._nodeTypes.indexOf("hidden");this._nodeObjectType=this._nodeTypes.indexOf("object");this._nodeNativeType=this._nodeTypes.indexOf("native");this._nodeCodeType=this._nodeTypes.indexOf("code");this._nodeSyntheticType=this._nodeTypes.indexOf("synthetic");this._edgeFieldsCount=meta.edge_fields.length;this._edgeTypeOffset=meta.edge_fields.indexOf("type");this._edgeNameOffset=meta.edge_fields.indexOf("name_or_index");this._edgeToNodeOffset=meta.edge_fields.indexOf("to_node");this._edgeTypes=meta.edge_types[this._edgeTypeOffset];this._edgeTypes.push("invisible");this._edgeElementType=this._edgeTypes.indexOf("element");this._edgeHiddenType=this._edgeTypes.indexOf("hidden");this._edgeInternalType=this._edgeTypes.indexOf("internal");this._edgeShortcutType=this._edgeTypes.indexOf("shortcut");this._edgeWeakType=this._edgeTypes.indexOf("weak");this._edgeInvisibleType=this._edgeTypes.indexOf("invisible");this.nodeCount=this._nodes.length/this._nodeFieldCount;this._edgeCount=this._containmentEdges.length/this._edgeFieldsCount;this._progress.updateStatus("Building edge indexes\u2026");this._buildEdgeIndexes();this._progress.updateStatus("Marking invisible edges\u2026");this._markInvisibleEdges();this._progress.updateStatus("Building retainers\u2026");this._buildRetainers();this._progress.updateStatus("Calculating node flags\u2026");this._calculateFlags();this._progress.updateStatus("Calculating distances\u2026");this._calculateDistances();this._progress.updateStatus("Building postorder index\u2026");var result=this._buildPostOrderIndex();this._progress.updateStatus("Building dominator tree\u2026");this._dominatorsTree=this._buildDominatorTree(result.postOrderIndex2NodeOrdinal,result.nodeOrdinal2PostOrderIndex);this._progress.updateStatus("Calculating retained sizes\u2026");this._calculateRetainedSizes(result.postOrderIndex2NodeOrdinal);this._progress.updateStatus("Buiding dominated nodes\u2026");this._buildDominatedNodes();this._progress.updateStatus("Finished processing.");},_buildEdgeIndexes:function()
+{var meta=this._metaNode;this._nodeTypeOffset=meta.node_fields.indexOf("type");this._nodeNameOffset=meta.node_fields.indexOf("name");this._nodeIdOffset=meta.node_fields.indexOf("id");this._nodeSelfSizeOffset=meta.node_fields.indexOf("self_size");this._nodeEdgeCountOffset=meta.node_fields.indexOf("edge_count");this._nodeFieldCount=meta.node_fields.length;this._nodeTypes=meta.node_types[this._nodeTypeOffset];this._nodeHiddenType=this._nodeTypes.indexOf("hidden");this._nodeObjectType=this._nodeTypes.indexOf("object");this._nodeNativeType=this._nodeTypes.indexOf("native");this._nodeCodeType=this._nodeTypes.indexOf("code");this._nodeSyntheticType=this._nodeTypes.indexOf("synthetic");this._edgeFieldsCount=meta.edge_fields.length;this._edgeTypeOffset=meta.edge_fields.indexOf("type");this._edgeNameOffset=meta.edge_fields.indexOf("name_or_index");this._edgeToNodeOffset=meta.edge_fields.indexOf("to_node");this._edgeTypes=meta.edge_types[this._edgeTypeOffset];this._edgeTypes.push("invisible");this._edgeElementType=this._edgeTypes.indexOf("element");this._edgeHiddenType=this._edgeTypes.indexOf("hidden");this._edgeInternalType=this._edgeTypes.indexOf("internal");this._edgeShortcutType=this._edgeTypes.indexOf("shortcut");this._edgeWeakType=this._edgeTypes.indexOf("weak");this._edgeInvisibleType=this._edgeTypes.indexOf("invisible");this.nodeCount=this._nodes.length/this._nodeFieldCount;this._edgeCount=this._containmentEdges.length/this._edgeFieldsCount;this._buildEdgeIndexes();this._markInvisibleEdges();this._buildRetainers();this._calculateFlags();this._calculateDistances();var result=this._buildPostOrderIndex();this._dominatorsTree=this._buildDominatorTree(result.postOrderIndex2NodeOrdinal,result.nodeOrdinal2PostOrderIndex);this._calculateRetainedSizes(result.postOrderIndex2NodeOrdinal);this._buildDominatedNodes();},_buildEdgeIndexes:function()
{var nodes=this._nodes;var nodeCount=this.nodeCount;var firstEdgeIndexes=this._firstEdgeIndexes=new Uint32Array(nodeCount+1);var nodeFieldCount=this._nodeFieldCount;var edgeFieldsCount=this._edgeFieldsCount;var nodeEdgeCountOffset=this._nodeEdgeCountOffset;firstEdgeIndexes[nodeCount]=this._containmentEdges.length;for(var nodeOrdinal=0,edgeIndex=0;nodeOrdinal<nodeCount;++nodeOrdinal){firstEdgeIndexes[nodeOrdinal]=edgeIndex;edgeIndex+=nodes[nodeOrdinal*nodeFieldCount+nodeEdgeCountOffset]*edgeFieldsCount;}},_buildRetainers:function()
{var retainingNodes=this._retainingNodes=new Uint32Array(this._edgeCount);var retainingEdges=this._retainingEdges=new Uint32Array(this._edgeCount);var firstRetainerIndex=this._firstRetainerIndex=new Uint32Array(this.nodeCount+1);var containmentEdges=this._containmentEdges;var edgeFieldsCount=this._edgeFieldsCount;var nodeFieldCount=this._nodeFieldCount;var edgeToNodeOffset=this._edgeToNodeOffset;var nodes=this._nodes;var firstEdgeIndexes=this._firstEdgeIndexes;var nodeCount=this.nodeCount;for(var toNodeFieldIndex=edgeToNodeOffset,l=containmentEdges.length;toNodeFieldIndex<l;toNodeFieldIndex+=edgeFieldsCount){var toNodeIndex=containmentEdges[toNodeFieldIndex];if(toNodeIndex%nodeFieldCount)
throw new Error("Invalid toNodeIndex "+toNodeIndex);++firstRetainerIndex[toNodeIndex/nodeFieldCount];}
@@ -273,14 +266,14 @@
{var valueOrFunctionA=nodeA[fieldName];var valueA=typeof valueOrFunctionA!=="function"?valueOrFunctionA:valueOrFunctionA.call(nodeA);var valueOrFunctionB=nodeB[fieldName];var valueB=typeof valueOrFunctionB!=="function"?valueOrFunctionB:valueOrFunctionB.call(nodeB);var result=valueA<valueB?-1:(valueA>valueB?1:0);return ascending?result:-result;}
function sortByComparator(indexA,indexB){nodeA.nodeIndex=indexA;nodeB.nodeIndex=indexB;var result=sortByNodeField(fieldName1,ascending1);if(result===0)
result=sortByNodeField(fieldName2,ascending2);return result;}
-this._iterationOrder.sortRange(sortByComparator,leftBound,rightBound,count);},__proto__:WebInspector.HeapSnapshotFilteredOrderedIterator.prototype};WebInspector.HeapSnapshotLoader=function(dispatcher)
-{this._reset();this._progress=new WebInspector.HeapSnapshotProgress(dispatcher);}
+this._iterationOrder.sortRange(sortByComparator,leftBound,rightBound,count);},__proto__:WebInspector.HeapSnapshotFilteredOrderedIterator.prototype};WebInspector.HeapSnapshotLoader=function()
+{this._reset();}
WebInspector.HeapSnapshotLoader.prototype={dispose:function()
{this._reset();},_reset:function()
{this._json="";this._state="find-snapshot-info";this._snapshot={};},close:function()
{if(this._json)
this._parseStringsArray();},buildSnapshot:function(constructorName)
-{this._progress.updateStatus("Processing snapshot\u2026");var constructor=WebInspector[constructorName];var result=new constructor(this._snapshot,this._progress);this._reset();return result;},_parseUintArray:function()
+{var constructor=WebInspector[constructorName];var result=new constructor(this._snapshot);this._reset();return result;},_parseUintArray:function()
{var index=0;var char0="0".charCodeAt(0),char9="9".charCodeAt(0),closingBracket="]".charCodeAt(0);var length=this._json.length;while(true){while(index<length){var code=this._json.charCodeAt(index);if(char0<=code&&code<=char9)
break;else if(code===closingBracket){this._json=this._json.slice(index+1);return false;}
++index;}
@@ -289,22 +282,22 @@
break;nextNumber*=10;nextNumber+=(code-char0);++index;}
if(index===length){this._json=this._json.slice(startIndex);return true;}
this._array[this._arrayIndex++]=nextNumber;}},_parseStringsArray:function()
-{this._progress.updateStatus("Parsing strings\u2026");var closingBracketIndex=this._json.lastIndexOf("]");if(closingBracketIndex===-1)
+{var closingBracketIndex=this._json.lastIndexOf("]");if(closingBracketIndex===-1)
throw new Error("Incomplete JSON");this._json=this._json.slice(0,closingBracketIndex+1);this._snapshot.strings=JSON.parse(this._json);},write:function(chunk)
{this._json+=chunk;switch(this._state){case"find-snapshot-info":{var snapshotToken="\"snapshot\"";var snapshotTokenIndex=this._json.indexOf(snapshotToken);if(snapshotTokenIndex===-1)
-throw new Error("Snapshot token not found");this._json=this._json.slice(snapshotTokenIndex+snapshotToken.length+1);this._state="parse-snapshot-info";this._progress.updateStatus("Loading snapshot info\u2026");}
+throw new Error("Snapshot token not found");this._json=this._json.slice(snapshotTokenIndex+snapshotToken.length+1);this._state="parse-snapshot-info";}
case"parse-snapshot-info":{var closingBracketIndex=WebInspector.findBalancedCurlyBrackets(this._json);if(closingBracketIndex===-1)
return;this._snapshot.snapshot=(JSON.parse(this._json.slice(0,closingBracketIndex)));this._json=this._json.slice(closingBracketIndex);this._state="find-nodes";}
case"find-nodes":{var nodesToken="\"nodes\"";var nodesTokenIndex=this._json.indexOf(nodesToken);if(nodesTokenIndex===-1)
return;var bracketIndex=this._json.indexOf("[",nodesTokenIndex);if(bracketIndex===-1)
return;this._json=this._json.slice(bracketIndex+1);var node_fields_count=this._snapshot.snapshot.meta.node_fields.length;var nodes_length=this._snapshot.snapshot.node_count*node_fields_count;this._array=new Uint32Array(nodes_length);this._arrayIndex=0;this._state="parse-nodes";}
-case"parse-nodes":{var hasMoreData=this._parseUintArray();this._progress.updateProgress("Loading nodes\u2026 %d\%",this._arrayIndex,this._array.length);if(hasMoreData)
+case"parse-nodes":{if(this._parseUintArray())
return;this._snapshot.nodes=this._array;this._state="find-edges";this._array=null;}
case"find-edges":{var edgesToken="\"edges\"";var edgesTokenIndex=this._json.indexOf(edgesToken);if(edgesTokenIndex===-1)
return;var bracketIndex=this._json.indexOf("[",edgesTokenIndex);if(bracketIndex===-1)
return;this._json=this._json.slice(bracketIndex+1);var edge_fields_count=this._snapshot.snapshot.meta.edge_fields.length;var edges_length=this._snapshot.snapshot.edge_count*edge_fields_count;this._array=new Uint32Array(edges_length);this._arrayIndex=0;this._state="parse-edges";}
-case"parse-edges":{var hasMoreData=this._parseUintArray();this._progress.updateProgress("Loading edges\u2026 %d\%",this._arrayIndex,this._array.length);if(hasMoreData)
-return;this._snapshot.edges=this._array;this._array=null;this._state="find-strings";this._progress.updateStatus("Loading strings\u2026");}
+case"parse-edges":{if(this._parseUintArray())
+return;this._snapshot.edges=this._array;this._array=null;this._state="find-strings";}
case"find-strings":{var stringsToken="\"strings\"";var stringsTokenIndex=this._json.indexOf(stringsToken);if(stringsTokenIndex===-1)
return;var bracketIndex=this._json.indexOf("[",stringsTokenIndex);if(bracketIndex===-1)
return;this._json=this._json.slice(bracketIndex);this._state="accumulate-strings";break;}
@@ -312,17 +305,16 @@
{this._objects=[];this._global=globalObject;this._postMessage=postMessage;}
WebInspector.HeapSnapshotWorkerDispatcher.prototype={_findFunction:function(name)
{var path=name.split(".");var result=this._global;for(var i=0;i<path.length;++i)
-result=result[path[i]];return result;},sendEvent:function(name,data)
-{this._postMessage({eventName:name,data:data});},dispatchMessage:function(event)
-{var data=event.data;var response={callId:data.callId};try{switch(data.disposition){case"create":{var constructorFunction=this._findFunction(data.methodName);this._objects[data.objectId]=new constructorFunction(this);break;}
+result=result[path[i]];return result;},dispatchMessage:function(event)
+{var data=event.data;var response={callId:data.callId};try{switch(data.disposition){case"create":{var constructorFunction=this._findFunction(data.methodName);this._objects[data.objectId]=new constructorFunction();break;}
case"dispose":{delete this._objects[data.objectId];break;}
case"getter":{var object=this._objects[data.objectId];var result=object[data.methodName];response.result=result;break;}
case"factory":{var object=this._objects[data.objectId];var result=object[data.methodName].apply(object,data.methodArguments);if(result)
this._objects[data.newObjectId]=result;response.result=!!result;break;}
case"method":{var object=this._objects[data.objectId];response.result=object[data.methodName].apply(object,data.methodArguments);break;}}}catch(e){response.error=e.toString();response.errorCallStack=e.stack;if(data.methodName)
response.errorMethodName=data.methodName;}
-this._postMessage(response);}};;WebInspector.JSHeapSnapshot=function(profile,progress)
-{this._nodeFlags={canBeQueried:1,detachedDOMTreeNode:2,pageObject:4,visitedMarkerMask:0x0ffff,visitedMarker:0x10000};WebInspector.HeapSnapshot.call(this,profile,progress);}
+this._postMessage(response);}};;WebInspector.JSHeapSnapshot=function(profile)
+{this._nodeFlags={canBeQueried:1,detachedDOMTreeNode:2,pageObject:4,visitedMarkerMask:0x0ffff,visitedMarker:0x10000};WebInspector.HeapSnapshot.call(this,profile);}
WebInspector.JSHeapSnapshot.prototype={createNode:function(nodeIndex)
{return new WebInspector.JSHeapSnapshotNode(this,nodeIndex);},createEdge:function(edges,edgeIndex)
{return new WebInspector.JSHeapSnapshotEdge(this,edges,edgeIndex);},createRetainingEdge:function(retainedNodeIndex,retainerIndex)
@@ -481,9 +473,10 @@
{this._closed=true;if(this._writeCallbacks.length)
return;WebInspector.fileManager.removeEventListener(WebInspector.FileManager.EventTypes.AppendedToURL,this._onAppendDone,this);WebInspector.fileManager.close(this._fileName);},_onAppendDone:function(event)
{if(event.data!==this._fileName)
-return;var callback=this._writeCallbacks.shift();if(callback)
-callback(this);if(!this._writeCallbacks.length){if(this._closed){WebInspector.fileManager.removeEventListener(WebInspector.FileManager.EventTypes.AppendedToURL,this._onAppendDone,this);WebInspector.fileManager.close(this._fileName);}}}};WebInspector.UIString=function(string,vararg)
-{return String.vsprintf(string,Array.prototype.slice.call(arguments,1));};Object.isEmpty=function(obj)
+return;if(!this._writeCallbacks.length){if(this._closed){WebInspector.fileManager.removeEventListener(WebInspector.FileManager.EventTypes.AppendedToURL,this._onAppendDone,this);WebInspector.fileManager.close(this._fileName);}
+return;}
+var callback=this._writeCallbacks.shift();if(callback)
+callback(this);}};Object.isEmpty=function(obj)
{for(var i in obj)
return false;return true;}
Object.values=function(obj)
@@ -525,7 +518,7 @@
return 1;if(this<other)
return-1;return 0;}
function sanitizeHref(href)
-{return href&&href.trim().toLowerCase().startsWith("javascript:")?null:href;}
+{return href&&href.trim().toLowerCase().startsWith("javascript:")?"":href;}
String.prototype.removeURLFragment=function()
{var fragmentIndex=this.indexOf("#");if(fragmentIndex==-1)
fragmentIndex=this.length;return this.substring(0,fragmentIndex);}
@@ -740,7 +733,8 @@
throw"recursion depth limit reached in StringPool.deepIntern(), perhaps attempting to traverse cyclical references?";for(var field in obj){switch(typeof obj[field]){case"string":obj[field]=this.intern(obj[field]);break;case"object":this.internObjectStrings(obj[field],depthLimit);break;}}}}
var _importedScripts={};function importScript(scriptName)
{if(_importedScripts[scriptName])
-return;var xhr=new XMLHttpRequest();_importedScripts[scriptName]=true;xhr.open("GET",scriptName,false);xhr.send(null);if(!xhr.responseText)
+return;var xhr=new XMLHttpRequest();_importedScripts[scriptName]=true;if(window.flattenImports)
+scriptName=scriptName.split("/").reverse()[0];xhr.open("GET",scriptName,false);xhr.send(null);if(!xhr.responseText)
throw"empty response arrived for script '"+scriptName+"'";var sourceURL=WebInspector.ParsedURL.completeURL(window.location.href,scriptName);window.eval(xhr.responseText+"\n//# sourceURL="+sourceURL);}
var loadScript=importScript;function CallbackBarrier()
{this._pendingIncomingCallbacksCount=0;}
@@ -752,4 +746,11 @@
if(!--this._pendingIncomingCallbacksCount&&this._outgoingCallback)
this._outgoingCallback();}};function postMessageWrapper(message)
{postMessage(message);}
-var dispatcher=new WebInspector.HeapSnapshotWorkerDispatcher(this,postMessageWrapper);addEventListener("message",dispatcher.dispatchMessage.bind(dispatcher),false);
+WebInspector.WorkerConsole=function()
+{}
+WebInspector.WorkerConsole.prototype={log:function(var_args)
+{this._postMessage("log",Array.prototype.slice.call(arguments));},error:function(var_args)
+{this._postMessage("error",Array.prototype.slice.call(arguments));},info:function(var_args)
+{this._postMessage("info",Array.prototype.slice.call(arguments));},trace:function()
+{this.log(new Error().stack);},_postMessage:function(method,args)
+{var rawMessage={object:"console",method:method,arguments:args};postMessageWrapper(rawMessage);}};var dispatcher=new WebInspector.HeapSnapshotWorkerDispatcher(this,postMessageWrapper);addEventListener("message",dispatcher.dispatchMessage.bind(dispatcher),false);console=new WebInspector.WorkerConsole();
« no previous file with comments | « chrome_linux/resources/inspector/ElementsPanel.js ('k') | chrome_linux/resources/inspector/Images/statusbarButtonGlyphs.png » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698