Diff
Modified: trunk/LayoutTests/ChangeLog (116217 => 116218)
--- trunk/LayoutTests/ChangeLog 2012-05-05 10:07:39 UTC (rev 116217)
+++ trunk/LayoutTests/ChangeLog 2012-05-05 10:23:21 UTC (rev 116218)
@@ -1,3 +1,17 @@
+2012-05-05 Ilya Tikhonovsky <[email protected]>
+
+ Web Inspector: save HeapSnapshot implementation.
+ https://bugs.webkit.org/show_bug.cgi?id=85595
+
+ HeapSnapshot specific implementation for loading was moved
+ from ProfilesPanel to HeapProfileHeader class.
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/profiler/heap-snapshot-inspect-dom-wrapper.html:
+ * inspector/profiler/heap-snapshot-test.js:
+ (initialize_HeapSnapshotTest):
+
2012-05-05 Pavel Feldman <[email protected]>
Web Inspector: allow overriding the script mapping on the UI level
Modified: trunk/LayoutTests/inspector/profiler/heap-snapshot-inspect-dom-wrapper.html (116217 => 116218)
--- trunk/LayoutTests/inspector/profiler/heap-snapshot-inspect-dom-wrapper.html 2012-05-05 10:07:39 UTC (rev 116217)
+++ trunk/LayoutTests/inspector/profiler/heap-snapshot-inspect-dom-wrapper.html 2012-05-05 10:23:21 UTC (rev 116218)
@@ -27,7 +27,7 @@
InspectorTest.addResult("_finishHeapSnapshot " + uid);
var panel = WebInspector.panels.profiles;
var profile = "" WebInspector.HeapSnapshotProfileType.TypeId)];
- InspectorTest.addSniffer(profile.proxy, "_callLoadCallbacks", step2);
+ InspectorTest.addSniffer(profile._proxy, "_callLoadCallbacks", step2);
}
function step2(loadCallbacks, snapshotProxy)
Modified: trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js (116217 => 116218)
--- trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js 2012-05-05 10:07:39 UTC (rev 116217)
+++ trunk/LayoutTests/inspector/profiler/heap-snapshot-test.js 2012-05-05 10:23:21 UTC (rev 116218)
@@ -523,6 +523,8 @@
}
InspectorTest.override(ProfilerAgent, "getProfile", pushGeneratedSnapshot);
InspectorTest._takeAndOpenSnapshotCallback = callback;
+ var profileType = WebInspector.panels.profiles.getProfileType(profile.typeId);
+ profile = ""
WebInspector.panels.profiles.addProfileHeader(profile);
WebInspector.panels.profiles.showProfile(profile);
};
Modified: trunk/Source/WebCore/ChangeLog (116217 => 116218)
--- trunk/Source/WebCore/ChangeLog 2012-05-05 10:07:39 UTC (rev 116217)
+++ trunk/Source/WebCore/ChangeLog 2012-05-05 10:23:21 UTC (rev 116218)
@@ -1,3 +1,39 @@
+2012-05-05 Ilya Tikhonovsky <[email protected]>
+
+ Web Inspector: save HeapSnapshot implementation.
+ https://bugs.webkit.org/show_bug.cgi?id=85595
+
+ HeapSnapshot specific implementation for loading was moved
+ from ProfilesPanel to HeapProfileHeader class.
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/front-end/HeapSnapshotView.js:
+ (WebInspector.HeapSnapshotView.prototype.get profileWrapper):
+ (WebInspector.HeapSnapshotView.prototype.get baseProfileWrapper):
+ (WebInspector.HeapProfileHeader):
+ (WebInspector.HeapProfileHeader.prototype.load.setProfileWait):
+ (WebInspector.HeapProfileHeader.prototype.load.done):
+ (WebInspector.HeapProfileHeader.prototype.load):
+ (WebInspector.HeapProfileHeader.prototype._saveStatusUpdate):
+ (WebInspector.HeapProfileHeader.prototype.pushJSONChunk):
+ (WebInspector.HeapProfileHeader.prototype.finishHeapSnapshot):
+ (WebInspector.HeapProfileHeader.prototype.canSave):
+ (WebInspector.HeapProfileHeader.prototype.save):
+ * inspector/front-end/InspectorFrontendAPI.js:
+ (InspectorFrontendAPI.appendedToURL):
+ * inspector/front-end/ProfilesPanel.js:
+ (WebInspector.ProfilesPanel.prototype._registerProfileType):
+ (WebInspector.ProfilesPanel.prototype._handleContextMenuEvent):
+ (WebInspector.ProfilesPanel.prototype.loadHeapSnapshot):
+ (WebInspector.ProfilesPanel.prototype._addHeapSnapshotChunk):
+ (WebInspector.ProfilesPanel.prototype._finishHeapSnapshot):
+ (WebInspector.ProfileSidebarTreeElement.prototype.set searchMatches):
+ (WebInspector.ProfileSidebarTreeElement.prototype.handleContextMenuEvent):
+ * inspector/front-end/inspector.js:
+ (WebInspector.append):
+ (WebInspector.appendedToURL):
+
2012-05-05 Pavel Feldman <[email protected]>
Web Inspector: allow overriding the script mapping on the UI level
Modified: trunk/Source/WebCore/inspector/front-end/HeapSnapshotView.js (116217 => 116218)
--- trunk/Source/WebCore/inspector/front-end/HeapSnapshotView.js 2012-05-05 10:07:39 UTC (rev 116217)
+++ trunk/Source/WebCore/inspector/front-end/HeapSnapshotView.js 2012-05-05 10:23:21 UTC (rev 116218)
@@ -181,7 +181,7 @@
get profileWrapper()
{
- return this.profile.proxy;
+ return this.profile._proxy;
},
get baseProfile()
@@ -191,7 +191,7 @@
get baseProfileWrapper()
{
- return this.baseProfile.proxy;
+ return this.baseProfile._proxy;
},
wasShown: function()
@@ -770,3 +770,103 @@
}
WebInspector.HeapSnapshotProfileType.prototype.__proto__ = WebInspector.ProfileType.prototype;
+
+/**
+ * @constructor
+ * @extends {WebInspector.ProfileHeader}
+ * @param {string} profileType
+ * @param {string} title
+ * @param {number} uid
+ * @param {number} maxJSObjectId
+ */
+WebInspector.HeapProfileHeader = function(profileType, title, uid, maxJSObjectId)
+{
+ WebInspector.ProfileHeader.call(this, profileType, title, uid);
+ this.maxJSObjectId = maxJSObjectId;
+ this._loaded = false;
+ this._totalNumberOfChunks = 0;
+}
+
+WebInspector.HeapProfileHeader.prototype = {
+ load: function(callback)
+ {
+ if (this._loaded) {
+ callback.call(null);
+ return;
+ }
+
+ if (!this._proxy) {
+ function setProfileWait(event) {
+ this.sidebarElement.wait = event.data;
+ }
+ var worker = new WebInspector.HeapSnapshotWorker();
+ worker.addEventListener("wait", setProfileWait, this);
+ this._proxy = worker.createObject("WebInspector.HeapSnapshotLoader");
+ }
+
+ if (this._proxy.startLoading(callback)) {
+ this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026");
+ this.sidebarElement.wait = true;
+ function done()
+ {
+ this._loaded = true;
+ }
+ ProfilerAgent.getProfile(this.typeId, this.uid, done.bind(this));
+ }
+ },
+
+ _saveStatusUpdate: function()
+ {
+ ++this._savedChunksCount;
+ if (this._savedChunksCount === this._totalNumberOfChunks) {
+ this.sidebarElement.subtitle = Number.bytesToString(this._proxy.totalSize);
+ this.sidebarElement.wait = false;
+ } else
+ this.sidebarElement.subtitle = WebInspector.UIString("Saving\u2026 %d\%", Math.floor(this._savedChunksCount * 100 / this._totalNumberOfChunks));
+ },
+
+ pushJSONChunk: function(chunk)
+ {
+ if (this._loaded) {
+ this.sidebarElement.wait = true;
+ WebInspector.append(this._fileName, chunk, this._saveStatusUpdate.bind(this));
+ } else {
+ ++this._totalNumberOfChunks;
+ this._proxy.pushJSONChunk(chunk);
+ }
+ },
+
+ finishHeapSnapshot: function()
+ {
+ function parsed(snapshotProxy)
+ {
+ this._proxy = snapshotProxy;
+ this.sidebarElement.subtitle = Number.bytesToString(snapshotProxy.totalSize);
+ this.sidebarElement.wait = false;
+ var worker = /** @type {WebInspector.HeapSnapshotWorker} */ snapshotProxy.worker;
+ worker.startCheckingForLongRunningCalls();
+ }
+ if (this._proxy.finishLoading(parsed.bind(this)))
+ this.sidebarElement.subtitle = WebInspector.UIString("Parsing\u2026");
+ },
+
+ canSave: function()
+ {
+ return this._loaded && InspectorFrontendHost.canSave() && ("append" in InspectorFrontendHost);
+ },
+
+ save: function()
+ {
+ function startWritingSnapshot()
+ {
+ this.sidebarElement.wait = true;
+ this.sidebarElement.subtitle = WebInspector.UIString("Saving\u2026 0\%");
+ this._savedChunksCount = 0;
+ ProfilerAgent.getProfile(this.typeId, this.uid);
+ }
+ this._fileName = this._fileName || "Heap-" + new Date().toISO8601Compact() + ".json";
+ WebInspector.save(this._fileName, "", true, startWritingSnapshot.bind(this));
+ }
+}
+
+WebInspector.HeapProfileHeader.prototype.__proto__ = WebInspector.ProfileHeader.prototype;
Modified: trunk/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js (116217 => 116218)
--- trunk/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js 2012-05-05 10:07:39 UTC (rev 116217)
+++ trunk/Source/WebCore/inspector/front-end/InspectorFrontendAPI.js 2012-05-05 10:23:21 UTC (rev 116218)
@@ -110,6 +110,11 @@
WebInspector.savedURL(url);
},
+ appendedToURL: function(url)
+ {
+ WebInspector.appendedToURL(url);
+ },
+
setToolbarColors: function(backgroundColor, color)
{
WebInspector.setToolbarColors(backgroundColor, color);
Modified: trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js (116217 => 116218)
--- trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js 2012-05-05 10:07:39 UTC (rev 116217)
+++ trunk/Source/WebCore/inspector/front-end/ProfilesPanel.js 2012-05-05 10:23:21 UTC (rev 116218)
@@ -138,20 +138,6 @@
/**
* @constructor
- * @extends {WebInspector.ProfileHeader}
- * @param {string} profileType
- * @param {string} title
- * @param {number} uid
- * @param {number} maxJSObjectId
- */
-WebInspector.HeapProfileHeader = function(profileType, title, uid, maxJSObjectId)
-{
- WebInspector.ProfileHeader.call(this, profileType, title, uid);
- this.maxJSObjectId = maxJSObjectId;
-}
-
-/**
- * @constructor
* @extends {WebInspector.Panel}
*/
WebInspector.ProfilesPanel = function()
@@ -336,8 +322,20 @@
profileType.treeElement = new WebInspector.SidebarSectionTreeElement(profileType.treeItemTitle, null, true);
profileType.treeElement.hidden = true;
this.sidebarTree.appendChild(profileType.treeElement);
+ profileType.treeElement.childrenListElement.addEventListener("contextmenu", this._handleContextMenuEvent.bind(this), true);
},
+ _handleContextMenuEvent: function(event)
+ {
+ var element = event.srcElement;
+ while (element && !element.treeElement)
+ element = element.parentElement;
+ if (!element)
+ return;
+ if (element.treeElement.handleContextMenuEvent)
+ element.treeElement.handleContextMenuEvent(event);
+ },
+
/**
* @param {string} text
* @param {string} profileTypeId
@@ -559,21 +557,7 @@
var profile = "" WebInspector.HeapSnapshotProfileType.TypeId)];
if (!profile)
return;
-
- if (!profile.proxy) {
- function setProfileWait(event) {
- profile.sidebarElement.wait = event.data;
- }
- var worker = new WebInspector.HeapSnapshotWorker();
- worker.addEventListener("wait", setProfileWait, this);
- profile.proxy = worker.createObject("WebInspector.HeapSnapshotLoader");
- }
- var proxy = profile.proxy;
- if (proxy.startLoading(callback)) {
- profile.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026");
- profile.sidebarElement.wait = true;
- ProfilerAgent.getProfile(profile.typeId, profile.uid);
- }
+ profile.load(callback);
},
/**
@@ -583,9 +567,9 @@
_addHeapSnapshotChunk: function(uid, chunk)
{
var profile = "" WebInspector.HeapSnapshotProfileType.TypeId)];
- if (!profile || !profile.proxy)
+ if (!profile )
return;
- profile.proxy.pushJSONChunk(chunk);
+ profile.pushJSONChunk(chunk);
},
/**
@@ -594,19 +578,9 @@
_finishHeapSnapshot: function(uid)
{
var profile = "" WebInspector.HeapSnapshotProfileType.TypeId)];
- if (!profile || !profile.proxy)
+ if (!profile)
return;
- var proxy = profile.proxy;
- function parsed(snapshotProxy)
- {
- profile.proxy = snapshotProxy;
- profile.sidebarElement.subtitle = Number.bytesToString(snapshotProxy.totalSize);
- profile.sidebarElement.wait = false;
- var worker = /** @type {WebInspector.HeapSnapshotWorker} */ snapshotProxy.worker;
- worker.startCheckingForLongRunningCalls();
- }
- if (proxy.finishLoading(parsed))
- profile.sidebarElement.subtitle = WebInspector.UIString("Parsing\u2026");
+ profile.finishHeapSnapshot();
},
/**
@@ -1116,6 +1090,16 @@
this.bubbleText = matches;
this.bubbleElement.addStyleClass("search-matches");
+ },
+
+ handleContextMenuEvent: function(event)
+ {
+ var profile = ""
+ if (!profile.canSave || !profile.canSave())
+ return;
+ var contextMenu = new WebInspector.ContextMenu();
+ contextMenu.appendItem(WebInspector.UIString("Save profile"), profile.save.bind(profile));
+ contextMenu.show(event);
}
}
Modified: trunk/Source/WebCore/inspector/front-end/inspector.js (116217 => 116218)
--- trunk/Source/WebCore/inspector/front-end/inspector.js 2012-05-05 10:07:39 UTC (rev 116217)
+++ trunk/Source/WebCore/inspector/front-end/inspector.js 2012-05-05 10:23:21 UTC (rev 116218)
@@ -1032,13 +1032,16 @@
WebInspector.inspectorView.setCurrentPanel(toolbarItem.panel);
}
-WebInspector.save = function(url, content, forceSaveAs)
+WebInspector._saveCallbacks = [];
+
+WebInspector.save = function(url, content, forceSaveAs, callback)
{
// Remove this url from the saved URLs while it is being saved.
var savedURLs = WebInspector.settings.savedURLs.get();
delete savedURLs[url];
WebInspector.settings.savedURLs.set(savedURLs);
-
+ if (callback)
+ WebInspector._saveCallbacks[url] = callback;
InspectorFrontendHost.save(url, content, forceSaveAs);
}
@@ -1047,6 +1050,11 @@
var savedURLs = WebInspector.settings.savedURLs.get();
savedURLs[url] = true;
WebInspector.settings.savedURLs.set(savedURLs);
+ var callback = WebInspector._saveCallbacks[url];
+ if (!callback)
+ return;
+ delete WebInspector._saveCallbacks[url];
+ callback.call(null, url);
}
WebInspector.isURLSaved = function(url)
@@ -1054,3 +1062,20 @@
var savedURLs = WebInspector.settings.savedURLs.get();
return savedURLs[url];
}
+
+WebInspector._appendCallbacks = [];
+
+WebInspector.append = function(url, content, callback)
+{
+ if (callback)
+ WebInspector._appendCallbacks[url] = callback;
+ InspectorFrontendHost.append(url, content);
+}
+
+WebInspector.appendedToURL = function(url)
+{
+ var callback = WebInspector._appendCallbacks[url];
+ if (callback)
+ callback.call(null, url);
+}
+