Profiler.ProfileType=class extends Common.Object{constructor(id,name){super();this._id=id;this._name=name;this._profiles=[];this._profileBeingRecorded=null;this._nextProfileUid=1;if(!window.opener) window.addEventListener('unload',this._clearTempStorage.bind(this),false);} typeName(){return'';} nextProfileUid(){return this._nextProfileUid;} incrementProfileUid(){return this._nextProfileUid++;} hasTemporaryView(){return false;} fileExtension(){return null;} get buttonTooltip(){return'';} get id(){return this._id;} get treeItemTitle(){return this._name;} get name(){return this._name;} buttonClicked(){return false;} get description(){return'';} isInstantProfile(){return false;} isEnabled(){return true;} getProfiles(){function isFinished(profile){return this._profileBeingRecorded!==profile;} return this._profiles.filter(isFinished.bind(this));} decorationElement(){return null;} getProfile(uid){for(let i=0;i!!type.fileExtension()&&fileName.endsWith(type.fileExtension()||''))||null;} async _loadFromFile(file){this._createFileSelectorElement();const profileType=this._findProfileTypeByExtension(file.name);if(!profileType){const extensions=new Set(this._profileTypes.map(type=>type.fileExtension()).filter(ext=>ext));Common.console.error(Common.UIString(`Can't load file. Supported file extensions: '%s'.`,Array.from(extensions).join(`', '`)));return;} if(!!profileType.profileBeingRecorded()){Common.console.error(Common.UIString(`Can't load profile while another profile is being recorded.`));return;} const error=await profileType.loadFromFile(file);if(error) UI.MessageDialog.show(Common.UIString('Profile loading failed: %s.',error.message));} toggleRecord(){if(!this._toggleRecordAction.enabled()) return true;const type=this._selectedProfileType;const isProfiling=type.buttonClicked();this._updateToggleRecordAction(isProfiling);if(isProfiling){this._launcherView.profileStarted();if(type.hasTemporaryView()) this.showProfile(type.profileBeingRecorded());}else{this._launcherView.profileFinished();} return true;} _onSuspendStateChanged(){this._updateToggleRecordAction(this._toggleRecordAction.toggled());} _updateToggleRecordAction(toggled){const enable=toggled||!SDK.targetManager.allTargetsSuspended();this._toggleRecordAction.setEnabled(enable);this._toggleRecordAction.setToggled(toggled);if(enable) this._toggleRecordButton.setTitle(this._selectedProfileType?this._selectedProfileType.buttonTooltip:'');else this._toggleRecordButton.setTitle(UI.anotherProfilerActiveLabel());if(this._selectedProfileType) this._launcherView.updateProfileType(this._selectedProfileType,enable);} _profileBeingRecordedRemoved(){this._updateToggleRecordAction(false);this._launcherView.profileFinished();} _onProfileTypeSelected(event){this._selectedProfileType=(event.data);this._updateProfileTypeSpecificUI();} _updateProfileTypeSpecificUI(){this._updateToggleRecordAction(this._toggleRecordAction.toggled());} _reset(){this._profileTypes.forEach(type=>type.reset());delete this.visibleView;this._profileGroups={};this._updateToggleRecordAction(false);this._launcherView.profileFinished();this._sidebarTree.element.classList.remove('some-expandable');this._launcherView.detach();this.profileViews.removeChildren();this._profileViewToolbar.removeToolbarItems();this.clearResultsButton.element.classList.remove('hidden');this.profilesItemTreeElement.select();this._showLauncherView();} _showLauncherView(){this.closeVisibleView();this._profileViewToolbar.removeToolbarItems();this._launcherView.show(this.profileViews);this.visibleView=this._launcherView;this._toolbarElement.classList.add('hidden');} _registerProfileType(profileType){this._launcherView.addProfileType(profileType);const profileTypeSection=new Profiler.ProfileTypeSidebarSection(this,profileType);this._typeIdToSidebarSection[profileType.id]=profileTypeSection;this._sidebarTree.appendChild(profileTypeSection);profileTypeSection.childrenListElement.addEventListener('contextmenu',this._handleContextMenuEvent.bind(this),false);function onAddProfileHeader(event){this._addProfileHeader((event.data));} function onRemoveProfileHeader(event){this._removeProfileHeader((event.data));} function profileComplete(event){this.showProfile((event.data));} profileType.addEventListener(Profiler.ProfileType.Events.ViewUpdated,this._updateProfileTypeSpecificUI,this);profileType.addEventListener(Profiler.ProfileType.Events.AddProfileHeader,onAddProfileHeader,this);profileType.addEventListener(Profiler.ProfileType.Events.RemoveProfileHeader,onRemoveProfileHeader,this);profileType.addEventListener(Profiler.ProfileType.Events.ProfileComplete,profileComplete,this);const profiles=profileType.getProfiles();for(let i=0;i=2){sidebarParent=group.sidebarTreeElement;profileTreeElement.setSmall(true);profileTreeElement.setMainTitle(Common.UIString('Run %d',groupSize));}} sidebarParent.appendChild(profileTreeElement);} removeProfileHeader(profile){const index=this._sidebarElementIndex(profile);if(index===-1) return false;const profileTreeElement=this._profileTreeElements[index];this._profileTreeElements.splice(index,1);let sidebarParent=this;const group=this._profileGroups[profile.title];if(group){const groupElements=group.profileSidebarTreeElements;groupElements.splice(groupElements.indexOf(profileTreeElement),1);if(groupElements.length===1){const pos=sidebarParent.children().indexOf((group.sidebarTreeElement));group.sidebarTreeElement.removeChild(groupElements[0]);this.insertChild(groupElements[0],pos);groupElements[0].setSmall(false);groupElements[0].setMainTitle(profile.title);this.removeChild(group.sidebarTreeElement);} if(groupElements.length!==0) sidebarParent=group.sidebarTreeElement;} sidebarParent.removeChild(profileTreeElement);profileTreeElement.dispose();if(this.childCount()) return false;this.hidden=true;return true;} sidebarElementForProfile(profile){const index=this._sidebarElementIndex(profile);return index===-1?null:this._profileTreeElements[index];} _sidebarElementIndex(profile){const elements=this._profileTreeElements;for(let i=0;i0;if(hasChildren) this._dataDisplayDelegate.showProfile(this.lastChild().profile);return hasChildren;} onattach(){this.listItemElement.classList.add('profile-group-sidebar-tree-item');this.listItemElement.createChild('div','icon');this.listItemElement.createChild('div','titles no-subtitle').createChild('span','title-container').createChild('span','title').textContent=this._title;}};Profiler.ProfilesSidebarTreeElement=class extends UI.TreeElement{constructor(panel){super('',false);this.selectable=true;this._panel=panel;} onselect(){this._panel._showLauncherView();return true;} onattach(){this.listItemElement.classList.add('profile-launcher-view-tree-item');this.listItemElement.createChild('div','icon');this.listItemElement.createChild('div','titles no-subtitle').createChild('span','title-container').createChild('span','title').textContent=Common.UIString('Profiles');}};Profiler.JSProfilerPanel=class extends Profiler.ProfilesPanel{constructor(){const registry=Profiler.ProfileTypeRegistry.instance;super('js_profiler',[registry.cpuProfileType],'profiler.js-toggle-recording');} wasShown(){UI.context.setFlavor(Profiler.JSProfilerPanel,this);} willHide(){UI.context.setFlavor(Profiler.JSProfilerPanel,null);} handleAction(context,actionId){const panel=UI.context.flavor(Profiler.JSProfilerPanel);console.assert(panel&&panel instanceof Profiler.JSProfilerPanel);panel.toggleRecord();return true;}};;Profiler.ProfileView=class extends UI.SimpleView{constructor(){super(Common.UIString('Profile'));this._searchableView=new UI.SearchableView(this);this._searchableView.setPlaceholder(Common.UIString('Find by cost (>50ms), name or file'));this._searchableView.show(this.element);const columns=([]);columns.push({id:'self',title:this.columnHeader('self'),width:'120px',fixedWidth:true,sortable:true,sort:DataGrid.DataGrid.Order.Descending});columns.push({id:'total',title:this.columnHeader('total'),width:'120px',fixedWidth:true,sortable:true});columns.push({id:'function',title:Common.UIString('Function'),disclosure:true,sortable:true});this.dataGrid=new DataGrid.DataGrid(columns);this.dataGrid.addEventListener(DataGrid.DataGrid.Events.SortingChanged,this._sortProfile,this);this.dataGrid.addEventListener(DataGrid.DataGrid.Events.SelectedNode,this._nodeSelected.bind(this,true));this.dataGrid.addEventListener(DataGrid.DataGrid.Events.DeselectedNode,this._nodeSelected.bind(this,false));this.viewSelectComboBox=new UI.ToolbarComboBox(this._changeView.bind(this));this.focusButton=new UI.ToolbarButton(Common.UIString('Focus selected function'),'largeicon-visibility');this.focusButton.setEnabled(false);this.focusButton.addEventListener(UI.ToolbarButton.Events.Click,this._focusClicked,this);this.excludeButton=new UI.ToolbarButton(Common.UIString('Exclude selected function'),'largeicon-delete');this.excludeButton.setEnabled(false);this.excludeButton.addEventListener(UI.ToolbarButton.Events.Click,this._excludeClicked,this);this.resetButton=new UI.ToolbarButton(Common.UIString('Restore all functions'),'largeicon-refresh');this.resetButton.setEnabled(false);this.resetButton.addEventListener(UI.ToolbarButton.Events.Click,this._resetClicked,this);this._linkifier=new Components.Linkifier(Profiler.ProfileView._maxLinkLength);} static buildPopoverTable(entryInfo){const table=createElement('table');for(const entry of entryInfo){const row=table.createChild('tr');row.createChild('td').textContent=entry.title;row.createChild('td').textContent=entry.value;} return table;} initialize(nodeFormatter,viewTypes){this._nodeFormatter=nodeFormatter;this._viewType=Common.settings.createSetting('profileView',Profiler.ProfileView.ViewTypes.Heavy);viewTypes=viewTypes||[Profiler.ProfileView.ViewTypes.Flame,Profiler.ProfileView.ViewTypes.Heavy,Profiler.ProfileView.ViewTypes.Tree];const optionNames=new Map([[Profiler.ProfileView.ViewTypes.Flame,Common.UIString('Chart')],[Profiler.ProfileView.ViewTypes.Heavy,Common.UIString('Heavy (Bottom Up)')],[Profiler.ProfileView.ViewTypes.Tree,Common.UIString('Tree (Top Down)')],]);const options=new Map(viewTypes.map(type=>[type,this.viewSelectComboBox.createOption(optionNames.get(type),'',type)]));const optionName=this._viewType.get()||viewTypes[0];const option=options.get(optionName)||options.get(viewTypes[0]);this.viewSelectComboBox.select(option);this._changeView();if(this._flameChart) this._flameChart.update();} focus(){if(this._flameChart) this._flameChart.focus();else super.focus();} columnHeader(columnId){throw'Not implemented';} selectRange(timeLeft,timeRight){if(!this._flameChart) return;this._flameChart.selectRange(timeLeft,timeRight);} syncToolbarItems(){return[this.viewSelectComboBox,this.focusButton,this.excludeButton,this.resetButton];} _getBottomUpProfileDataGridTree(){if(!this._bottomUpProfileDataGridTree){this._bottomUpProfileDataGridTree=new Profiler.BottomUpProfileDataGridTree(this._nodeFormatter,this._searchableView,this.profile.root,this.adjustedTotal);} return this._bottomUpProfileDataGridTree;} _getTopDownProfileDataGridTree(){if(!this._topDownProfileDataGridTree){this._topDownProfileDataGridTree=new Profiler.TopDownProfileDataGridTree(this._nodeFormatter,this._searchableView,this.profile.root,this.adjustedTotal);} return this._topDownProfileDataGridTree;} willHide(){this._currentSearchResultIndex=-1;} refresh(){const selectedProfileNode=this.dataGrid.selectedNode?this.dataGrid.selectedNode.profileNode:null;this.dataGrid.rootNode().removeChildren();const children=this.profileDataGridTree.children;const count=children.length;for(let index=0;indexrhs[property]) return 1;return 0;};}else{comparator=function(lhs,rhs){if(lhs[property]>rhs[property]) return-1;if(lhs[property]'));const lessThan=(query.startsWith('<'));let equalTo=(query.startsWith('=')||((greaterThan||lessThan)&&query.indexOf('=')===1));const percentUnits=(query.endsWith('%'));const millisecondsUnits=(query.length>2&&query.endsWith('ms'));const secondsUnits=(!millisecondsUnits&&query.endsWith('s'));let queryNumber=parseFloat(query);if(greaterThan||lessThan||equalTo){if(equalTo&&(greaterThan||lessThan)) queryNumber=parseFloat(query.substring(2));else queryNumber=parseFloat(query.substring(1));} const queryNumberMilliseconds=(secondsUnits?(queryNumber*1000):queryNumber);if(!isNaN(queryNumber)&&!(greaterThan||lessThan)) equalTo=true;const matcher=createPlainTextSearchRegex(query,'i');function matchesQuery(profileDataGridNode){delete profileDataGridNode._searchMatchedSelfColumn;delete profileDataGridNode._searchMatchedTotalColumn;delete profileDataGridNode._searchMatchedFunctionColumn;if(percentUnits){if(lessThan){if(profileDataGridNode.selfPercentqueryNumber) profileDataGridNode._searchMatchedSelfColumn=true;if(profileDataGridNode.totalPercent>queryNumber) profileDataGridNode._searchMatchedTotalColumn=true;} if(equalTo){if(profileDataGridNode.selfPercent===queryNumber) profileDataGridNode._searchMatchedSelfColumn=true;if(profileDataGridNode.totalPercent===queryNumber) profileDataGridNode._searchMatchedTotalColumn=true;}}else if(millisecondsUnits||secondsUnits){if(lessThan){if(profileDataGridNode.selfqueryNumberMilliseconds) profileDataGridNode._searchMatchedSelfColumn=true;if(profileDataGridNode.total>queryNumberMilliseconds) profileDataGridNode._searchMatchedTotalColumn=true;} if(equalTo){if(profileDataGridNode.self===queryNumberMilliseconds) profileDataGridNode._searchMatchedSelfColumn=true;if(profileDataGridNode.total===queryNumberMilliseconds) profileDataGridNode._searchMatchedTotalColumn=true;}} if(profileDataGridNode.functionName.match(matcher)||(profileDataGridNode.url&&profileDataGridNode.url.match(matcher))) profileDataGridNode._searchMatchedFunctionColumn=true;if(profileDataGridNode._searchMatchedSelfColumn||profileDataGridNode._searchMatchedTotalColumn||profileDataGridNode._searchMatchedFunctionColumn){profileDataGridNode.refresh();return true;} return false;} return matchesQuery;} performSearch(searchConfig,shouldJump,jumpBackwards){this.searchCanceled();const matchesQuery=this._matchFunction(searchConfig);if(!matchesQuery) return;this._searchResults=[];const deepSearch=this.deepSearch;for(let current=this.children[0];current;current=current.traverseNextNode(!deepSearch,null,!deepSearch)){if(matchesQuery(current)) this._searchResults.push({profileNode:current});} this._searchResultIndex=jumpBackwards?0:this._searchResults.length-1;this._searchableView.updateSearchMatchesCount(this._searchResults.length);this._searchableView.updateCurrentMatchIndex(this._searchResultIndex);} searchCanceled(){if(this._searchResults){for(let i=0;inew Profiler.SamplingHeapProfileNode(child));sourceNodeStack.push.apply(sourceNodeStack,sourceNode.children);targetNodeStack.push.apply(targetNodeStack,parentNode.children);} return resultRoot;}}};Profiler.HeapProfileView.NodeFormatter=class{constructor(profileView){this._profileView=profileView;} formatValue(value){return Number.withThousandsSeparator(value);} formatPercent(value,node){return Common.UIString('%.2f\xa0%%',value);} linkifyNode(node){const heapProfilerModel=this._profileView._profileHeader._heapProfilerModel;return this._profileView.linkifier().maybeLinkifyConsoleCallFrame(heapProfilerModel?heapProfilerModel.target():null,node.profileNode.callFrame,'profile-node-file');}};Profiler.HeapFlameChartDataProvider=class extends Profiler.ProfileFlameChartDataProvider{constructor(profile,heapProfilerModel){super();this._profile=profile;this._heapProfilerModel=heapProfilerModel;} minimumBoundary(){return 0;} totalTime(){return this._profile.root.total;} formatValue(value,precision){return Common.UIString('%s\xa0KB',Number.withThousandsSeparator(value/1e3));} _calculateTimelineData(){function nodesCount(node){return node.children.reduce((count,node)=>count+nodesCount(node),1);} const count=nodesCount(this._profile.root);const entryNodes=new Array(count);const entryLevels=new Uint16Array(count);const entryTotalTimes=new Float32Array(count);const entryStartTimes=new Float64Array(count);let depth=0;let maxDepth=0;let position=0;let index=0;function addNode(node){const start=position;entryNodes[index]=node;entryLevels[index]=depth;entryTotalTimes[index]=node.total;entryStartTimes[index]=position;++index;++depth;node.children.forEach(addNode);--depth;maxDepth=Math.max(maxDepth,depth);position=start+node.total;} addNode(this._profile.root);this._maxStackDepth=maxDepth+1;this._entryNodes=entryNodes;this._timelineData=new PerfUI.FlameChart.TimelineData(entryLevels,entryTotalTimes,entryStartTimes,null);return this._timelineData;} prepareHighlightedEntryInfo(entryIndex){const node=this._entryNodes[entryIndex];if(!node) return null;const entryInfo=[];function pushEntryInfoRow(title,value){entryInfo.push({title:title,value:value});} pushEntryInfoRow(Common.UIString('Name'),UI.beautifyFunctionName(node.functionName));pushEntryInfoRow(Common.UIString('Self size'),Number.bytesToString(node.self));pushEntryInfoRow(Common.UIString('Total size'),Number.bytesToString(node.total));const linkifier=new Components.Linkifier();const link=linkifier.maybeLinkifyConsoleCallFrame(this._heapProfilerModel?this._heapProfilerModel.target():null,node.callFrame);if(link) pushEntryInfoRow(Common.UIString('URL'),link.textContent);linkifier.dispose();return Profiler.ProfileView.buildPopoverTable(entryInfo);}};;Profiler.HeapSnapshotWorkerProxy=class extends Common.Object{constructor(eventHandler){super();this._eventHandler=eventHandler;this._nextObjectId=1;this._nextCallId=1;this._callbacks=new Map();this._previousCallbacks=new Set();this._worker=new Common.Worker('heap_snapshot_worker');this._worker.onmessage=this._messageReceived.bind(this);} createLoader(profileUid,snapshotReceivedCallback){const objectId=this._nextObjectId++;const proxy=new Profiler.HeapSnapshotLoaderProxy(this,objectId,profileUid,snapshotReceivedCallback);this._postMessage({callId:this._nextCallId++,disposition:'create',objectId:objectId,methodName:'HeapSnapshotWorker.HeapSnapshotLoader'});return proxy;} dispose(){this._worker.terminate();if(this._interval) clearInterval(this._interval);} disposeObject(objectId){this._postMessage({callId:this._nextCallId++,disposition:'dispose',objectId:objectId});} evaluateForTest(script,callback){const callId=this._nextCallId++;this._callbacks.set(callId,callback);this._postMessage({callId:callId,disposition:'evaluateForTest',source:script});} callFactoryMethod(callback,objectId,methodName,proxyConstructor){const callId=this._nextCallId++;const methodArguments=Array.prototype.slice.call(arguments,4);const newObjectId=this._nextObjectId++;function wrapCallback(remoteResult){callback(remoteResult?new proxyConstructor(this,newObjectId):null);} if(callback){this._callbacks.set(callId,wrapCallback.bind(this));this._postMessage({callId:callId,disposition:'factory',objectId:objectId,methodName:methodName,methodArguments:methodArguments,newObjectId:newObjectId});return null;}else{this._postMessage({callId:callId,disposition:'factory',objectId:objectId,methodName:methodName,methodArguments:methodArguments,newObjectId:newObjectId});return new proxyConstructor(this,newObjectId);}} callMethod(callback,objectId,methodName){const callId=this._nextCallId++;const methodArguments=Array.prototype.slice.call(arguments,3);if(callback) this._callbacks.set(callId,callback);this._postMessage({callId:callId,disposition:'method',objectId:objectId,methodName:methodName,methodArguments:methodArguments});} startCheckingForLongRunningCalls(){if(this._interval) return;this._checkLongRunningCalls();this._interval=setInterval(this._checkLongRunningCalls.bind(this),300);} _checkLongRunningCalls(){for(const callId of this._previousCallbacks){if(!this._callbacks.has(callId)) this._previousCallbacks.delete(callId);} const hasLongRunningCalls=!!this._previousCallbacks.size;this.dispatchEventToListeners(Profiler.HeapSnapshotWorkerProxy.Events.Wait,hasLongRunningCalls);for(const callId of this._callbacks.keysArray()) this._previousCallbacks.add(callId);} _messageReceived(event){const data=event.data;if(data.eventName){if(this._eventHandler) this._eventHandler(data.eventName,data.data);return;} if(data.error){if(data.errorMethodName){Common.console.error(Common.UIString('An error occurred when a call to method \'%s\' was requested',data.errorMethodName));} Common.console.error(data['errorCallStack']);this._callbacks.delete(data.callId);return;} if(!this._callbacks.has(data.callId)) return;const callback=this._callbacks.get(data.callId);this._callbacks.delete(data.callId);callback(data.result);} _postMessage(message){this._worker.postMessage(message);}};Profiler.HeapSnapshotWorkerProxy.Events={Wait:Symbol('Wait')};Profiler.HeapSnapshotProxyObject=class{constructor(worker,objectId){this._worker=worker;this._objectId=objectId;} _callWorker(workerMethodName,args){args.splice(1,0,this._objectId);return this._worker[workerMethodName].apply(this._worker,args);} dispose(){this._worker.disposeObject(this._objectId);} disposeWorker(){this._worker.dispose();} callFactoryMethod(callback,methodName,proxyConstructor,var_args){return this._callWorker('callFactoryMethod',Array.prototype.slice.call(arguments,0));} _callMethodPromise(methodName,var_args){const args=Array.prototype.slice.call(arguments);return new Promise(resolve=>this._callWorker('callMethod',[resolve,...args]));}};Profiler.HeapSnapshotLoaderProxy=class extends Profiler.HeapSnapshotProxyObject{constructor(worker,objectId,profileUid,snapshotReceivedCallback){super(worker,objectId);this._profileUid=profileUid;this._snapshotReceivedCallback=snapshotReceivedCallback;} write(chunk){return this._callMethodPromise('write',chunk);} async close(){await this._callMethodPromise('close');const snapshotProxy=await new Promise(resolve=>this.callFactoryMethod(resolve,'buildSnapshot',Profiler.HeapSnapshotProxy));this.dispose();snapshotProxy.setProfileUid(this._profileUid);await snapshotProxy.updateStaticData();this._snapshotReceivedCallback(snapshotProxy);}};Profiler.HeapSnapshotProxy=class extends Profiler.HeapSnapshotProxyObject{constructor(worker,objectId){super(worker,objectId);this._staticData=null;} search(searchConfig,filter){return this._callMethodPromise('search',searchConfig,filter);} aggregatesWithFilter(filter){return this._callMethodPromise('aggregatesWithFilter',filter);} aggregatesForDiff(){return this._callMethodPromise('aggregatesForDiff');} calculateSnapshotDiff(baseSnapshotId,baseSnapshotAggregates){return this._callMethodPromise('calculateSnapshotDiff',baseSnapshotId,baseSnapshotAggregates);} nodeClassName(snapshotObjectId){return this._callMethodPromise('nodeClassName',snapshotObjectId);} createEdgesProvider(nodeIndex){return this.callFactoryMethod(null,'createEdgesProvider',Profiler.HeapSnapshotProviderProxy,nodeIndex);} createRetainingEdgesProvider(nodeIndex){return this.callFactoryMethod(null,'createRetainingEdgesProvider',Profiler.HeapSnapshotProviderProxy,nodeIndex);} createAddedNodesProvider(baseSnapshotId,className){return this.callFactoryMethod(null,'createAddedNodesProvider',Profiler.HeapSnapshotProviderProxy,baseSnapshotId,className);} createDeletedNodesProvider(nodeIndexes){return this.callFactoryMethod(null,'createDeletedNodesProvider',Profiler.HeapSnapshotProviderProxy,nodeIndexes);} createNodesProvider(filter){return this.callFactoryMethod(null,'createNodesProvider',Profiler.HeapSnapshotProviderProxy,filter);} createNodesProviderForClass(className,nodeFilter){return this.callFactoryMethod(null,'createNodesProviderForClass',Profiler.HeapSnapshotProviderProxy,className,nodeFilter);} allocationTracesTops(){return this._callMethodPromise('allocationTracesTops');} allocationNodeCallers(nodeId){return this._callMethodPromise('allocationNodeCallers',nodeId);} allocationStack(nodeIndex){return this._callMethodPromise('allocationStack',nodeIndex);} dispose(){throw new Error('Should never be called');} get nodeCount(){return this._staticData.nodeCount;} get rootNodeIndex(){return this._staticData.rootNodeIndex;} async updateStaticData(){this._staticData=await this._callMethodPromise('updateStaticData');} getStatistics(){return this._callMethodPromise('getStatistics');} getSamples(){return this._callMethodPromise('getSamples');} get totalSize(){return this._staticData.totalSize;} get uid(){return this._profileUid;} setProfileUid(profileUid){this._profileUid=profileUid;} maxJSObjectId(){return this._staticData.maxJSObjectId;}};Profiler.HeapSnapshotProviderProxy=class extends Profiler.HeapSnapshotProxyObject{constructor(worker,objectId){super(worker,objectId);} nodePosition(snapshotObjectId){return this._callMethodPromise('nodePosition',snapshotObjectId);} isEmpty(){return this._callMethodPromise('isEmpty');} serializeItemsRange(startPosition,endPosition){return this._callMethodPromise('serializeItemsRange',startPosition,endPosition);} sortAndRewind(comparator){return this._callMethodPromise('sortAndRewind',comparator);}};;Profiler.HeapSnapshotSortableDataGrid=class extends DataGrid.DataGrid{constructor(dataDisplayDelegate,columns){super(columns);this._dataDisplayDelegate=dataDisplayDelegate;this._recursiveSortingDepth=0;this._highlightedNode=null;this._populatedAndSorted=false;this._nameFilter=null;this._nodeFilter=new HeapSnapshotModel.NodeFilter();this.addEventListener(Profiler.HeapSnapshotSortableDataGrid.Events.SortingComplete,this._sortingComplete,this);this.addEventListener(DataGrid.DataGrid.Events.SortingChanged,this.sortingChanged,this);} nodeFilter(){return this._nodeFilter;} setNameFilter(nameFilter){this._nameFilter=nameFilter;} defaultPopulateCount(){return 100;} _disposeAllNodes(){const children=this.topLevelNodes();for(let i=0,l=children.length;ifield2?1:0);if(!sortFields[1]) result=-result;if(result!==0) return result;field1=nodeA[sortFields[2]];field2=nodeB[sortFields[2]];result=field1field2?1:0);if(!sortFields[3]) result=-result;return result;} this._performSorting(SortByTwoFields);} _performSorting(sortFunction){this.recursiveSortingEnter();const children=this.allChildren(this.rootNode());this.rootNode().removeChildren();children.sort(sortFunction);for(let i=0,l=children.length;i=this._topPaddingHeight&&scrollBottom>=this._bottomPaddingHeight) return;const hysteresisHeight=500;scrollTop-=hysteresisHeight;viewPortHeight+=2*hysteresisHeight;const selectedNode=this.selectedNode;this.rootNode().removeChildren();this._topPaddingHeight=0;this._bottomPaddingHeight=0;this._addVisibleNodes(this.rootNode(),scrollTop,scrollTop+viewPortHeight);this.setVerticalPadding(this._topPaddingHeight,this._bottomPaddingHeight);if(selectedNode){if(selectedNode.parent) selectedNode.select(true);else this.selectedNode=selectedNode;}} _addVisibleNodes(parentNode,topBound,bottomBound){if(!parentNode.expanded) return 0;const children=this.allChildren(parentNode);let topPadding=0;const nameFilterValue=this._nameFilter?this._nameFilter.value().toLowerCase():'';let i=0;for(;itopBound) break;topPadding=newTop;} let position=topPadding;for(;i=scrollTop&&height{console.assert(!this._scrollToResolveCallback);this._scrollToResolveCallback=resolve.bind(null,node);});} _calculateOffset(pathToReveal){let parentNode=this.rootNode();let height=0;for(let i=0;i=viewportTop;} onResize(){super.onResize();this.updateVisibleNodes(false);} _onScroll(event){this.updateVisibleNodes(false);if(this._scrollToResolveCallback){this._scrollToResolveCallback();this._scrollToResolveCallback=null;}}};Profiler.HeapSnapshotContainmentDataGrid=class extends Profiler.HeapSnapshotSortableDataGrid{constructor(dataDisplayDelegate,columns){columns=columns||(([{id:'object',title:Common.UIString('Object'),disclosure:true,sortable:true},{id:'distance',title:Common.UIString('Distance'),width:'70px',sortable:true,fixedWidth:true},{id:'shallowSize',title:Common.UIString('Shallow Size'),width:'110px',sortable:true,fixedWidth:true},{id:'retainedSize',title:Common.UIString('Retained Size'),width:'110px',sortable:true,fixedWidth:true,sort:DataGrid.DataGrid.Order.Descending}]));super(dataDisplayDelegate,columns);} setDataSource(snapshot,nodeIndex){this.snapshot=snapshot;const node={nodeIndex:nodeIndex||snapshot.rootNodeIndex};const fakeEdge={node:node};this.setRootNode(this._createRootNode(snapshot,fakeEdge));this.rootNode().sort();} _createRootNode(snapshot,fakeEdge){return new Profiler.HeapSnapshotObjectNode(this,snapshot,fakeEdge,null);} sortingChanged(){const rootNode=this.rootNode();if(rootNode.hasChildren()) rootNode.sort();}};Profiler.HeapSnapshotRetainmentDataGrid=class extends Profiler.HeapSnapshotContainmentDataGrid{constructor(dataDisplayDelegate){const columns=([{id:'object',title:Common.UIString('Object'),disclosure:true,sortable:true},{id:'distance',title:Common.UIString('Distance'),width:'70px',sortable:true,fixedWidth:true,sort:DataGrid.DataGrid.Order.Ascending},{id:'shallowSize',title:Common.UIString('Shallow Size'),width:'110px',sortable:true,fixedWidth:true},{id:'retainedSize',title:Common.UIString('Retained Size'),width:'110px',sortable:true,fixedWidth:true}]);super(dataDisplayDelegate,columns);} _createRootNode(snapshot,fakeEdge){return new Profiler.HeapSnapshotRetainingObjectNode(this,snapshot,fakeEdge,null);} _sortFields(sortColumn,sortAscending){return{object:['_name',sortAscending,'_count',false],count:['_count',sortAscending,'_name',true],shallowSize:['_shallowSize',sortAscending,'_name',true],retainedSize:['_retainedSize',sortAscending,'_name',true],distance:['_distance',sortAscending,'_name',true]}[sortColumn];} reset(){this.rootNode().removeChildren();this.resetSortingCache();} setDataSource(snapshot,nodeIndex){super.setDataSource(snapshot,nodeIndex);this.rootNode().expand();}};Profiler.HeapSnapshotRetainmentDataGrid.Events={ExpandRetainersComplete:Symbol('ExpandRetainersComplete')};Profiler.HeapSnapshotConstructorsDataGrid=class extends Profiler.HeapSnapshotViewportDataGrid{constructor(dataDisplayDelegate){const columns=([{id:'object',title:Common.UIString('Constructor'),disclosure:true,sortable:true},{id:'distance',title:Common.UIString('Distance'),width:'70px',sortable:true,fixedWidth:true},{id:'count',title:Common.UIString('Objects Count'),width:'100px',sortable:true,fixedWidth:true},{id:'shallowSize',title:Common.UIString('Shallow Size'),width:'110px',sortable:true,fixedWidth:true},{id:'retainedSize',title:Common.UIString('Retained Size'),width:'110px',sort:DataGrid.DataGrid.Order.Descending,sortable:true,fixedWidth:true}]);super(dataDisplayDelegate,columns);this._profileIndex=-1;this._objectIdToSelect=null;} _sortFields(sortColumn,sortAscending){return{object:['_name',sortAscending,'_count',false],distance:['_distance',sortAscending,'_retainedSize',true],count:['_count',sortAscending,'_name',true],shallowSize:['_shallowSize',sortAscending,'_name',true],retainedSize:['_retainedSize',sortAscending,'_name',true]}[sortColumn];} async revealObjectByHeapSnapshotId(id){if(!this.snapshot){this._objectIdToSelect=id;return null;} const className=await this.snapshot.nodeClassName(parseInt(id,10));if(!className) return null;const parent=this.topLevelNodes().find(classNode=>classNode._name===className);if(!parent) return null;const nodes=await parent.populateNodeBySnapshotObjectId(parseInt(id,10));return nodes.length?this.revealTreeNode(nodes):null;} clear(){this._nextRequestedFilter=null;this._lastFilter=null;this.removeTopLevelNodes();} setDataSource(snapshot){this.snapshot=snapshot;if(this._profileIndex===-1) this._populateChildren();if(this._objectIdToSelect){this.revealObjectByHeapSnapshotId(this._objectIdToSelect);this._objectIdToSelect=null;}} setSelectionRange(minNodeId,maxNodeId){this._nodeFilter=new HeapSnapshotModel.NodeFilter(minNodeId,maxNodeId);this._populateChildren(this._nodeFilter);} setAllocationNodeId(allocationNodeId){this._nodeFilter=new HeapSnapshotModel.NodeFilter();this._nodeFilter.allocationNodeId=allocationNodeId;this._populateChildren(this._nodeFilter);} _aggregatesReceived(nodeFilter,aggregates){this._filterInProgress=null;if(this._nextRequestedFilter){this.snapshot.aggregatesWithFilter(this._nextRequestedFilter).then(this._aggregatesReceived.bind(this,this._nextRequestedFilter));this._filterInProgress=this._nextRequestedFilter;this._nextRequestedFilter=null;} this.removeTopLevelNodes();this.resetSortingCache();for(const constructor in aggregates){this.appendNode(this.rootNode(),new Profiler.HeapSnapshotConstructorNode(this,constructor,aggregates[constructor],nodeFilter));} this.sortingChanged();this._lastFilter=nodeFilter;} async _populateChildren(maybeNodeFilter){const nodeFilter=maybeNodeFilter||new HeapSnapshotModel.NodeFilter();if(this._filterInProgress){this._nextRequestedFilter=this._filterInProgress.equals(nodeFilter)?null:nodeFilter;return;} if(this._lastFilter&&this._lastFilter.equals(nodeFilter)) return;this._filterInProgress=nodeFilter;const aggregates=await this.snapshot.aggregatesWithFilter(nodeFilter);this._aggregatesReceived(nodeFilter,aggregates);} filterSelectIndexChanged(profiles,profileIndex){this._profileIndex=profileIndex;this._nodeFilter=undefined;if(profileIndex!==-1){const minNodeId=profileIndex>0?profiles[profileIndex-1].maxJSObjectId:0;const maxNodeId=profiles[profileIndex].maxJSObjectId;this._nodeFilter=new HeapSnapshotModel.NodeFilter(minNodeId,maxNodeId);} this._populateChildren(this._nodeFilter);}};Profiler.HeapSnapshotDiffDataGrid=class extends Profiler.HeapSnapshotViewportDataGrid{constructor(dataDisplayDelegate){const columns=([{id:'object',title:Common.UIString('Constructor'),disclosure:true,sortable:true},{id:'addedCount',title:Common.UIString('# New'),width:'75px',sortable:true,fixedWidth:true},{id:'removedCount',title:Common.UIString('# Deleted'),width:'75px',sortable:true,fixedWidth:true},{id:'countDelta',title:Common.UIString('# Delta'),width:'65px',sortable:true,fixedWidth:true},{id:'addedSize',title:Common.UIString('Alloc. Size'),width:'75px',sortable:true,fixedWidth:true,sort:DataGrid.DataGrid.Order.Descending},{id:'removedSize',title:Common.UIString('Freed Size'),width:'75px',sortable:true,fixedWidth:true},{id:'sizeDelta',title:Common.UIString('Size Delta'),width:'75px',sortable:true,fixedWidth:true}]);super(dataDisplayDelegate,columns);} defaultPopulateCount(){return 50;} _sortFields(sortColumn,sortAscending){return{object:['_name',sortAscending,'_count',false],addedCount:['_addedCount',sortAscending,'_name',true],removedCount:['_removedCount',sortAscending,'_name',true],countDelta:['_countDelta',sortAscending,'_name',true],addedSize:['_addedSize',sortAscending,'_name',true],removedSize:['_removedSize',sortAscending,'_name',true],sizeDelta:['_sizeDelta',sortAscending,'_name',true]}[sortColumn];} setDataSource(snapshot){this.snapshot=snapshot;} setBaseDataSource(baseSnapshot){this.baseSnapshot=baseSnapshot;this.removeTopLevelNodes();this.resetSortingCache();if(this.baseSnapshot===this.snapshot){this.dispatchEventToListeners(Profiler.HeapSnapshotSortableDataGrid.Events.SortingComplete);return;} this._populateChildren();} async _populateChildren(){const aggregatesForDiff=await this.baseSnapshot.aggregatesForDiff();const diffByClassName=await this.snapshot.calculateSnapshotDiff(this.baseSnapshot.uid,aggregatesForDiff);for(const className in diffByClassName){const diff=diffByClassName[className];this.appendNode(this.rootNode(),new Profiler.HeapSnapshotDiffNode(this,className,diff));} this.sortingChanged();}};Profiler.AllocationDataGrid=class extends Profiler.HeapSnapshotViewportDataGrid{constructor(heapProfilerModel,dataDisplayDelegate){const columns=([{id:'liveCount',title:Common.UIString('Live Count'),width:'75px',sortable:true,fixedWidth:true},{id:'count',title:Common.UIString('Count'),width:'65px',sortable:true,fixedWidth:true},{id:'liveSize',title:Common.UIString('Live Size'),width:'75px',sortable:true,fixedWidth:true},{id:'size',title:Common.UIString('Size'),width:'75px',sortable:true,fixedWidth:true,sort:DataGrid.DataGrid.Order.Descending},{id:'name',title:Common.UIString('Function'),disclosure:true,sortable:true},]);super(dataDisplayDelegate,columns);this._heapProfilerModel=heapProfilerModel;this._linkifier=new Components.Linkifier();} heapProfilerModel(){return this._heapProfilerModel;} dispose(){this._linkifier.reset();} async setDataSource(snapshot){this.snapshot=snapshot;this._topNodes=await this.snapshot.allocationTracesTops();this._populateChildren();} _populateChildren(){this.removeTopLevelNodes();const root=this.rootNode();const tops=this._topNodes;for(const top of tops) this.appendNode(root,new Profiler.AllocationGridNode(this,top));this.updateVisibleNodes(true);} sortingChanged(){this._topNodes.sort(this._createComparator());this.rootNode().removeChildren();this._populateChildren();} _createComparator(){const fieldName=this.sortColumnId();const compareResult=(this.sortOrder()===DataGrid.DataGrid.Order.Ascending)?+1:-1;function compare(a,b){if(a[fieldName]>b[fieldName]) return compareResult;if(a[fieldName]=0&&distancethis._populateChildren());} expandWithoutPopulate(){this._populated=true;this.expand();return this._provider().sortAndRewind(this.comparator());} _populateChildren(fromPosition,toPosition){let afterPopulate;const promise=new Promise(resolve=>afterPopulate=resolve);fromPosition=fromPosition||0;toPosition=toPosition||fromPosition+this._dataGrid.defaultPopulateCount();let firstNotSerializedPosition=fromPosition;serializeNextChunk.call(this);return promise;function serializeNextChunk(){if(firstNotSerializedPosition>=toPosition) return;const end=Math.min(firstNotSerializedPosition+this._dataGrid.defaultPopulateCount(),toPosition);this._provider().serializeItemsRange(firstNotSerializedPosition,end).then(childrenRetrieved.bind(this));firstNotSerializedPosition=end;} function insertRetrievedChild(item,insertionIndex){if(this._savedChildren){const hash=this._childHashForEntity(item);if(hash in this._savedChildren){this._dataGrid.insertChild(this,this._savedChildren[hash],insertionIndex);return;}} this._dataGrid.insertChild(this,this._createChildNode(item),insertionIndex);} function insertShowMoreButton(from,to,insertionIndex){const button=new DataGrid.ShowMoreDataGridNode(this._populateChildren.bind(this),from,to,this._dataGrid.defaultPopulateCount());this._dataGrid.insertChild(this,button,insertionIndex);} function childrenRetrieved(itemsRange){let itemIndex=0;let itemPosition=itemsRange.startPosition;const items=itemsRange.items;let insertionIndex=0;if(!this._retrievedChildrenRanges.length){if(itemsRange.startPosition>0){this._retrievedChildrenRanges.push({from:0,to:0});insertShowMoreButton.call(this,0,itemsRange.startPosition,insertionIndex++);} this._retrievedChildrenRanges.push({from:itemsRange.startPosition,to:itemsRange.endPosition});for(let i=0,l=items.length;i=itemPosition){found=true;break;} insertionIndex+=range.to-range.from;if(range.toitemsRange.endPosition) newEndOfRange=itemsRange.endPosition;while(itemPositionfulfill=x);function onResult(object){fulfill(object||runtimeModel.createRemoteObjectFromPrimitiveValue(Common.UIString('Preview is not available')));} const runtimeModel=heapProfilerModel.runtimeModel();if(this._type==='string') onResult(runtimeModel.createRemoteObjectFromPrimitiveValue(this._name));else if(!heapProfilerModel||!runtimeModel) onResult(null);else heapProfilerModel.objectForSnapshotObjectId(String(this.snapshotNodeId),objectGroupName).then(onResult);return promise;} async updateHasChildren(){const isEmpty=await this._provider().isEmpty();this.setHasChildren(!isEmpty);} shortenWindowURL(fullName,hasObjectId){const startPos=fullName.indexOf('/');const endPos=hasObjectId?fullName.indexOf('@'):fullName.length;if(startPos===-1||endPos===-1) return fullName;const fullURL=fullName.substring(startPos+1,endPos).trimLeft();let url=fullURL.trimURL();if(url.length>40) url=url.trimMiddle(40);return fullName.substr(0,startPos+2)+url+fullName.substr(endPos);}};Profiler.HeapSnapshotObjectNode=class extends Profiler.HeapSnapshotGenericObjectNode{constructor(dataGrid,snapshot,edge,parentObjectNode){super(dataGrid,edge.node);this._referenceName=edge.name;this._referenceType=edge.type;this._edgeIndex=edge.edgeIndex;this._snapshot=snapshot;this._parentObjectNode=parentObjectNode;this._cycledWithAncestorGridNode=this._findAncestorWithSameSnapshotNodeId();if(!this._cycledWithAncestorGridNode) this.updateHasChildren();const data=this.data;data['count']='';data['addedCount']='';data['removedCount']='';data['countDelta']='';data['addedSize']='';data['removedSize']='';data['sizeDelta']='';} retainersDataSource(){return{snapshot:this._snapshot,snapshotNodeIndex:this.snapshotNodeIndex};} createProvider(){return this._snapshot.createEdgesProvider(this.snapshotNodeIndex);} _findAncestorWithSameSnapshotNodeId(){let ancestor=this._parentObjectNode;while(ancestor){if(ancestor.snapshotNodeId===this.snapshotNodeId) return ancestor;ancestor=ancestor._parentObjectNode;} return null;} _createChildNode(item){return new Profiler.HeapSnapshotObjectNode(this._dataGrid,this._snapshot,item,this);} _childHashForEntity(edge){return edge.edgeIndex;} _childHashForNode(childNode){return childNode._edgeIndex;} comparator(){const sortAscending=this._dataGrid.isSortOrderAscending();const sortColumnId=this._dataGrid.sortColumnId();const sortFields={object:['!edgeName',sortAscending,'retainedSize',false],count:['!edgeName',true,'retainedSize',false],shallowSize:['selfSize',sortAscending,'!edgeName',true],retainedSize:['retainedSize',sortAscending,'!edgeName',true],distance:['distance',sortAscending,'_name',true]}[sortColumnId]||['!edgeName',true,'retainedSize',false];return Profiler.HeapSnapshotGridNode.createComparator(sortFields);} _prefixObjectCell(div){let name=this._referenceName||'(empty)';let nameClass='name';switch(this._referenceType){case'context':nameClass='object-value-number';break;case'internal':case'hidden':case'weak':nameClass='object-value-null';break;case'element':name='['+name+']';break;} if(this._cycledWithAncestorGridNode) div.className+=' cycled-ancessor-node';const nameSpan=createElement('span');nameSpan.className=nameClass;nameSpan.textContent=name;div.appendChild(nameSpan);const separatorSpan=createElement('span');separatorSpan.className='grayed';separatorSpan.textContent=this._edgeNodeSeparator();div.appendChild(separatorSpan);} _edgeNodeSeparator(){return' :: ';}};Profiler.HeapSnapshotRetainingObjectNode=class extends Profiler.HeapSnapshotObjectNode{constructor(dataGrid,snapshot,edge,parentRetainingObjectNode){super(dataGrid,snapshot,edge,parentRetainingObjectNode);} createProvider(){return this._snapshot.createRetainingEdgesProvider(this.snapshotNodeIndex);} _createChildNode(item){return new Profiler.HeapSnapshotRetainingObjectNode(this._dataGrid,this._snapshot,item,this);} _edgeNodeSeparator(){return' in ';} expand(){this._expandRetainersChain(20);} _expandRetainersChain(maxExpandLevels){if(!this._populated){this.once(Profiler.HeapSnapshotGridNode.Events.PopulateComplete).then(()=>this._expandRetainersChain(maxExpandLevels));this.populate();return;} super.expand();if(--maxExpandLevels>0&&this.children.length>0){const retainer=this.children[0];if(retainer._distance>1){retainer._expandRetainersChain(maxExpandLevels);return;}} this._dataGrid.dispatchEventToListeners(Profiler.HeapSnapshotRetainmentDataGrid.Events.ExpandRetainersComplete);}};Profiler.HeapSnapshotInstanceNode=class extends Profiler.HeapSnapshotGenericObjectNode{constructor(dataGrid,snapshot,node,isDeletedNode){super(dataGrid,node);this._baseSnapshotOrSnapshot=snapshot;this._isDeletedNode=isDeletedNode;this.updateHasChildren();const data=this.data;data['count']='';data['countDelta']='';data['sizeDelta']='';if(this._isDeletedNode){data['addedCount']='';data['addedSize']='';data['removedCount']='\u2022';data['removedSize']=Number.withThousandsSeparator(this._shallowSize);}else{data['addedCount']='\u2022';data['addedSize']=Number.withThousandsSeparator(this._shallowSize);data['removedCount']='';data['removedSize']='';}} retainersDataSource(){return{snapshot:this._baseSnapshotOrSnapshot,snapshotNodeIndex:this.snapshotNodeIndex};} createProvider(){return this._baseSnapshotOrSnapshot.createEdgesProvider(this.snapshotNodeIndex);} _createChildNode(item){return new Profiler.HeapSnapshotObjectNode(this._dataGrid,this._baseSnapshotOrSnapshot,item,null);} _childHashForEntity(edge){return edge.edgeIndex;} _childHashForNode(childNode){return childNode._edgeIndex;} comparator(){const sortAscending=this._dataGrid.isSortOrderAscending();const sortColumnId=this._dataGrid.sortColumnId();const sortFields={object:['!edgeName',sortAscending,'retainedSize',false],distance:['distance',sortAscending,'retainedSize',false],count:['!edgeName',true,'retainedSize',false],addedSize:['selfSize',sortAscending,'!edgeName',true],removedSize:['selfSize',sortAscending,'!edgeName',true],shallowSize:['selfSize',sortAscending,'!edgeName',true],retainedSize:['retainedSize',sortAscending,'!edgeName',true]}[sortColumnId]||['!edgeName',true,'retainedSize',false];return Profiler.HeapSnapshotGridNode.createComparator(sortFields);}};Profiler.HeapSnapshotConstructorNode=class extends Profiler.HeapSnapshotGridNode{constructor(dataGrid,className,aggregate,nodeFilter){super(dataGrid,aggregate.count>0);this._name=className;this._nodeFilter=nodeFilter;this._distance=aggregate.distance;this._count=aggregate.count;this._shallowSize=aggregate.self;this._retainedSize=aggregate.maxRet;const snapshot=dataGrid.snapshot;const countPercent=this._count/snapshot.nodeCount*100.0;const retainedSizePercent=this._retainedSize/snapshot.totalSize*100.0;const shallowSizePercent=this._shallowSize/snapshot.totalSize*100.0;this.data={'object':className,'count':Number.withThousandsSeparator(this._count),'distance':this._toUIDistance(this._distance),'shallowSize':Number.withThousandsSeparator(this._shallowSize),'retainedSize':Number.withThousandsSeparator(this._retainedSize),'count-percent':this._toPercentString(countPercent),'shallowSize-percent':this._toPercentString(shallowSizePercent),'retainedSize-percent':this._toPercentString(retainedSizePercent)};} createProvider(){return this._dataGrid.snapshot.createNodesProviderForClass(this._name,this._nodeFilter);} async populateNodeBySnapshotObjectId(snapshotObjectId){this._dataGrid.resetNameFilter();await this.expandWithoutPopulate();const nodePosition=await this._provider().nodePosition(snapshotObjectId);if(nodePosition===-1){this.collapse();return[];} await this._populateChildren(nodePosition,null);const node=(this.childForPosition(nodePosition));return node?[this,node]:[];} filteredOut(filterValue){return this._name.toLowerCase().indexOf(filterValue)===-1;} createCell(columnId){const cell=columnId!=='object'?this._createValueCell(columnId):super.createCell(columnId);if(this._searchMatched) cell.classList.add('highlight');return cell;} _createChildNode(item){return new Profiler.HeapSnapshotInstanceNode(this._dataGrid,this._dataGrid.snapshot,item,false);} comparator(){const sortAscending=this._dataGrid.isSortOrderAscending();const sortColumnId=this._dataGrid.sortColumnId();const sortFields={object:['name',sortAscending,'id',true],distance:['distance',sortAscending,'retainedSize',false],count:['name',true,'id',true],shallowSize:['selfSize',sortAscending,'id',true],retainedSize:['retainedSize',sortAscending,'id',true]}[sortColumnId];return Profiler.HeapSnapshotGridNode.createComparator(sortFields);} _childHashForEntity(node){return node.id;} _childHashForNode(childNode){return childNode.snapshotNodeId;}};Profiler.HeapSnapshotDiffNodesProvider=class{constructor(addedNodesProvider,deletedNodesProvider,addedCount,removedCount){this._addedNodesProvider=addedNodesProvider;this._deletedNodesProvider=deletedNodesProvider;this._addedCount=addedCount;this._removedCount=removedCount;} dispose(){this._addedNodesProvider.dispose();this._deletedNodesProvider.dispose();} nodePosition(snapshotObjectId){throw new Error('Unreachable');} isEmpty(){return Promise.resolve(false);} async serializeItemsRange(beginPosition,endPosition){let itemsRange;let addedItems;if(beginPosition=endPosition){itemsRange.totalLength=this._addedCount+this._removedCount;return itemsRange;} addedItems=itemsRange;itemsRange=await this._deletedNodesProvider.serializeItemsRange(0,endPosition-itemsRange.endPosition);}else{addedItems=new HeapSnapshotModel.ItemsRange(0,0,0,[]);itemsRange=await this._deletedNodesProvider.serializeItemsRange(beginPosition-this._addedCount,endPosition-this._addedCount);} if(!addedItems.items.length) addedItems.startPosition=this._addedCount+itemsRange.startPosition;for(const item of itemsRange.items) item.isAddedNotRemoved=false;addedItems.items.pushAll(itemsRange.items);addedItems.endPosition=this._addedCount+itemsRange.endPosition;addedItems.totalLength=this._addedCount+this._removedCount;return addedItems;} async sortAndRewind(comparator){await this._addedNodesProvider.sortAndRewind(comparator);await this._deletedNodesProvider.sortAndRewind(comparator);}};Profiler.HeapSnapshotDiffNode=class extends Profiler.HeapSnapshotGridNode{constructor(dataGrid,className,diffForClass){super(dataGrid,true);this._name=className;this._addedCount=diffForClass.addedCount;this._removedCount=diffForClass.removedCount;this._countDelta=diffForClass.countDelta;this._addedSize=diffForClass.addedSize;this._removedSize=diffForClass.removedSize;this._sizeDelta=diffForClass.sizeDelta;this._deletedIndexes=diffForClass.deletedIndexes;this.data={'object':className,'addedCount':Number.withThousandsSeparator(this._addedCount),'removedCount':Number.withThousandsSeparator(this._removedCount),'countDelta':this._signForDelta(this._countDelta)+Number.withThousandsSeparator(Math.abs(this._countDelta)),'addedSize':Number.withThousandsSeparator(this._addedSize),'removedSize':Number.withThousandsSeparator(this._removedSize),'sizeDelta':this._signForDelta(this._sizeDelta)+Number.withThousandsSeparator(Math.abs(this._sizeDelta))};} createProvider(){const tree=this._dataGrid;return new Profiler.HeapSnapshotDiffNodesProvider(tree.snapshot.createAddedNodesProvider(tree.baseSnapshot.uid,this._name),tree.baseSnapshot.createDeletedNodesProvider(this._deletedIndexes),this._addedCount,this._removedCount);} createCell(columnId){const cell=super.createCell(columnId);if(columnId!=='object') cell.classList.add('numeric-column');return cell;} _createChildNode(item){if(item.isAddedNotRemoved) return new Profiler.HeapSnapshotInstanceNode(this._dataGrid,this._dataGrid.snapshot,item,false);else return new Profiler.HeapSnapshotInstanceNode(this._dataGrid,this._dataGrid.baseSnapshot,item,true);} _childHashForEntity(node){return node.id;} _childHashForNode(childNode){return childNode.snapshotNodeId;} comparator(){const sortAscending=this._dataGrid.isSortOrderAscending();const sortColumnId=this._dataGrid.sortColumnId();const sortFields={object:['name',sortAscending,'id',true],addedCount:['name',true,'id',true],removedCount:['name',true,'id',true],countDelta:['name',true,'id',true],addedSize:['selfSize',sortAscending,'id',true],removedSize:['selfSize',sortAscending,'id',true],sizeDelta:['selfSize',sortAscending,'id',true]}[sortColumnId];return Profiler.HeapSnapshotGridNode.createComparator(sortFields);} filteredOut(filterValue){return this._name.toLowerCase().indexOf(filterValue)===-1;} _signForDelta(delta){if(delta===0) return'';if(delta>0) return'+';else return'\u2212';}};Profiler.AllocationGridNode=class extends Profiler.HeapSnapshotGridNode{constructor(dataGrid,data){super(dataGrid,data.hasChildren);this._populated=false;this._allocationNode=data;this.data={'liveCount':Number.withThousandsSeparator(data.liveCount),'count':Number.withThousandsSeparator(data.count),'liveSize':Number.withThousandsSeparator(data.liveSize),'size':Number.withThousandsSeparator(data.size),'name':data.name};} populate(){if(this._populated) return;this._doPopulate();} async _doPopulate(){this._populated=true;const callers=await this._dataGrid.snapshot.allocationNodeCallers(this._allocationNode.id);const callersChain=callers.nodesWithSingleCaller;let parentNode=this;const dataGrid=(this._dataGrid);for(const caller of callersChain){const child=new Profiler.AllocationGridNode(dataGrid,caller);dataGrid.appendNode(parentNode,child);parentNode=child;parentNode._populated=true;if(this.expanded) parentNode.expand();} const callersBranch=callers.branchingCallers;callersBranch.sort(this._dataGrid._createComparator());for(const caller of callersBranch) dataGrid.appendNode(parentNode,new Profiler.AllocationGridNode(dataGrid,caller));dataGrid.updateVisibleNodes(true);} expand(){super.expand();if(this.children.length===1) this.children[0].expand();} createCell(columnId){if(columnId!=='name') return this._createValueCell(columnId);const cell=super.createCell(columnId);const allocationNode=this._allocationNode;const heapProfilerModel=this._dataGrid.heapProfilerModel();if(allocationNode.scriptId){const linkifier=this._dataGrid._linkifier;const urlElement=linkifier.linkifyScriptLocation(heapProfilerModel?heapProfilerModel.target():null,String(allocationNode.scriptId),allocationNode.scriptName,allocationNode.line-1,allocationNode.column-1,'profile-node-file');urlElement.style.maxWidth='75%';cell.insertBefore(urlElement,cell.firstChild);} return cell;} allocationNodeId(){return this._allocationNode.id;}};;Profiler.HeapSnapshotView=class extends UI.SimpleView{constructor(dataDisplayDelegate,profile){super(Common.UIString('Heap Snapshot'));this.element.classList.add('heap-snapshot-view');this._profile=profile;profile.profileType().addEventListener(Profiler.HeapSnapshotProfileType.SnapshotReceived,this._onReceiveSnapshot,this);profile.profileType().addEventListener(Profiler.ProfileType.Events.RemoveProfileHeader,this._onProfileHeaderRemoved,this);const isHeapTimeline=profile.profileType().id===Profiler.TrackingHeapSnapshotProfileType.TypeId;if(isHeapTimeline){this._trackingOverviewGrid=new Profiler.HeapTrackingOverviewGrid(profile);this._trackingOverviewGrid.addEventListener(Profiler.HeapTrackingOverviewGrid.IdsRangeChanged,this._onIdsRangeChanged.bind(this));} this._parentDataDisplayDelegate=dataDisplayDelegate;this._searchableView=new UI.SearchableView(this);this._searchableView.show(this.element);this._splitWidget=new UI.SplitWidget(false,true,'heapSnapshotSplitViewState',200,200);this._splitWidget.show(this._searchableView.element);this._containmentDataGrid=new Profiler.HeapSnapshotContainmentDataGrid(this);this._containmentDataGrid.addEventListener(DataGrid.DataGrid.Events.SelectedNode,this._selectionChanged,this);this._containmentWidget=this._containmentDataGrid.asWidget();this._containmentWidget.setMinimumSize(50,25);this._statisticsView=new Profiler.HeapSnapshotStatisticsView();this._constructorsDataGrid=new Profiler.HeapSnapshotConstructorsDataGrid(this);this._constructorsDataGrid.addEventListener(DataGrid.DataGrid.Events.SelectedNode,this._selectionChanged,this);this._constructorsWidget=this._constructorsDataGrid.asWidget();this._constructorsWidget.setMinimumSize(50,25);this._diffDataGrid=new Profiler.HeapSnapshotDiffDataGrid(this);this._diffDataGrid.addEventListener(DataGrid.DataGrid.Events.SelectedNode,this._selectionChanged,this);this._diffWidget=this._diffDataGrid.asWidget();this._diffWidget.setMinimumSize(50,25);if(isHeapTimeline&&Common.moduleSetting('recordAllocationStacks').get()){this._allocationDataGrid=new Profiler.AllocationDataGrid(profile._heapProfilerModel,this);this._allocationDataGrid.addEventListener(DataGrid.DataGrid.Events.SelectedNode,this._onSelectAllocationNode,this);this._allocationWidget=this._allocationDataGrid.asWidget();this._allocationWidget.setMinimumSize(50,25);this._allocationStackView=new Profiler.HeapAllocationStackView(profile._heapProfilerModel);this._allocationStackView.setMinimumSize(50,25);this._tabbedPane=new UI.TabbedPane();} this._retainmentDataGrid=new Profiler.HeapSnapshotRetainmentDataGrid(this);this._retainmentWidget=this._retainmentDataGrid.asWidget();this._retainmentWidget.setMinimumSize(50,21);this._retainmentWidget.element.classList.add('retaining-paths-view');let splitWidgetResizer;if(this._allocationStackView){this._tabbedPane=new UI.TabbedPane();this._tabbedPane.appendTab('retainers',Common.UIString('Retainers'),this._retainmentWidget);this._tabbedPane.appendTab('allocation-stack',Common.UIString('Allocation stack'),this._allocationStackView);splitWidgetResizer=this._tabbedPane.headerElement();this._objectDetailsView=this._tabbedPane;}else{const retainmentViewHeader=createElementWithClass('div','heap-snapshot-view-resizer');const retainingPathsTitleDiv=retainmentViewHeader.createChild('div','title');const retainingPathsTitle=retainingPathsTitleDiv.createChild('span');retainingPathsTitle.textContent=Common.UIString('Retainers');splitWidgetResizer=retainmentViewHeader;this._objectDetailsView=new UI.VBox();this._objectDetailsView.element.appendChild(retainmentViewHeader);this._retainmentWidget.show(this._objectDetailsView.element);} this._splitWidget.hideDefaultResizer();this._splitWidget.installResizer(splitWidgetResizer);this._retainmentDataGrid.addEventListener(DataGrid.DataGrid.Events.SelectedNode,this._inspectedObjectChanged,this);this._retainmentDataGrid.reset();this._perspectives=[];this._comparisonPerspective=new Profiler.HeapSnapshotView.ComparisonPerspective();this._perspectives.push(new Profiler.HeapSnapshotView.SummaryPerspective());if(profile.profileType()!==Profiler.ProfileTypeRegistry.instance.trackingHeapSnapshotProfileType) this._perspectives.push(this._comparisonPerspective);this._perspectives.push(new Profiler.HeapSnapshotView.ContainmentPerspective());if(this._allocationWidget) this._perspectives.push(new Profiler.HeapSnapshotView.AllocationPerspective());this._perspectives.push(new Profiler.HeapSnapshotView.StatisticsPerspective());this._perspectiveSelect=new UI.ToolbarComboBox(this._onSelectedPerspectiveChanged.bind(this));this._updatePerspectiveOptions();this._baseSelect=new UI.ToolbarComboBox(this._changeBase.bind(this));this._baseSelect.setVisible(false);this._updateBaseOptions();this._filterSelect=new UI.ToolbarComboBox(this._changeFilter.bind(this));this._filterSelect.setVisible(false);this._updateFilterOptions();this._classNameFilter=new UI.ToolbarInput('Class filter');this._classNameFilter.setVisible(false);this._constructorsDataGrid.setNameFilter(this._classNameFilter);this._diffDataGrid.setNameFilter(this._classNameFilter);this._selectedSizeText=new UI.ToolbarText();this._popoverHelper=new UI.PopoverHelper(this.element,this._getPopoverRequest.bind(this));this._popoverHelper.setDisableOnClick(true);this._popoverHelper.setHasPadding(true);this.element.addEventListener('scroll',this._popoverHelper.hidePopover.bind(this._popoverHelper),true);this._currentPerspectiveIndex=0;this._currentPerspective=this._perspectives[0];this._currentPerspective.activate(this);this._dataGrid=this._currentPerspective.masterGrid(this);this._populate();this._searchThrottler=new Common.Throttler(0);for(const existingProfile of this._profiles()) existingProfile.addEventListener(Profiler.ProfileHeader.Events.ProfileTitleChanged,this._updateControls,this);} searchableView(){return this._searchableView;} showProfile(profile){return this._parentDataDisplayDelegate.showProfile(profile);} showObject(snapshotObjectId,perspectiveName){if(snapshotObjectId<=this._profile.maxJSObjectId) this.selectLiveObject(perspectiveName,snapshotObjectId);else this._parentDataDisplayDelegate.showObject(snapshotObjectId,perspectiveName);} async _populate(){const heapSnapshotProxy=await this._profile._loadPromise;this._retrieveStatistics(heapSnapshotProxy);this._dataGrid.setDataSource(heapSnapshotProxy);if(this._profile.profileType().id===Profiler.TrackingHeapSnapshotProfileType.TypeId&&this._profile.fromFile()){const samples=await heapSnapshotProxy.getSamples();this._trackingOverviewGrid._setSamples(samples);} const list=this._profiles();const profileIndex=list.indexOf(this._profile);this._baseSelect.setSelectedIndex(Math.max(0,profileIndex-1));if(this._trackingOverviewGrid) this._trackingOverviewGrid._updateGrid();} async _retrieveStatistics(heapSnapshotProxy){const statistics=await heapSnapshotProxy.getStatistics();this._statisticsView.setTotal(statistics.total);this._statisticsView.addRecord(statistics.code,Common.UIString('Code'),'#f77');this._statisticsView.addRecord(statistics.strings,Common.UIString('Strings'),'#5e5');this._statisticsView.addRecord(statistics.jsArrays,Common.UIString('JS Arrays'),'#7af');this._statisticsView.addRecord(statistics.native,Common.UIString('Typed Arrays'),'#fc5');this._statisticsView.addRecord(statistics.system,Common.UIString('System Objects'),'#98f');this._statisticsView.addRecord(statistics.total,Common.UIString('Total'));return statistics;} _onIdsRangeChanged(event){const minId=event.data.minId;const maxId=event.data.maxId;this._selectedSizeText.setText(Common.UIString('Selected size: %s',Number.bytesToString(event.data.size)));if(this._constructorsDataGrid.snapshot) this._constructorsDataGrid.setSelectionRange(minId,maxId);} syncToolbarItems(){const result=[this._perspectiveSelect,this._classNameFilter];if(this._profile.profileType()!==Profiler.ProfileTypeRegistry.instance.trackingHeapSnapshotProfileType) result.push(this._baseSelect,this._filterSelect);result.push(this._selectedSizeText);return result;} willHide(){this._currentSearchResultIndex=-1;this._popoverHelper.hidePopover();} supportsCaseSensitiveSearch(){return true;} supportsRegexSearch(){return false;} searchCanceled(){this._currentSearchResultIndex=-1;this._searchResults=[];} _selectRevealedNode(node){if(node) node.select();} performSearch(searchConfig,shouldJump,jumpBackwards){const nextQuery=new HeapSnapshotModel.SearchConfig(searchConfig.query.trim(),searchConfig.caseSensitive,searchConfig.isRegex,shouldJump,jumpBackwards||false);this._searchThrottler.schedule(this._performSearch.bind(this,nextQuery));} async _performSearch(nextQuery){this.searchCanceled();if(!this._currentPerspective.supportsSearch()) return;this.currentQuery=nextQuery;const query=nextQuery.query.trim();if(!query) return;if(query.charAt(0)==='@'){const snapshotNodeId=parseInt(query.substring(1),10);if(isNaN(snapshotNodeId)) return;const node=await this._dataGrid.revealObjectByHeapSnapshotId(String(snapshotNodeId));this._selectRevealedNode(node);return;} this._searchResults=await this._profile._snapshotProxy.search(this.currentQuery,this._dataGrid.nodeFilter());this._searchableView.updateSearchMatchesCount(this._searchResults.length);if(this._searchResults.length) this._currentSearchResultIndex=nextQuery.jumpBackwards?this._searchResults.length-1:0;return this._jumpToSearchResult(this._currentSearchResultIndex);} jumpToNextSearchResult(){if(!this._searchResults.length) return;this._currentSearchResultIndex=(this._currentSearchResultIndex+1)%this._searchResults.length;this._searchThrottler.schedule(this._jumpToSearchResult.bind(this,this._currentSearchResultIndex));} jumpToPreviousSearchResult(){if(!this._searchResults.length) return;this._currentSearchResultIndex=(this._currentSearchResultIndex+this._searchResults.length-1)%this._searchResults.length;this._searchThrottler.schedule(this._jumpToSearchResult.bind(this,this._currentSearchResultIndex));} async _jumpToSearchResult(searchResultIndex){this._searchableView.updateCurrentMatchIndex(searchResultIndex);const node=await this._dataGrid.revealObjectByHeapSnapshotId(String(this._searchResults[searchResultIndex]));this._selectRevealedNode(node);} refreshVisibleData(){if(!this._dataGrid) return;let child=this._dataGrid.rootNode().children[0];while(child){child.refresh();child=child.traverseNextNode(false,null,true);}} _changeBase(){if(this._baseProfile===this._profiles()[this._baseSelect.selectedIndex()]) return;this._baseProfile=this._profiles()[this._baseSelect.selectedIndex()];const dataGrid=(this._dataGrid);if(dataGrid.snapshot) this._baseProfile._loadPromise.then(dataGrid.setBaseDataSource.bind(dataGrid));if(!this.currentQuery||!this._searchResults) return;this.performSearch(this.currentQuery,false);} _changeFilter(){const profileIndex=this._filterSelect.selectedIndex()-1;this._dataGrid.filterSelectIndexChanged(this._profiles(),profileIndex);if(!this.currentQuery||!this._searchResults) return;this.performSearch(this.currentQuery,false);} _profiles(){return this._profile.profileType().getProfiles();} populateContextMenu(contextMenu,event){if(this._dataGrid) this._dataGrid.populateContextMenu(contextMenu,event);} _selectionChanged(event){const selectedNode=(event.data);this._setSelectedNodeForDetailsView(selectedNode);this._inspectedObjectChanged(event);} _onSelectAllocationNode(event){const selectedNode=(event.data);this._constructorsDataGrid.setAllocationNodeId(selectedNode.allocationNodeId());this._setSelectedNodeForDetailsView(null);} _inspectedObjectChanged(event){const selectedNode=(event.data);if(this._profile._heapProfilerModel&&selectedNode instanceof Profiler.HeapSnapshotGenericObjectNode) this._profile._heapProfilerModel.addInspectedHeapObject(String(selectedNode.snapshotNodeId));} _setSelectedNodeForDetailsView(nodeItem){const dataSource=nodeItem&&nodeItem.retainersDataSource();if(dataSource){this._retainmentDataGrid.setDataSource(dataSource.snapshot,dataSource.snapshotNodeIndex);if(this._allocationStackView) this._allocationStackView.setAllocatedObject(dataSource.snapshot,dataSource.snapshotNodeIndex);}else{if(this._allocationStackView) this._allocationStackView.clear();this._retainmentDataGrid.reset();}} _changePerspectiveAndWait(perspectiveTitle){const perspectiveIndex=this._perspectives.findIndex(perspective=>perspective.title()===perspectiveTitle);if(perspectiveIndex===-1||this._currentPerspectiveIndex===perspectiveIndex) return Promise.resolve();const promise=this._perspectives[perspectiveIndex].masterGrid(this).once(Profiler.HeapSnapshotSortableDataGrid.Events.ContentShown);const option=this._perspectiveSelect.options().find(option=>option.value===perspectiveIndex);this._perspectiveSelect.select((option));this._changePerspective(perspectiveIndex);return promise;} async _updateDataSourceAndView(){const dataGrid=this._dataGrid;if(!dataGrid||dataGrid.snapshot) return;const snapshotProxy=await this._profile._loadPromise;if(this._dataGrid!==dataGrid) return;if(dataGrid.snapshot!==snapshotProxy) dataGrid.setDataSource(snapshotProxy);if(dataGrid!==this._diffDataGrid) return;if(!this._baseProfile) this._baseProfile=this._profiles()[this._baseSelect.selectedIndex()];const baseSnapshotProxy=await this._baseProfile._loadPromise;if(this._diffDataGrid.baseSnapshot!==baseSnapshotProxy) this._diffDataGrid.setBaseDataSource(baseSnapshotProxy);} _onSelectedPerspectiveChanged(event){this._changePerspective(event.target.selectedOptions[0].value);} _changePerspective(selectedIndex){if(selectedIndex===this._currentPerspectiveIndex) return;this._currentPerspectiveIndex=selectedIndex;this._currentPerspective.deactivate(this);const perspective=this._perspectives[selectedIndex];this._currentPerspective=perspective;this._dataGrid=perspective.masterGrid(this);perspective.activate(this);this.refreshVisibleData();if(this._dataGrid) this._dataGrid.updateWidths();this._updateDataSourceAndView();if(!this.currentQuery||!this._searchResults) return;this.performSearch(this.currentQuery,false);} async selectLiveObject(perspectiveName,snapshotObjectId){await this._changePerspectiveAndWait(perspectiveName);const node=await this._dataGrid.revealObjectByHeapSnapshotId(snapshotObjectId);if(node) node.select();else Common.console.error('Cannot find corresponding heap snapshot node');} _getPopoverRequest(event){const span=event.target.enclosingNodeOrSelfWithNodeName('span');const row=event.target.enclosingNodeOrSelfWithNodeName('tr');const heapProfilerModel=this._profile._heapProfilerModel;if(!row||!span||!heapProfilerModel) return null;const node=row._dataGridNode;let objectPopoverHelper;return{box:span.boxInWindow(),show:async popover=>{const remoteObject=await node.queryObjectContent(heapProfilerModel,'popover');if(!remoteObject) return false;objectPopoverHelper=await ObjectUI.ObjectPopoverHelper.buildObjectPopover(remoteObject,popover);if(!objectPopoverHelper){heapProfilerModel.runtimeModel().releaseObjectGroup('popover');return false;} return true;},hide:()=>{heapProfilerModel.runtimeModel().releaseObjectGroup('popover');objectPopoverHelper.dispose();}};} _updatePerspectiveOptions(){const multipleSnapshots=this._profiles().length>1;this._perspectiveSelect.removeOptions();this._perspectives.forEach((perspective,index)=>{if(multipleSnapshots||perspective!==this._comparisonPerspective) this._perspectiveSelect.createOption(perspective.title(),'',String(index));});} _updateBaseOptions(){const list=this._profiles();const selectedIndex=this._baseSelect.selectedIndex();this._baseSelect.removeOptions();for(const item of list) this._baseSelect.createOption(item.title);if(selectedIndex>-1) this._baseSelect.setSelectedIndex(selectedIndex);} _updateFilterOptions(){const list=this._profiles();const selectedIndex=this._filterSelect.selectedIndex();this._filterSelect.removeOptions();this._filterSelect.createOption(Common.UIString('All objects'));for(let i=0;i-1) this._filterSelect.setSelectedIndex(selectedIndex);} _updateControls(){this._updatePerspectiveOptions();this._updateBaseOptions();this._updateFilterOptions();} _onReceiveSnapshot(event){this._updateControls();const profile=event.data;profile.addEventListener(Profiler.ProfileHeader.Events.ProfileTitleChanged,this._updateControls,this);} _onProfileHeaderRemoved(event){const profile=event.data;profile.removeEventListener(Profiler.ProfileHeader.Events.ProfileTitleChanged,this._updateControls,this);if(this._profile===profile){this.detach();this._profile.profileType().removeEventListener(Profiler.HeapSnapshotProfileType.SnapshotReceived,this._onReceiveSnapshot,this);this._profile.profileType().removeEventListener(Profiler.ProfileType.Events.RemoveProfileHeader,this._onProfileHeaderRemoved,this);this.dispose();}else{this._updateControls();}} dispose(){if(this._allocationStackView){this._allocationStackView.clear();this._allocationDataGrid.dispose();} if(this._trackingOverviewGrid) this._trackingOverviewGrid.dispose();}};Profiler.HeapSnapshotView.Perspective=class{constructor(title){this._title=title;} activate(heapSnapshotView){} deactivate(heapSnapshotView){heapSnapshotView._baseSelect.setVisible(false);heapSnapshotView._filterSelect.setVisible(false);heapSnapshotView._classNameFilter.setVisible(false);if(heapSnapshotView._trackingOverviewGrid) heapSnapshotView._trackingOverviewGrid.detach();if(heapSnapshotView._allocationWidget) heapSnapshotView._allocationWidget.detach();if(heapSnapshotView._statisticsView) heapSnapshotView._statisticsView.detach();heapSnapshotView._splitWidget.detach();heapSnapshotView._splitWidget.detachChildWidgets();} masterGrid(heapSnapshotView){return null;} title(){return this._title;} supportsSearch(){return false;}};Profiler.HeapSnapshotView.SummaryPerspective=class extends Profiler.HeapSnapshotView.Perspective{constructor(){super(Common.UIString('Summary'));} activate(heapSnapshotView){heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._constructorsWidget);heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetailsView);heapSnapshotView._splitWidget.show(heapSnapshotView._searchableView.element);heapSnapshotView._filterSelect.setVisible(true);heapSnapshotView._classNameFilter.setVisible(true);if(!heapSnapshotView._trackingOverviewGrid) return;heapSnapshotView._trackingOverviewGrid.show(heapSnapshotView._searchableView.element,heapSnapshotView._splitWidget.element);heapSnapshotView._trackingOverviewGrid.update();heapSnapshotView._trackingOverviewGrid._updateGrid();} masterGrid(heapSnapshotView){return heapSnapshotView._constructorsDataGrid;} supportsSearch(){return true;}};Profiler.HeapSnapshotView.ComparisonPerspective=class extends Profiler.HeapSnapshotView.Perspective{constructor(){super(Common.UIString('Comparison'));} activate(heapSnapshotView){heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._diffWidget);heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetailsView);heapSnapshotView._splitWidget.show(heapSnapshotView._searchableView.element);heapSnapshotView._baseSelect.setVisible(true);heapSnapshotView._classNameFilter.setVisible(true);} masterGrid(heapSnapshotView){return heapSnapshotView._diffDataGrid;} supportsSearch(){return true;}};Profiler.HeapSnapshotView.ContainmentPerspective=class extends Profiler.HeapSnapshotView.Perspective{constructor(){super(Common.UIString('Containment'));} activate(heapSnapshotView){heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._containmentWidget);heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetailsView);heapSnapshotView._splitWidget.show(heapSnapshotView._searchableView.element);} masterGrid(heapSnapshotView){return heapSnapshotView._containmentDataGrid;}};Profiler.HeapSnapshotView.AllocationPerspective=class extends Profiler.HeapSnapshotView.Perspective{constructor(){super(Common.UIString('Allocation'));this._allocationSplitWidget=new UI.SplitWidget(false,true,'heapSnapshotAllocationSplitViewState',200,200);this._allocationSplitWidget.setSidebarWidget(new UI.VBox());} activate(heapSnapshotView){this._allocationSplitWidget.setMainWidget(heapSnapshotView._allocationWidget);heapSnapshotView._splitWidget.setMainWidget(heapSnapshotView._constructorsWidget);heapSnapshotView._splitWidget.setSidebarWidget(heapSnapshotView._objectDetailsView);const allocatedObjectsView=new UI.VBox();const resizer=createElementWithClass('div','heap-snapshot-view-resizer');const title=resizer.createChild('div','title').createChild('span');title.textContent=Common.UIString('Live objects');this._allocationSplitWidget.hideDefaultResizer();this._allocationSplitWidget.installResizer(resizer);allocatedObjectsView.element.appendChild(resizer);heapSnapshotView._splitWidget.show(allocatedObjectsView.element);this._allocationSplitWidget.setSidebarWidget(allocatedObjectsView);this._allocationSplitWidget.show(heapSnapshotView._searchableView.element);heapSnapshotView._constructorsDataGrid.clear();const selectedNode=heapSnapshotView._allocationDataGrid.selectedNode;if(selectedNode) heapSnapshotView._constructorsDataGrid.setAllocationNodeId(selectedNode.allocationNodeId());} deactivate(heapSnapshotView){this._allocationSplitWidget.detach();super.deactivate(heapSnapshotView);} masterGrid(heapSnapshotView){return heapSnapshotView._allocationDataGrid;}};Profiler.HeapSnapshotView.StatisticsPerspective=class extends Profiler.HeapSnapshotView.Perspective{constructor(){super(Common.UIString('Statistics'));} activate(heapSnapshotView){heapSnapshotView._statisticsView.show(heapSnapshotView._searchableView.element);} masterGrid(heapSnapshotView){return null;}};Profiler.HeapSnapshotProfileType=class extends Profiler.ProfileType{constructor(id,title){super(id||Profiler.HeapSnapshotProfileType.TypeId,title||ls`Heap snapshot`);SDK.targetManager.observeModels(SDK.HeapProfilerModel,this);SDK.targetManager.addModelListener(SDK.HeapProfilerModel,SDK.HeapProfilerModel.Events.ResetProfiles,this._resetProfiles,this);SDK.targetManager.addModelListener(SDK.HeapProfilerModel,SDK.HeapProfilerModel.Events.AddHeapSnapshotChunk,this._addHeapSnapshotChunk,this);SDK.targetManager.addModelListener(SDK.HeapProfilerModel,SDK.HeapProfilerModel.Events.ReportHeapSnapshotProgress,this._reportHeapSnapshotProgress,this);} modelAdded(heapProfilerModel){heapProfilerModel.enable();} modelRemoved(heapProfilerModel){} getProfiles(){return(super.getProfiles());} fileExtension(){return'.heapsnapshot';} get buttonTooltip(){return Common.UIString('Take heap snapshot');} isInstantProfile(){return true;} buttonClicked(){this._takeHeapSnapshot();Host.userMetrics.actionTaken(Host.UserMetrics.Action.ProfilesHeapProfileTaken);return false;} get treeItemTitle(){return Common.UIString('HEAP SNAPSHOTS');} get description(){return Common.UIString('Heap snapshot profiles show memory distribution among your page\'s JavaScript objects and related DOM nodes.');} createProfileLoadedFromFile(title){return new Profiler.HeapProfileHeader(null,this,title);} async _takeHeapSnapshot(){if(this.profileBeingRecorded()) return;const heapProfilerModel=UI.context.flavor(SDK.HeapProfilerModel);if(!heapProfilerModel) return;let profile=new Profiler.HeapProfileHeader(heapProfilerModel,this);this.setProfileBeingRecorded(profile);this.addProfile(profile);profile.updateStatus(Common.UIString('Snapshotting\u2026'));await heapProfilerModel.takeHeapSnapshot(true);profile=this.profileBeingRecorded();profile.title=Common.UIString('Snapshot %d',profile.uid);profile._finishLoad();this.setProfileBeingRecorded(null);this.dispatchEventToListeners(Profiler.ProfileType.Events.ProfileComplete,profile);} _addHeapSnapshotChunk(event){if(!this.profileBeingRecorded()) return;const chunk=(event.data);this.profileBeingRecorded().transferChunk(chunk);} _reportHeapSnapshotProgress(event){const profile=this.profileBeingRecorded();if(!profile) return;const data=(event.data);profile.updateStatus(Common.UIString('%.0f%%',(data.done/data.total)*100),true);if(data.finished) profile._prepareToLoad();} _resetProfiles(event){const heapProfilerModel=(event.data);for(const profile of this.getProfiles()){if(profile._heapProfilerModel===heapProfilerModel) this.removeProfile(profile);}} _snapshotReceived(profile){if(this.profileBeingRecorded()===profile) this.setProfileBeingRecorded(null);this.dispatchEventToListeners(Profiler.HeapSnapshotProfileType.SnapshotReceived,profile);}};Profiler.HeapSnapshotProfileType.TypeId='HEAP';Profiler.HeapSnapshotProfileType.SnapshotReceived='SnapshotReceived';Profiler.TrackingHeapSnapshotProfileType=class extends Profiler.HeapSnapshotProfileType{constructor(){super(Profiler.TrackingHeapSnapshotProfileType.TypeId,ls`Allocation instrumentation on timeline`);} modelAdded(heapProfilerModel){super.modelAdded(heapProfilerModel);heapProfilerModel.addEventListener(SDK.HeapProfilerModel.Events.HeapStatsUpdate,this._heapStatsUpdate,this);heapProfilerModel.addEventListener(SDK.HeapProfilerModel.Events.LastSeenObjectId,this._lastSeenObjectId,this);} modelRemoved(heapProfilerModel){super.modelRemoved(heapProfilerModel);heapProfilerModel.removeEventListener(SDK.HeapProfilerModel.Events.HeapStatsUpdate,this._heapStatsUpdate,this);heapProfilerModel.removeEventListener(SDK.HeapProfilerModel.Events.LastSeenObjectId,this._lastSeenObjectId,this);} _heapStatsUpdate(event){if(!this._profileSamples) return;const samples=(event.data);let index;for(let i=0;ithis._fulfillLoad=resolve);this._totalNumberOfChunks=0;this._bufferedWriter=null;this._tempFile=null;} heapProfilerModel(){return this._heapProfilerModel;} createSidebarTreeElement(dataDisplayDelegate){return new Profiler.ProfileSidebarTreeElement(dataDisplayDelegate,this,'heap-snapshot-sidebar-tree-item');} createView(dataDisplayDelegate){return new Profiler.HeapSnapshotView(dataDisplayDelegate,this);} _prepareToLoad(){console.assert(!this._receiver,'Already loading');this._setupWorker();this.updateStatus(Common.UIString('Loading\u2026'),true);} _finishLoad(){if(!this._wasDisposed) this._receiver.close();if(!this._bufferedWriter) return;this._didWriteToTempFile(this._bufferedWriter);} _didWriteToTempFile(tempFile){if(this._wasDisposed){if(tempFile) tempFile.remove();return;} this._tempFile=tempFile;if(!tempFile) this._failedToCreateTempFile=true;if(this._onTempFileReady){this._onTempFileReady();this._onTempFileReady=null;}} _setupWorker(){function setProfileWait(event){this.updateStatus(null,event.data);} console.assert(!this._workerProxy,'HeapSnapshotWorkerProxy already exists');this._workerProxy=new Profiler.HeapSnapshotWorkerProxy(this._handleWorkerEvent.bind(this));this._workerProxy.addEventListener(Profiler.HeapSnapshotWorkerProxy.Events.Wait,setProfileWait,this);this._receiver=this._workerProxy.createLoader(this.uid,this._snapshotReceived.bind(this));} _handleWorkerEvent(eventName,data){if(HeapSnapshotModel.HeapSnapshotProgressEvent.BrokenSnapshot===eventName){const error=(data);Common.console.error(error);return;} if(HeapSnapshotModel.HeapSnapshotProgressEvent.Update!==eventName) return;const subtitle=(data);this.updateStatus(subtitle);} dispose(){if(this._workerProxy) this._workerProxy.dispose();this.removeTempFile();this._wasDisposed=true;} _didCompleteSnapshotTransfer(){if(!this._snapshotProxy) return;this.updateStatus(Number.bytesToString(this._snapshotProxy.totalSize),false);} transferChunk(chunk){if(!this._bufferedWriter) this._bufferedWriter=new Bindings.TempFile();this._bufferedWriter.write([chunk]);++this._totalNumberOfChunks;this._receiver.write(chunk);} _snapshotReceived(snapshotProxy){if(this._wasDisposed) return;this._receiver=null;this._snapshotProxy=snapshotProxy;this.maxJSObjectId=snapshotProxy.maxJSObjectId();this._didCompleteSnapshotTransfer();this._workerProxy.startCheckingForLongRunningCalls();this.notifySnapshotReceived();} notifySnapshotReceived(){this._fulfillLoad(this._snapshotProxy);this.profileType()._snapshotReceived(this);if(this.canSaveToFile()) this.dispatchEventToListeners(Profiler.ProfileHeader.Events.ProfileReceived);} canSaveToFile(){return!this.fromFile()&&!!this._snapshotProxy;} saveToFile(){const fileOutputStream=new Bindings.FileOutputStream();this._fileName=this._fileName||'Heap-'+new Date().toISO8601Compact()+this.profileType().fileExtension();fileOutputStream.open(this._fileName).then(onOpen.bind(this));async function onOpen(accepted){if(!accepted) return;if(this._failedToCreateTempFile){Common.console.error('Failed to open temp file with heap snapshot');fileOutputStream.close();return;} if(this._tempFile){const error=await this._tempFile.copyToOutputStream(fileOutputStream,this._onChunkTransferred.bind(this));if(error) Common.console.error('Failed to read heap snapshot from temp file: '+error.message);this._didCompleteSnapshotTransfer();return;} this._onTempFileReady=onOpen.bind(this,accepted);this._updateSaveProgress(0,1);}} _onChunkTransferred(reader){this._updateSaveProgress(reader.loadedSize(),reader.fileSize());} _updateSaveProgress(value,total){const percentValue=((total&&value/total)*100).toFixed(0);this.updateStatus(Common.UIString('Saving\u2026 %d%%',percentValue));} async loadFromFile(file){this.updateStatus(Common.UIString('Loading\u2026'),true);this._setupWorker();const reader=new Bindings.ChunkedFileReader(file,10000000);const success=await reader.read((this._receiver));if(!success) this.updateStatus(reader.error().message);return success?null:reader.error();}};Profiler.HeapTrackingOverviewGrid=class extends UI.VBox{constructor(heapProfileHeader){super();this.element.id='heap-recording-view';this.element.classList.add('heap-tracking-overview');this._overviewContainer=this.element.createChild('div','heap-overview-container');this._overviewGrid=new PerfUI.OverviewGrid('heap-recording');this._overviewGrid.element.classList.add('fill');this._overviewCanvas=this._overviewContainer.createChild('canvas','heap-recording-overview-canvas');this._overviewContainer.appendChild(this._overviewGrid.element);this._overviewCalculator=new Profiler.HeapTrackingOverviewGrid.OverviewCalculator();this._overviewGrid.addEventListener(PerfUI.OverviewGrid.Events.WindowChanged,this._onWindowChanged,this);this._profileSamples=heapProfileHeader.fromFile()?new Profiler.TrackingHeapSnapshotProfileType.Samples():heapProfileHeader._profileSamples;this._profileType=heapProfileHeader.profileType();if(!heapProfileHeader.fromFile()&&heapProfileHeader.profileType().profileBeingRecorded()===heapProfileHeader){this._profileType.addEventListener(Profiler.TrackingHeapSnapshotProfileType.HeapStatsUpdate,this._onHeapStatsUpdate,this);this._profileType.addEventListener(Profiler.TrackingHeapSnapshotProfileType.TrackingStopped,this._onStopTracking,this);} this._windowLeft=0.0;this._windowRight=1.0;this._overviewGrid.setWindow(this._windowLeft,this._windowRight);this._yScale=new Profiler.HeapTrackingOverviewGrid.SmoothScale();this._xScale=new Profiler.HeapTrackingOverviewGrid.SmoothScale();} dispose(){this._onStopTracking();} _onStopTracking(){this._profileType.removeEventListener(Profiler.TrackingHeapSnapshotProfileType.HeapStatsUpdate,this._onHeapStatsUpdate,this);this._profileType.removeEventListener(Profiler.TrackingHeapSnapshotProfileType.TrackingStopped,this._onStopTracking,this);} _onHeapStatsUpdate(event){this._profileSamples=event.data;this._scheduleUpdate();} _setSamples(samples){if(!samples) return;console.assert(!this._profileSamples.timestamps.length,'Should only call this method when loading from file.');console.assert(samples.timestamps.length);this._profileSamples=new Profiler.TrackingHeapSnapshotProfileType.Samples();this._profileSamples.sizes=samples.sizes;this._profileSamples.ids=samples.lastAssignedIds;this._profileSamples.timestamps=samples.timestamps;this._profileSamples.max=samples.sizes;this._profileSamples.totalTime=(samples.timestamps.peekLast());this.update();} _drawOverviewCanvas(width,height){if(!this._profileSamples) return;const profileSamples=this._profileSamples;const sizes=profileSamples.sizes;const topSizes=profileSamples.max;const timestamps=profileSamples.timestamps;const startTime=timestamps[0];const endTime=timestamps[timestamps.length-1];const scaleFactor=this._xScale.nextScale(width/profileSamples.totalTime);let maxSize=0;function aggregateAndCall(sizes,callback){let size=0;let currentX=0;for(let i=1;itimeRight) break;maxId=ids[i];if(timestamps[i]{if(this.isShowing()&&result) this.showObject(result,viewName);});} contextMenu.revealSection().appendItem(Common.UIString('Reveal in Summary view'),revealInView.bind(this,'Summary'));} handleAction(context,actionId){const panel=UI.context.flavor(Profiler.HeapProfilerPanel);console.assert(panel&&panel instanceof Profiler.HeapProfilerPanel);panel.toggleRecord();return true;} wasShown(){UI.context.setFlavor(Profiler.HeapProfilerPanel,this);} willHide(){UI.context.setFlavor(Profiler.HeapProfilerPanel,null);} showObject(snapshotObjectId,perspectiveName){const registry=Profiler.ProfileTypeRegistry.instance;const heapProfiles=registry.heapSnapshotProfileType.getProfiles();for(let i=0;i=snapshotObjectId){this.showProfile(profile);const view=this.viewForProfile(profile);view.selectLiveObject(perspectiveName,snapshotObjectId);break;}}}};;Profiler.ProfileLauncherView=class extends UI.VBox{constructor(profilesPanel){super();this._panel=profilesPanel;this.element.classList.add('profile-launcher-view','panel-enabler-view');this._contentElement=this.element.createChild('div','profile-launcher-view-content');this._innerContentElement=this._contentElement.createChild('div');const controlDiv=this._contentElement.createChild('div','hbox profile-launcher-control');const targetDiv=controlDiv.createChild('div','hbox profile-launcher-target');targetDiv.createChild('div').textContent=Common.UIString('Target:');const targetsSelect=targetDiv.createChild('select','chrome-select');new Profiler.TargetsComboBoxController(targetsSelect,targetDiv);this._controlButton=UI.createTextButton('',this._controlButtonClicked.bind(this),'profile-launcher-button',true);this._contentElement.appendChild(this._controlButton);this._recordButtonEnabled=true;this._loadButton=UI.createTextButton(Common.UIString('Load'),this._loadButtonClicked.bind(this),'profile-launcher-button');this._contentElement.appendChild(this._loadButton);this._selectedProfileTypeSetting=Common.settings.createSetting('selectedProfileType','CPU');this._header=this._innerContentElement.createChild('h1');this._profileTypeSelectorForm=this._innerContentElement.createChild('form');this._innerContentElement.createChild('div','flexible-space');this._typeIdToOptionElement=new Map();} _loadButtonClicked(){this._panel.showLoadFromFileDialog();} _updateControls(){if(this._isEnabled&&this._recordButtonEnabled) this._controlButton.removeAttribute('disabled');else this._controlButton.setAttribute('disabled','');this._controlButton.title=this._recordButtonEnabled?'':UI.anotherProfilerActiveLabel();if(this._isInstantProfile){this._controlButton.classList.remove('running');this._controlButton.classList.add('primary-button');this._controlButton.textContent=Common.UIString('Take snapshot');}else if(this._isProfiling){this._controlButton.classList.add('running');this._controlButton.classList.remove('primary-button');this._controlButton.textContent=Common.UIString('Stop');}else{this._controlButton.classList.remove('running');this._controlButton.classList.add('primary-button');this._controlButton.textContent=Common.UIString('Start');} for(const item of this._typeIdToOptionElement.values()) item.disabled=!!this._isProfiling;} profileStarted(){this._isProfiling=true;this._updateControls();} profileFinished(){this._isProfiling=false;this._updateControls();} updateProfileType(profileType,recordButtonEnabled){this._isInstantProfile=profileType.isInstantProfile();this._recordButtonEnabled=recordButtonEnabled;this._isEnabled=profileType.isEnabled();this._updateControls();} addProfileType(profileType){const labelElement=UI.createRadioLabel('profile-type',profileType.name);this._profileTypeSelectorForm.appendChild(labelElement);const optionElement=labelElement.radioElement;this._typeIdToOptionElement.set(profileType.id,optionElement);optionElement._profileType=profileType;optionElement.style.hidden=true;optionElement.addEventListener('change',this._profileTypeChanged.bind(this,profileType),false);const descriptionElement=this._profileTypeSelectorForm.createChild('p');descriptionElement.textContent=profileType.description;const decorationElement=profileType.decorationElement();if(decorationElement) labelElement.appendChild(decorationElement);if(this._typeIdToOptionElement.size>1) this._header.textContent=Common.UIString('Select profiling type');else this._header.textContent=profileType.name;} restoreSelectedProfileType(){let typeId=this._selectedProfileTypeSetting.get();if(!this._typeIdToOptionElement.has(typeId)) typeId=this._typeIdToOptionElement.keys().next().value;this._typeIdToOptionElement.get(typeId).checked=true;const type=this._typeIdToOptionElement.get(typeId)._profileType;this.dispatchEventToListeners(Profiler.ProfileLauncherView.Events.ProfileTypeSelected,type);} _controlButtonClicked(){this._panel.toggleRecord();} _profileTypeChanged(profileType){this.dispatchEventToListeners(Profiler.ProfileLauncherView.Events.ProfileTypeSelected,profileType);this._isInstantProfile=profileType.isInstantProfile();this._isEnabled=profileType.isEnabled();this._updateControls();this._selectedProfileTypeSetting.set(profileType.id);}};Profiler.ProfileLauncherView.Events={ProfileTypeSelected:Symbol('ProfileTypeSelected')};;Profiler.ProfileTypeRegistry=class{constructor(){this.cpuProfileType=new Profiler.CPUProfileType();this.heapSnapshotProfileType=new Profiler.HeapSnapshotProfileType();this.samplingHeapProfileType=new Profiler.SamplingHeapProfileType();this.samplingNativeHeapProfileType=new Profiler.SamplingNativeHeapProfileType();this.samplingNativeHeapSnapshotType=new Profiler.SamplingNativeHeapSnapshotType();this.trackingHeapSnapshotProfileType=new Profiler.TrackingHeapSnapshotProfileType();}};Profiler.ProfileTypeRegistry.instance=new Profiler.ProfileTypeRegistry();;Profiler.TargetsComboBoxController=class{constructor(selectElement,elementToHide){elementToHide.classList.add('hidden');selectElement.addEventListener('change',this._onComboBoxSelectionChange.bind(this),false);this._selectElement=selectElement;this._elementToHide=elementToHide;this._targetToOption=new Map();UI.context.addFlavorChangeListener(SDK.Target,this._targetChangedExternally,this);SDK.targetManager.addEventListener(SDK.TargetManager.Events.NameChanged,this._targetNameChanged,this);SDK.targetManager.observeTargets(this,SDK.Target.Capability.JS);} targetAdded(target){const option=this._selectElement.createChild('option');option.text=target.name();option.__target=target;this._targetToOption.set(target,option);if(UI.context.flavor(SDK.Target)===target){this._selectElement.selectedIndex=Array.prototype.indexOf.call((this._selectElement),option);UI.context.setFlavor(SDK.HeapProfilerModel,target.model(SDK.HeapProfilerModel));UI.context.setFlavor(SDK.CPUProfilerModel,target.model(SDK.CPUProfilerModel));} this._updateVisibility();} targetRemoved(target){const option=this._targetToOption.remove(target);this._selectElement.removeChild(option);this._updateVisibility();} _targetNameChanged(event){const target=(event.data);const option=this._targetToOption.get(target);option.text=target.name();} _onComboBoxSelectionChange(){const selectedOption=this._selectElement[this._selectElement.selectedIndex];if(!selectedOption) return;UI.context.setFlavor(SDK.Target,selectedOption.__target);UI.context.setFlavor(SDK.HeapProfilerModel,selectedOption.__target.model(SDK.HeapProfilerModel));UI.context.setFlavor(SDK.CPUProfilerModel,selectedOption.__target.model(SDK.CPUProfilerModel));} _updateVisibility(){const hidden=this._selectElement.childElementCount===1;this._elementToHide.classList.toggle('hidden',hidden);} _targetChangedExternally(event){const target=(event.data);if(!target) return;const option=this._targetToOption.get(target);if(!option) return;this._select(option);UI.context.setFlavor(SDK.HeapProfilerModel,target.model(SDK.HeapProfilerModel));UI.context.setFlavor(SDK.CPUProfilerModel,target.model(SDK.CPUProfilerModel));} _select(option){this._selectElement.selectedIndex=Array.prototype.indexOf.call((this._selectElement),option);}};;Runtime.cachedResources["profiler/heapProfiler.css"]="/*\n * Copyright (C) 2009 Google Inc. All rights reserved.\n * Copyright (C) 2010 Apple Inc. All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are\n * met:\n *\n * * Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * * Redistributions in binary form must reproduce the above\n * copyright notice, this list of conditions and the following disclaimer\n * in the documentation and/or other materials provided with the\n * distribution.\n * * Neither the name of Google Inc. nor the names of its\n * contributors may be used to endorse or promote products derived from\n * this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n * \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n.heap-snapshot-view {\n overflow: hidden;\n}\n\n.heap-snapshot-view .data-grid {\n border: none;\n}\n\n.heap-snapshot-view .data-grid tr:empty {\n height: 16px;\n visibility: hidden;\n}\n\n.heap-snapshot-view .data-grid span.percent-column {\n width: 35px !important;\n}\n\n.heap-snapshot-view .object-value-object,\n.object-value-node {\n display: inline;\n position: static;\n}\n\n.detached-dom-tree-node {\n background-color: #FF9999;\n}\n\n.heap-snapshot-view .object-value-string {\n white-space: nowrap;\n}\n\n.heap-snapshot-view tr:not(.selected) .object-value-id {\n color: grey;\n}\n\n.heap-snapshot-view .data-grid {\n flex: auto;\n}\n\n.heap-snapshot-view .heap-tracking-overview {\n flex: 0 0 80px;\n height: 80px;\n}\n\n.heap-snapshot-view .retaining-paths-view {\n overflow: hidden;\n}\n\n.heap-snapshot-view .heap-snapshot-view-resizer {\n background-image: url(Images/toolbarResizerVertical.png);\n background-color: #eee;\n border-bottom: 1px solid rgb(179, 179, 179);\n background-repeat: no-repeat;\n background-position: right center, center;\n flex: 0 0 21px;\n}\n\n.heap-snapshot-view .heap-snapshot-view-resizer .title > span {\n display: inline-block;\n padding-top: 3px;\n vertical-align: middle;\n margin-left: 4px;\n margin-right: 8px;\n}\n\n.heap-snapshot-view .heap-snapshot-view-resizer * {\n pointer-events: none;\n}\n\n.heap-snapshot-view tr:not(.selected) td.object-column span.highlight {\n background-color: rgb(255, 255, 200);\n}\n\n.heap-snapshot-view td.object-column span.grayed {\n color: gray;\n}\n\n.cycled-ancessor-node {\n opacity: 0.6;\n}\n\n#heap-recording-view .heap-snapshot-view {\n top: 80px;\n}\n\n.heap-overview-container {\n overflow: hidden;\n position: absolute;\n top: 0;\n width: 100%;\n height: 80px;\n}\n\n#heap-recording-overview-grid .resources-dividers-label-bar {\n pointer-events: auto;\n}\n\n#heap-recording-overview-container {\n border-bottom: 1px solid rgba(0, 0, 0, 0.3);\n}\n\n.heap-recording-overview-canvas {\n position: absolute;\n top: 20px;\n left: 0;\n right: 0;\n bottom: 0;\n}\n\n.heap-snapshot-statistics-view {\n overflow: auto;\n}\n\n.heap-snapshot-stats-pie-chart {\n margin: 12px 30px;\n flex-shrink: 0;\n}\n\n.heap-snapshot-stats-legend {\n margin-left: 24px;\n flex-shrink: 0;\n}\n\n.heap-snapshot-stats-legend > div {\n margin-top: 1px;\n width: 170px;\n}\n\n.heap-snapshot-stats-swatch {\n display: inline-block;\n width: 10px;\n height: 10px;\n border: 1px solid rgba(100, 100, 100, 0.3);\n}\n\n.heap-snapshot-stats-swatch.heap-snapshot-stats-empty-swatch {\n border: none;\n}\n\n.heap-snapshot-stats-name,\n.heap-snapshot-stats-size {\n display: inline-block;\n margin-left: 6px;\n}\n\n.heap-snapshot-stats-size {\n float: right;\n text-align: right;\n}\n\n.heap-allocation-stack .stack-frame {\n display: flex;\n justify-content: space-between;\n border-bottom: 1px solid rgb(240, 240, 240);\n padding: 2px;\n}\n\n.heap-allocation-stack .stack-frame .devtools-link {\n color: rgb(33%, 33%, 33%);\n}\n\n.no-heap-allocation-stack {\n padding: 5px;\n}\n\n/*# sourceURL=profiler/heapProfiler.css */";Runtime.cachedResources["profiler/profilesPanel.css"]="/*\n * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.\n * Copyright (C) 2009 Anthony Ricaud \n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions\n * are met:\n *\n * 1. Redistributions of source code must retain the above copyright\n * notice, this list of conditions and the following disclaimer.\n * 2. Redistributions in binary form must reproduce the above copyright\n * notice, this list of conditions and the following disclaimer in the\n * documentation and/or other materials provided with the distribution.\n * 3. Neither the name of Apple Computer, Inc. (\"Apple\") nor the names of\n * its contributors may be used to endorse or promote products derived\n * from this software without specific prior written permission.\n *\n * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS \"AS IS\" AND ANY\n * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY\n * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\n * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n/* Profiler Style */\n\n#profile-views {\n flex: auto;\n position: relative;\n}\n\n.profile-view .data-grid table.data {\n background: white;\n}\n\n.profile-view .data-grid tr:not(.selected) .highlight {\n background-color: rgb(255, 230, 179);\n}\n\n.profile-view .data-grid tr:hover td:not(.bottom-filler-td) {\n background-color: rgba(0, 0, 0, 0.1);\n}\n\n.profile-view .data-grid td.numeric-column {\n text-align: right;\n}\n\n.profile-view .data-grid div.profile-multiple-values {\n float: right;\n}\n\n.profile-view .data-grid span.percent-column {\n color: #999;\n width: 50px;\n display: inline-block;\n}\n\n.profile-view .data-grid tr.selected span {\n color: inherit;\n}\n\n.profiles-toolbar {\n background-color: #f3f3f3;\n border-bottom: 1px solid #ccc;\n flex-shrink: 0;\n}\n\n.profiles-tree-sidebar {\n flex: auto;\n overflow: hidden;\n}\n\n.profiles-sidebar-tree-box {\n overflow-y: auto;\n}\n\n.profile-view {\n display: flex;\n overflow: hidden;\n}\n\n.profile-view .data-grid {\n border: none;\n flex: auto;\n}\n\n.profile-view .data-grid th.self-column,\n.profile-view .data-grid th.total-column {\n text-align: center;\n}\n\n.profile-node-file {\n float: right;\n color: gray;\n}\n\n.profile-warn-marker {\n vertical-align: -1px;\n margin-right: 2px;\n}\n\n.data-grid tr.selected .profile-node-file {\n color: rgb(33%, 33%, 33%);\n}\n\n.data-grid:focus tr.selected .profile-node-file {\n color: white;\n}\n\n.profile-launcher-view-content {\n padding: 0 16px;\n text-align: left;\n}\n\n.profile-launcher-control {\n align-items: center;\n flex-wrap: wrap;\n}\n\n.profile-launcher-control > * {\n margin-top: 10px;\n margin-right: 6px;\n}\n\n.profile-launcher-control button {\n min-width: 110px;\n}\n\n.profile-launcher-target {\n align-items: baseline;\n}\n\n.profile-launcher-target > * {\n flex: 0 0 auto;\n margin-right: 8px;\n}\n\n.profile-launcher-view-content h1 {\n padding: 15px 0 10px;\n}\n\n.panel-enabler-view.profile-launcher-view form {\n padding: 0;\n font-size: 13px;\n width: 100%;\n}\n\n.panel-enabler-view.profile-launcher-view label {\n margin: 0;\n}\n\n.profile-launcher-view-content p {\n color: grey;\n margin-top: 1px;\n margin-left: 22px;\n}\n\n.profile-launcher-view-content button.running {\n color: hsl(0, 100%, 58%);\n}\n\n.profile-launcher-view-content button.running:hover {\n color: hsl(0, 100%, 42%);\n}\n\nbody.inactive .profile-launcher-view-content button.running:not(.toolbar-item) {\n color: rgb(220, 130, 130);\n}\n\n.highlighted-row {\n -webkit-animation: row_highlight 2s 0s;\n}\n\n@-webkit-keyframes row_highlight {\n from {background-color: rgba(255, 255, 120, 1); }\n to { background-color: rgba(255, 255, 120, 0); }\n}\n\n.profile-canvas-decoration span[is=dt-icon-label] {\n margin-right: 4px;\n}\n\n.profile-canvas-decoration {\n color: red;\n margin: -14px 0 13px 22px;\n padding-left: 14px;\n}\n\n.profile-canvas-decoration button {\n margin: 0 0 0 10px !important;\n}\n\n.profile-launcher-button {\n margin-top: 10px;\n margin-right: 8px;\n min-width: 110px;\n}\n\n.cpu-profile-flame-chart-overview-container {\n overflow: hidden;\n position: absolute;\n top: 0;\n width: 100%;\n height: 80px;\n}\n\n#cpu-profile-flame-chart-overview-container {\n border-bottom: 1px solid rgba(0, 0, 0, 0.3);\n}\n\n.cpu-profile-flame-chart-overview-canvas {\n position: absolute;\n top: 20px;\n left: 0;\n right: 0;\n bottom: 0;\n}\n\n#cpu-profile-flame-chart-overview-grid .resources-dividers-label-bar {\n pointer-events: auto;\n}\n\n.cpu-profile-flame-chart-overview-pane {\n flex: 0 0 80px !important;\n}\n\n/*# sourceURL=profiler/profilesPanel.css */";Runtime.cachedResources["profiler/profilesSidebarTree.css"]="/*\n * Copyright 2016 The Chromium Authors. All rights reserved.\n * Use of this source code is governed by a BSD-style license that can be\n * found in the LICENSE file.\n */\n\n/* Tree outline overrides */\n\n:host {\n padding: 0;\n}\n\nol.tree-outline {\n overflow: auto;\n flex: auto;\n padding: 0;\n margin: 0;\n}\n\n.tree-outline li {\n height: 36px;\n padding-right: 5px;\n margin-top: 1px;\n line-height: 34px;\n border-top: 1px solid transparent;\n}\n\n.tree-outline li:not(.parent)::before {\n display: none;\n}\n\n:host-context(.some-expandable) .tree-outline li:not(.parent) {\n margin-left: 10px;\n}\n\n.tree-outline li.profiles-tree-section {\n height: 18px;\n padding: 0 10px;\n white-space: nowrap;\n margin-top: 1px;\n color: rgb(92, 110, 129);\n text-shadow: rgba(255, 255, 255, 0.75) 0 1px 0;\n line-height: 18px;\n}\n\n.tree-outline li.profiles-tree-section::before {\n display: none;\n}\n\n.tree-outline ol {\n overflow: hidden;\n}\n\n/* Generic items styling */\n\n.title-container > .save-link {\n text-decoration: underline;\n margin-left: auto;\n display: none;\n}\n\nli.selected .title-container > .save-link {\n display: block;\n cursor: pointer;\n}\n\n.tree-outline > .icon {\n margin-left: 16px;\n}\n\nli .icon {\n width: 32px;\n height: 32px;\n margin-top: 1px;\n margin-right: 3px;\n flex: none;\n}\n\nli.wait .icon {\n content: none;\n}\n\nli.wait .icon::before {\n display: block;\n width: 24px;\n height: 24px;\n margin: 4px;\n border: 3px solid grey;\n border-radius: 12px;\n clip: rect(0, 15px, 15px, 0);\n content: \"\";\n position: absolute;\n -webkit-animation: spinner-animation 1s linear infinite;\n box-sizing: border-box;\n}\n\nli.wait.small .icon::before {\n width: 14px;\n height: 14px;\n margin: 1px;\n clip: rect(0, 9px, 9px, 0);\n border-width: 2px;\n}\n\nli.wait.selected .icon::before {\n border-color: white;\n}\n\n@-webkit-keyframes spinner-animation {\n from { transform: rotate(0); }\n to { transform: rotate(360deg); }\n}\n\nli.small {\n height: 20px;\n}\n\nli.small .icon {\n width: 16px;\n height: 16px;\n}\n\nli .titles {\n display: flex;\n flex-direction: column;\n top: 5px;\n line-height: 12px;\n padding-bottom: 1px;\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n flex: auto;\n}\n\nli .titles > .title-container {\n display: flex;\n}\n\nli.small .titles {\n top: 2px;\n line-height: normal;\n}\n\nli:not(.small) .title::after {\n content: \"\\A\";\n white-space: pre;\n}\n\nli .subtitle {\n font-size: 80%;\n}\n\nli.small .subtitle {\n display: none;\n}\n\n/* Heap profiles */\n\n.heap-snapshot-sidebar-tree-item .icon {\n content: url(Images/profileIcon.png);\n}\n\n.heap-snapshot-sidebar-tree-item.small .icon {\n content: url(Images/profileSmallIcon.png);\n}\n\n/* Launcher */\n\n.profile-launcher-view-tree-item {\n margin-left: 0 !important;\n}\n\n.profile-launcher-view-tree-item > .icon {\n width: 8px !important;\n visibility: hidden;\n}\n\n/* CPU profiles */\n\n.profile-sidebar-tree-item .icon {\n content: url(Images/profileIcon.png);\n}\n\n.profile-sidebar-tree-item.small .icon {\n content: url(Images/profileSmallIcon.png);\n}\n\n.profile-group-sidebar-tree-item .icon {\n content: url(Images/profileGroupIcon.png);\n}\n\n/*# sourceURL=profiler/profilesSidebarTree.css */";