Changeset 117234 in webkit
- Timestamp:
- May 16, 2012 1:47:59 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r117232 r117234 1 2012-05-15 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: use separate fields for storing HeapSnapshotLoaderProxy and HeapSnapshotProxy 4 https://bugs.webkit.org/show_bug.cgi?id=86488 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/profiler/heap-snapshot-inspect-dom-wrapper.html: instead of sniffing a method 9 call we can use HeapProfileHeader.load directly. 10 1 11 2012-05-16 Kenichi Ishibashi <bashi@chromium.org> 2 12 -
trunk/LayoutTests/inspector/profiler/heap-snapshot-inspect-dom-wrapper.html
r116218 r117234 28 28 var panel = WebInspector.panels.profiles; 29 29 var profile = panel._profilesIdMap[panel._makeKey(uid, WebInspector.HeapSnapshotProfileType.TypeId)]; 30 InspectorTest.addSniffer(profile._proxy, "_callLoadCallbacks", step2);30 profile.load(step2.bind(this)); 31 31 } 32 32 33 function step2( loadCallbacks,snapshotProxy)33 function step2(snapshotProxy) 34 34 { 35 35 InspectorTest.addResult("_callLoadCallbacks"); -
trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js
r117051 r117234 161 161 // so we provide synthetic snapshots. 162 162 InspectorTest._panelReset = InspectorTest.override(WebInspector.panels.profiles, "_reset", function(){}, true); 163 InspectorTest.addSniffer(WebInspector.HeapSnapshotView.prototype, " _loadProfile", InspectorTest._snapshotViewShown, true);163 InspectorTest.addSniffer(WebInspector.HeapSnapshotView.prototype, "show", InspectorTest._snapshotViewShown, true); 164 164 165 165 detailedHeapProfilesEnabled(); -
trunk/Source/WebCore/ChangeLog
r117233 r117234 1 2012-05-15 Yury Semikhatsky <yurys@chromium.org> 2 3 Web Inspector: use separate fields for storing HeapSnapshotLoaderProxy and HeapSnapshotProxy 4 https://bugs.webkit.org/show_bug.cgi?id=86488 5 6 Reviewed by Pavel Feldman. 7 8 Simplified heap profiler snapshot loading code. Introduced dedicated fields for 9 snapshot loader proxy and for snapshot proxy. 10 11 * inspector/front-end/HeapSnapshotProxy.js: 12 (WebInspector.HeapSnapshotWorker): 13 (WebInspector.HeapSnapshotLoaderProxy): 14 (WebInspector.HeapSnapshotLoaderProxy.prototype.finishLoading.updateStaticData): 15 (WebInspector.HeapSnapshotLoaderProxy.prototype.finishLoading.callLoadCallbacks): 16 (WebInspector.HeapSnapshotLoaderProxy.prototype.finishLoading): 17 (WebInspector.HeapSnapshotLoaderProxy.prototype.get loaded): 18 (WebInspector.HeapSnapshotLoaderProxy.prototype.startLoading): 19 (WebInspector.HeapSnapshotLoaderProxy.prototype.pushJSONChunk): 20 * inspector/front-end/HeapSnapshotView.js: 21 (WebInspector.HeapSnapshotView.profileCallback): 22 (WebInspector.HeapSnapshotView): 23 (WebInspector.HeapSnapshotView.prototype.dispose): 24 (WebInspector.HeapSnapshotView.prototype.get baseProfileWrapper): 25 (WebInspector.HeapSnapshotView.prototype.wasShown.profileCallback1): 26 (WebInspector.HeapSnapshotView.prototype._changeView): 27 (WebInspector.HeapProfileHeader): split _proxy field into _loaderProxy and _snapshotProxy 28 (WebInspector.HeapProfileHeader.prototype.snapshotProxy): 29 (WebInspector.HeapProfileHeader.prototype.load): 30 (WebInspector.HeapProfileHeader.prototype._setupWorker): 31 (WebInspector.HeapProfileHeader.prototype.dispose): 32 (WebInspector.HeapProfileHeader.prototype._saveStatusUpdate): 33 (WebInspector.HeapProfileHeader.prototype.pushJSONChunk): 34 (WebInspector.HeapProfileHeader.prototype.finishHeapSnapshot): 35 (WebInspector.HeapProfileHeader.prototype.canSaveToFile): 36 (WebInspector.HeapProfileHeader.prototype.loadFromFile.onLoad): 37 (WebInspector.HeapProfileHeader.prototype.loadFromFile): 38 1 39 2012-05-16 Eugene Klyuchnikov <eustas.bug@gmail.com> 2 40 -
trunk/Source/WebCore/inspector/front-end/HeapSnapshotProxy.js
r117227 r117234 301 301 { 302 302 WebInspector.HeapSnapshotProxyObject.call(this, worker, objectId); 303 this._loading = false; 304 this._loaded = false; 303 this._onLoadCallbacks = []; 305 304 } 306 305 307 306 WebInspector.HeapSnapshotLoaderProxy.prototype = { 307 /** 308 * @param {function(WebInspector.HeapSnapshotProxy)} callback 309 */ 308 310 finishLoading: function(callback) 309 311 { 310 if (!this._loading) 311 return false; 312 var loadCallbacks = this._onLoadCallbacks; 313 loadCallbacks.splice(0, 0, callback); 314 delete this._onLoadCallbacks; 315 this._loading = false; 316 this._loaded = true; 317 var self = this; 312 this._onLoadCallbacks.unshift(callback); 313 318 314 function updateStaticData(snapshotProxy) 319 315 { 320 316 this.dispose(); 321 snapshotProxy.updateStaticData(this._callLoadCallbacks.bind(this, loadCallbacks)); 317 snapshotProxy.updateStaticData(callLoadCallbacks.bind(this)); 318 } 319 function callLoadCallbacks(snapshotProxy) 320 { 321 for (var i = 0; i < this._onLoadCallbacks.length; ++i) 322 this._onLoadCallbacks[i](snapshotProxy); 323 this._onLoadCallbacks = null; 322 324 } 323 325 this.callFactoryMethod(updateStaticData.bind(this), "finishLoading", "WebInspector.HeapSnapshotProxy"); 324 return true; 325 }, 326 327 _callLoadCallbacks: function(loadCallbacks, snapshotProxy) 328 { 329 for (var i = 0; i < loadCallbacks.length; ++i) 330 loadCallbacks[i](snapshotProxy); 331 }, 332 333 get loaded() 334 { 335 return this._loaded; 336 }, 337 326 }, 327 328 /** 329 * @param {function(WebInspector.HeapSnapshotProxy)} callback 330 * @return {boolean} 331 */ 338 332 startLoading: function(callback) 339 333 { 340 if (!this._loading) { 341 this._onLoadCallbacks = [callback]; 342 this._loading = true; 343 return true; 344 } else { 345 this._onLoadCallbacks.push(callback); 346 return false; 347 } 334 var loadingHasJustStarted = !this._onLoadCallbacks.length; 335 this._onLoadCallbacks.push(callback); 336 return loadingHasJustStarted; 348 337 }, 349 338 350 339 pushJSONChunk: function(chunk) 351 340 { 352 if (!this._loading)353 return;354 341 this.callMethod(null, "pushJSONChunk", chunk); 355 342 } … … 431 418 { 432 419 this.disposeWorker(); 433 },434 435 finishLoading: function()436 {437 return false;438 },439 440 get loaded()441 {442 return !!this._objectId;443 420 }, 444 421 … … 468 445 }, 469 446 470 startLoading: function(callback)471 {472 setTimeout(callback.bind(null, this), 0);473 return false;474 },475 476 447 get totalSize() 477 448 { -
trunk/Source/WebCore/inspector/front-end/HeapSnapshotView.js
r116959 r117234 136 136 this._popoverHelper = new WebInspector.ObjectPopoverHelper(this.element, this._getHoverAnchor.bind(this), this._resolveObjectForPopover.bind(this), undefined, true); 137 137 138 this. _loadProfile(this._profileUid,profileCallback.bind(this));139 140 function profileCallback( )138 this.profile.load(profileCallback.bind(this)); 139 140 function profileCallback(heapSnapshotProxy) 141 141 { 142 142 var list = this._profiles(); … … 153 153 else 154 154 this.baseSelectElement.selectedIndex = profileIndex; 155 this.dataGrid.setDataSource(this, this.profileWrapper);155 this.dataGrid.setDataSource(this, heapSnapshotProxy); 156 156 } 157 157 } … … 160 160 dispose: function() 161 161 { 162 this.profile Wrapper.dispose();162 this.profile.dispose(); 163 163 if (this.baseProfile) 164 this.baseProfile Wrapper.dispose();164 this.baseProfile.dispose(); 165 165 this.containmentDataGrid.dispose(); 166 166 this.constructorsDataGrid.dispose(); … … 180 180 }, 181 181 182 get profileWrapper()183 {184 return this.profile._proxy;185 },186 187 182 get baseProfile() 188 183 { … … 190 185 }, 191 186 192 get baseProfileWrapper()193 {194 return this.baseProfile._proxy;195 },196 197 187 wasShown: function() 198 188 { 199 if (!this.profileWrapper.loaded) 200 this._loadProfile(this._profileUid, profileCallback1.bind(this)); 201 else 202 profileCallback1.call(this); 189 // FIXME: load base and current snapshots in parallel 190 this.profile.load(profileCallback1.bind(this)); 203 191 204 192 function profileCallback1() { 205 if (this.baseProfile && !this.baseProfileWrapper.loaded)206 this. _loadProfile(this._baseProfileUid,profileCallback2.bind(this));193 if (this.baseProfile) 194 this.baseProfile.load(profileCallback2.bind(this)); 207 195 else 208 196 profileCallback2.call(this); … … 371 359 this._baseProfileUid = this._profiles()[this.baseSelectElement.selectedIndex].uid; 372 360 var dataGrid = /** @type {WebInspector.HeapSnapshotDiffDataGrid} */ this.dataGrid; 373 this._loadProfile(this._baseProfileUid, dataGrid.setBaseDataSource.bind(dataGrid)); 361 // Change set base data source only if main data source is already set. 362 if (dataGrid.snapshot) 363 this.baseProfile.load(dataGrid.setBaseDataSource.bind(dataGrid)); 374 364 375 365 if (!this.currentQuery || !this._searchFinishedCallback || !this._searchResults) … … 421 411 }, 422 412 423 _loadProfile: function(profileUid, callback)424 {425 WebInspector.panels.profiles.loadHeapSnapshot(profileUid, callback);426 },427 428 413 isDetailedSnapshot: function(snapshot) 429 414 { … … 500 485 }, 501 486 487 _updateDataSourceAndView: function() 488 { 489 var dataGrid = this.dataGrid; 490 if (dataGrid.snapshotView) 491 return; 492 493 this.profile.load(didLoadSnapshot.bind(this)); 494 function didLoadSnapshot(snapshotProxy) 495 { 496 if (this.dataGrid !== dataGrid) 497 return; 498 if (dataGrid.snapshot !== snapshotProxy) 499 dataGrid.setDataSource(this, snapshotProxy); 500 if (dataGrid === this.diffDataGrid) { 501 if (!this._baseProfileUid) 502 this._baseProfileUid = this._profiles()[this.baseSelectElement.selectedIndex].uid; 503 this.baseProfile.load(didLoadBaseSnaphot.bind(this)); 504 } 505 } 506 507 function didLoadBaseSnaphot(baseSnapshotProxy) 508 { 509 if (this.diffDataGrid.baseSnapshot !== baseSnapshotProxy) 510 this.diffDataGrid.setBaseDataSource(baseSnapshotProxy); 511 } 512 }, 513 502 514 _changeView: function(event) 503 515 { … … 516 528 this.dataGrid.updateWidths(); 517 529 518 if (this.currentView === this.diffView) {530 if (this.currentView === this.diffView) 519 531 this.baseSelectElement.removeStyleClass("hidden"); 520 if (!this.dataGrid.snapshotView) { 521 this._changeBase(); 522 this.dataGrid.setDataSource(this, this.profileWrapper); 523 } 524 } else { 532 else 525 533 this.baseSelectElement.addStyleClass("hidden"); 526 if (!this.dataGrid.snapshotView) 527 this.dataGrid.setDataSource(this, this.profileWrapper); 528 } 534 535 this._updateDataSourceAndView(); 529 536 530 537 if (this.currentView === this.constructorsView) … … 795 802 WebInspector.ProfileHeader.call(this, WebInspector.HeapSnapshotProfileType.TypeId, title, uid); 796 803 this.maxJSObjectId = maxJSObjectId; 797 this._loaded = false; 804 /** 805 * @type {WebInspector.HeapSnapshotLoaderProxy} 806 */ 807 this._loaderProxy = null; 808 /** 809 * @type {WebInspector.HeapSnapshotProxy} 810 */ 811 this._snapshotProxy = null; 798 812 this._totalNumberOfChunks = 0; 799 813 } 800 814 801 815 WebInspector.HeapProfileHeader.prototype = { 816 snapshotProxy: function() 817 { 818 return this._snapshotProxy; 819 }, 820 802 821 /** 803 822 * @override … … 806 825 load: function(callback) 807 826 { 808 if (this._ loaded) {809 callback(this._ proxy);810 return; 811 } 812 813 if (!this._ proxy)827 if (this._snapshotProxy) { 828 callback(this._snapshotProxy); 829 return; 830 } 831 832 if (!this._loaderProxy) 814 833 this._setupWorker(); 815 834 816 if (this._ proxy.startLoading(callback)) {835 if (this._loaderProxy.startLoading(callback)) { 817 836 this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026"); 818 837 this.sidebarElement.wait = true; 819 function done() 820 { 821 this._loaded = true; 822 } 823 ProfilerAgent.getProfile(this.typeId, this.uid, done.bind(this)); 838 ProfilerAgent.getProfile(this.typeId, this.uid); 824 839 } 825 840 }, … … 832 847 var worker = new WebInspector.HeapSnapshotWorker(); 833 848 worker.addEventListener("wait", setProfileWait, this); 834 this._proxy = worker.createObject("WebInspector.HeapSnapshotLoader"); 849 this._loaderProxy = worker.createObject("WebInspector.HeapSnapshotLoader"); 850 }, 851 852 dispose: function() 853 { 854 if (this._loaderProxy) 855 this._loaderProxy.dispose(); 856 else if (this._snapshotProxy) 857 this._snapshotProxy.dispose(); 835 858 }, 836 859 … … 843 866 return; 844 867 if (++this._savedChunksCount === this._totalNumberOfChunks) { 845 this.sidebarElement.subtitle = Number.bytesToString(this._ proxy.totalSize);868 this.sidebarElement.subtitle = Number.bytesToString(this._snapshotProxy.totalSize); 846 869 this.sidebarElement.wait = false; 847 870 this._savedChunksCount = 0; … … 856 879 pushJSONChunk: function(chunk) 857 880 { 858 if (this._loaded) { 881 if (this._loaderProxy) { 882 ++this._totalNumberOfChunks; 883 this._loaderProxy.pushJSONChunk(chunk); 884 } else { 859 885 this.sidebarElement.wait = true; 860 886 WebInspector.fileManager.append(this._fileName, chunk); 861 } else {862 ++this._totalNumberOfChunks;863 this._proxy.pushJSONChunk(chunk);864 887 } 865 888 }, … … 869 892 function parsed(snapshotProxy) 870 893 { 871 this._proxy = snapshotProxy; 894 this._loaderProxy = null; 895 this._snapshotProxy = snapshotProxy; 872 896 this.sidebarElement.subtitle = Number.bytesToString(snapshotProxy.totalSize); 873 897 this.sidebarElement.wait = false; … … 876 900 worker.startCheckingForLongRunningCalls(); 877 901 } 878 if (this._ proxy.finishLoading(parsed.bind(this)))902 if (this._loaderProxy.finishLoading(parsed.bind(this))) 879 903 this.sidebarElement.subtitle = WebInspector.UIString("Parsing\u2026"); 880 904 }, … … 886 910 canSaveToFile: function() 887 911 { 888 return !this.fromFile() && this._ loaded&& !this._savedChunksCount && WebInspector.fileManager.canAppend();912 return !this.fromFile() && this._snapshotProxy && !this._savedChunksCount && WebInspector.fileManager.canAppend(); 889 913 }, 890 914 … … 948 972 this.sidebarElement.wait = true; 949 973 this._setupWorker(); 950 this._ proxy.startLoading(function() { });974 this._loaderProxy.startLoading(function(ignoredSnapshotProxy) { }); 951 975 952 976 function loadNextChunk(file, reader, loadedSize) … … 967 991 968 992 this._loadedSize += event.target.result.length; 969 this._ proxy.pushJSONChunk(event.target.result);993 this._loaderProxy.pushJSONChunk(event.target.result); 970 994 this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026 %d%", (this._loadedSize * 100 / file.size).toFixed(2)); 971 995 972 996 if (this._loadedSize === file.size) { 973 this._loaded = true;974 997 this.finishHeapSnapshot(); 975 998 return; -
trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js
r117051 r117234 646 646 /** 647 647 * @param {number} uid 648 * @param {Function} callback649 */650 loadHeapSnapshot: function(uid, callback)651 {652 var profile = this._profilesIdMap[this._makeKey(uid, WebInspector.HeapSnapshotProfileType.TypeId)];653 if (!profile)654 return;655 profile.load(callback);656 },657 658 /**659 * @param {number} uid660 648 * @param {string} chunk 661 649 */
Note: See TracChangeset
for help on using the changeset viewer.