Changeset 116218 in webkit
- Timestamp:
- May 5, 2012 3:23:21 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r116217 r116218 1 2012-05-05 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Web Inspector: save HeapSnapshot implementation. 4 https://bugs.webkit.org/show_bug.cgi?id=85595 5 6 HeapSnapshot specific implementation for loading was moved 7 from ProfilesPanel to HeapProfileHeader class. 8 9 Reviewed by Yury Semikhatsky. 10 11 * inspector/profiler/heap-snapshot-inspect-dom-wrapper.html: 12 * inspector/profiler/heap-snapshot-test.js: 13 (initialize_HeapSnapshotTest): 14 1 15 2012-05-05 Pavel Feldman <pfeldman@chromium.org> 2 16 -
trunk/LayoutTests/inspector/profiler/heap-snapshot-inspect-dom-wrapper.html
r114271 r116218 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 InspectorTest.addSniffer(profile._proxy, "_callLoadCallbacks", step2); 31 31 } 32 32 -
trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js
r114872 r116218 524 524 InspectorTest.override(ProfilerAgent, "getProfile", pushGeneratedSnapshot); 525 525 InspectorTest._takeAndOpenSnapshotCallback = callback; 526 var profileType = WebInspector.panels.profiles.getProfileType(profile.typeId); 527 profile = profileType.createProfile(profile); 526 528 WebInspector.panels.profiles.addProfileHeader(profile); 527 529 WebInspector.panels.profiles.showProfile(profile); -
trunk/Source/WebCore/ChangeLog
r116217 r116218 1 2012-05-05 Ilya Tikhonovsky <loislo@chromium.org> 2 3 Web Inspector: save HeapSnapshot implementation. 4 https://bugs.webkit.org/show_bug.cgi?id=85595 5 6 HeapSnapshot specific implementation for loading was moved 7 from ProfilesPanel to HeapProfileHeader class. 8 9 Reviewed by Yury Semikhatsky. 10 11 * inspector/front-end/HeapSnapshotView.js: 12 (WebInspector.HeapSnapshotView.prototype.get profileWrapper): 13 (WebInspector.HeapSnapshotView.prototype.get baseProfileWrapper): 14 (WebInspector.HeapProfileHeader): 15 (WebInspector.HeapProfileHeader.prototype.load.setProfileWait): 16 (WebInspector.HeapProfileHeader.prototype.load.done): 17 (WebInspector.HeapProfileHeader.prototype.load): 18 (WebInspector.HeapProfileHeader.prototype._saveStatusUpdate): 19 (WebInspector.HeapProfileHeader.prototype.pushJSONChunk): 20 (WebInspector.HeapProfileHeader.prototype.finishHeapSnapshot): 21 (WebInspector.HeapProfileHeader.prototype.canSave): 22 (WebInspector.HeapProfileHeader.prototype.save): 23 * inspector/front-end/InspectorFrontendAPI.js: 24 (InspectorFrontendAPI.appendedToURL): 25 * inspector/front-end/ProfilesPanel.js: 26 (WebInspector.ProfilesPanel.prototype._registerProfileType): 27 (WebInspector.ProfilesPanel.prototype._handleContextMenuEvent): 28 (WebInspector.ProfilesPanel.prototype.loadHeapSnapshot): 29 (WebInspector.ProfilesPanel.prototype._addHeapSnapshotChunk): 30 (WebInspector.ProfilesPanel.prototype._finishHeapSnapshot): 31 (WebInspector.ProfileSidebarTreeElement.prototype.set searchMatches): 32 (WebInspector.ProfileSidebarTreeElement.prototype.handleContextMenuEvent): 33 * inspector/front-end/inspector.js: 34 (WebInspector.append): 35 (WebInspector.appendedToURL): 36 1 37 2012-05-05 Pavel Feldman <pfeldman@chromium.org> 2 38 -
trunk/Source/WebCore/inspector/front-end/HeapSnapshotView.js
r116210 r116218 182 182 get profileWrapper() 183 183 { 184 return this.profile. proxy;184 return this.profile._proxy; 185 185 }, 186 186 … … 192 192 get baseProfileWrapper() 193 193 { 194 return this.baseProfile. proxy;194 return this.baseProfile._proxy; 195 195 }, 196 196 … … 771 771 772 772 WebInspector.HeapSnapshotProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype; 773 774 /** 775 * @constructor 776 * @extends {WebInspector.ProfileHeader} 777 * @param {string} profileType 778 * @param {string} title 779 * @param {number} uid 780 * @param {number} maxJSObjectId 781 */ 782 WebInspector.HeapProfileHeader = function(profileType, title, uid, maxJSObjectId) 783 { 784 WebInspector.ProfileHeader.call(this, profileType, title, uid); 785 this.maxJSObjectId = maxJSObjectId; 786 this._loaded = false; 787 this._totalNumberOfChunks = 0; 788 } 789 790 WebInspector.HeapProfileHeader.prototype = { 791 load: function(callback) 792 { 793 if (this._loaded) { 794 callback.call(null); 795 return; 796 } 797 798 if (!this._proxy) { 799 function setProfileWait(event) { 800 this.sidebarElement.wait = event.data; 801 } 802 var worker = new WebInspector.HeapSnapshotWorker(); 803 worker.addEventListener("wait", setProfileWait, this); 804 this._proxy = worker.createObject("WebInspector.HeapSnapshotLoader"); 805 } 806 807 if (this._proxy.startLoading(callback)) { 808 this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026"); 809 this.sidebarElement.wait = true; 810 function done() 811 { 812 this._loaded = true; 813 } 814 ProfilerAgent.getProfile(this.typeId, this.uid, done.bind(this)); 815 } 816 }, 817 818 _saveStatusUpdate: function() 819 { 820 ++this._savedChunksCount; 821 if (this._savedChunksCount === this._totalNumberOfChunks) { 822 this.sidebarElement.subtitle = Number.bytesToString(this._proxy.totalSize); 823 this.sidebarElement.wait = false; 824 } else 825 this.sidebarElement.subtitle = WebInspector.UIString("Saving\u2026 %d\%", Math.floor(this._savedChunksCount * 100 / this._totalNumberOfChunks)); 826 }, 827 828 pushJSONChunk: function(chunk) 829 { 830 if (this._loaded) { 831 this.sidebarElement.wait = true; 832 WebInspector.append(this._fileName, chunk, this._saveStatusUpdate.bind(this)); 833 } else { 834 ++this._totalNumberOfChunks; 835 this._proxy.pushJSONChunk(chunk); 836 } 837 }, 838 839 finishHeapSnapshot: function() 840 { 841 function parsed(snapshotProxy) 842 { 843 this._proxy = snapshotProxy; 844 this.sidebarElement.subtitle = Number.bytesToString(snapshotProxy.totalSize); 845 this.sidebarElement.wait = false; 846 var worker = /** @type {WebInspector.HeapSnapshotWorker} */ snapshotProxy.worker; 847 worker.startCheckingForLongRunningCalls(); 848 } 849 if (this._proxy.finishLoading(parsed.bind(this))) 850 this.sidebarElement.subtitle = WebInspector.UIString("Parsing\u2026"); 851 }, 852 853 canSave: function() 854 { 855 return this._loaded && InspectorFrontendHost.canSave() && ("append" in InspectorFrontendHost); 856 }, 857 858 save: function() 859 { 860 function startWritingSnapshot() 861 { 862 this.sidebarElement.wait = true; 863 this.sidebarElement.subtitle = WebInspector.UIString("Saving\u2026 0\%"); 864 this._savedChunksCount = 0; 865 ProfilerAgent.getProfile(this.typeId, this.uid); 866 } 867 this._fileName = this._fileName || "Heap-" + new Date().toISO8601Compact() + ".json"; 868 WebInspector.save(this._fileName, "", true, startWritingSnapshot.bind(this)); 869 } 870 } 871 872 WebInspector.HeapProfileHeader.prototype.__proto__ = WebInspector.ProfileHeader.prototype; -
trunk/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js
r113199 r116218 111 111 }, 112 112 113 appendedToURL: function(url) 114 { 115 WebInspector.appendedToURL(url); 116 }, 117 113 118 setToolbarColors: function(backgroundColor, color) 114 119 { -
trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js
r116210 r116218 139 139 /** 140 140 * @constructor 141 * @extends {WebInspector.ProfileHeader}142 * @param {string} profileType143 * @param {string} title144 * @param {number} uid145 * @param {number} maxJSObjectId146 */147 WebInspector.HeapProfileHeader = function(profileType, title, uid, maxJSObjectId)148 {149 WebInspector.ProfileHeader.call(this, profileType, title, uid);150 this.maxJSObjectId = maxJSObjectId;151 }152 153 /**154 * @constructor155 141 * @extends {WebInspector.Panel} 156 142 */ … … 337 323 profileType.treeElement.hidden = true; 338 324 this.sidebarTree.appendChild(profileType.treeElement); 325 profileType.treeElement.childrenListElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true); 326 }, 327 328 _handleContextMenuEvent: function(event) 329 { 330 var element = event.srcElement; 331 while (element && !element.treeElement) 332 element = element.parentElement; 333 if (!element) 334 return; 335 if (element.treeElement.handleContextMenuEvent) 336 element.treeElement.handleContextMenuEvent(event); 339 337 }, 340 338 … … 560 558 if (!profile) 561 559 return; 562 563 if (!profile.proxy) { 564 function setProfileWait(event) { 565 profile.sidebarElement.wait = event.data; 566 } 567 var worker = new WebInspector.HeapSnapshotWorker(); 568 worker.addEventListener("wait", setProfileWait, this); 569 profile.proxy = worker.createObject("WebInspector.HeapSnapshotLoader"); 570 } 571 var proxy = profile.proxy; 572 if (proxy.startLoading(callback)) { 573 profile.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026"); 574 profile.sidebarElement.wait = true; 575 ProfilerAgent.getProfile(profile.typeId, profile.uid); 576 } 560 profile.load(callback); 577 561 }, 578 562 … … 584 568 { 585 569 var profile = this._profilesIdMap[this._makeKey(uid, WebInspector.HeapSnapshotProfileType.TypeId)]; 586 if (!profile || !profile.proxy)587 return; 588 profile.p roxy.pushJSONChunk(chunk);570 if (!profile ) 571 return; 572 profile.pushJSONChunk(chunk); 589 573 }, 590 574 … … 595 579 { 596 580 var profile = this._profilesIdMap[this._makeKey(uid, WebInspector.HeapSnapshotProfileType.TypeId)]; 597 if (!profile || !profile.proxy) 598 return; 599 var proxy = profile.proxy; 600 function parsed(snapshotProxy) 601 { 602 profile.proxy = snapshotProxy; 603 profile.sidebarElement.subtitle = Number.bytesToString(snapshotProxy.totalSize); 604 profile.sidebarElement.wait = false; 605 var worker = /** @type {WebInspector.HeapSnapshotWorker} */ snapshotProxy.worker; 606 worker.startCheckingForLongRunningCalls(); 607 } 608 if (proxy.finishLoading(parsed)) 609 profile.sidebarElement.subtitle = WebInspector.UIString("Parsing\u2026"); 581 if (!profile) 582 return; 583 profile.finishHeapSnapshot(); 610 584 }, 611 585 … … 1117 1091 this.bubbleText = matches; 1118 1092 this.bubbleElement.addStyleClass("search-matches"); 1093 }, 1094 1095 handleContextMenuEvent: function(event) 1096 { 1097 var profile = this.profile; 1098 if (!profile.canSave || !profile.canSave()) 1099 return; 1100 var contextMenu = new WebInspector.ContextMenu(); 1101 contextMenu.appendItem(WebInspector.UIString("Save profile"), profile.save.bind(profile)); 1102 contextMenu.show(event); 1119 1103 } 1120 1104 } -
trunk/Source/WebCore/inspector/front-end/inspector.js
r115569 r116218 1033 1033 } 1034 1034 1035 WebInspector.save = function(url, content, forceSaveAs) 1035 WebInspector._saveCallbacks = []; 1036 1037 WebInspector.save = function(url, content, forceSaveAs, callback) 1036 1038 { 1037 1039 // Remove this url from the saved URLs while it is being saved. … … 1039 1041 delete savedURLs[url]; 1040 1042 WebInspector.settings.savedURLs.set(savedURLs); 1041 1043 if (callback) 1044 WebInspector._saveCallbacks[url] = callback; 1042 1045 InspectorFrontendHost.save(url, content, forceSaveAs); 1043 1046 } … … 1048 1051 savedURLs[url] = true; 1049 1052 WebInspector.settings.savedURLs.set(savedURLs); 1053 var callback = WebInspector._saveCallbacks[url]; 1054 if (!callback) 1055 return; 1056 delete WebInspector._saveCallbacks[url]; 1057 callback.call(null, url); 1050 1058 } 1051 1059 … … 1055 1063 return savedURLs[url]; 1056 1064 } 1065 1066 WebInspector._appendCallbacks = []; 1067 1068 WebInspector.append = function(url, content, callback) 1069 { 1070 if (callback) 1071 WebInspector._appendCallbacks[url] = callback; 1072 InspectorFrontendHost.append(url, content); 1073 } 1074 1075 WebInspector.appendedToURL = function(url) 1076 { 1077 var callback = WebInspector._appendCallbacks[url]; 1078 if (callback) 1079 callback.call(null, url); 1080 } 1081
Note: See TracChangeset
for help on using the changeset viewer.