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

Unified Diff: Source/devtools/front_end/HeapSnapshotView.js

Issue 98273008: [DevTools] Send heap snapshot to the frontend immediatly when it is ready (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed test crash Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/inspector/InspectorHeapProfilerAgent.cpp ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/HeapSnapshotView.js
diff --git a/Source/devtools/front_end/HeapSnapshotView.js b/Source/devtools/front_end/HeapSnapshotView.js
index 5cad97e7882c8a71834d63b2f383b91837d3a336..58c2866f61a2db9677fd6be0c06a12f41bd56bad 100644
--- a/Source/devtools/front_end/HeapSnapshotView.js
+++ b/Source/devtools/front_end/HeapSnapshotView.js
@@ -796,8 +796,9 @@ WebInspector.HeapProfilerDispatcher.prototype = {
* @override
* @param {number} done
* @param {number} total
+ * @param {boolean=} finished
*/
- reportHeapSnapshotProgress: function(done, total)
+ reportHeapSnapshotProgress: function(done, total, finished)
{
this._genericCaller("reportHeapSnapshotProgress");
},
@@ -817,11 +818,15 @@ WebInspector.HeapProfilerDispatcher._dispatcher = new WebInspector.HeapProfilerD
* @constructor
* @extends {WebInspector.ProfileType}
* @implements {HeapProfilerAgent.Dispatcher}
+ * @param {string=} id
+ * @param {string=} title
*/
-WebInspector.HeapSnapshotProfileType = function()
+WebInspector.HeapSnapshotProfileType = function(id, title)
{
- WebInspector.ProfileType.call(this, WebInspector.HeapSnapshotProfileType.TypeId, WebInspector.UIString("Take Heap Snapshot"));
+ WebInspector.ProfileType.call(this, id || WebInspector.HeapSnapshotProfileType.TypeId, title || WebInspector.UIString("Take Heap Snapshot"));
WebInspector.HeapProfilerDispatcher._dispatcher.register(this);
+
+ this._nextSnapshotId = 1;
}
WebInspector.HeapSnapshotProfileType.TypeId = "HEAP";
@@ -903,9 +908,24 @@ WebInspector.HeapSnapshotProfileType.prototype = {
{
if (this.profileBeingRecorded())
return;
- this._profileBeingRecorded = new WebInspector.HeapProfileHeader(this, WebInspector.UIString("Snapshotting\u2026"));
+ var id = this._nextSnapshotId++;
+ this._profileBeingRecorded = new WebInspector.HeapProfileHeader(this, WebInspector.UIString("Snapshotting\u2026"), id);
this.addProfile(this._profileBeingRecorded);
- HeapProfilerAgent.takeHeapSnapshot(true, callback);
+ /**
+ * @param {?string} error
+ * @this {WebInspector.HeapSnapshotProfileType}
+ */
+ function didTakeHeapSnapshot(error)
+ {
+ var profile = this._profileBeingRecorded;
+ profile.title = WebInspector.UIString("Snapshot %d", profile.uid);
+ profile._finishLoad();
+ this._profileBeingRecorded = null;
+ WebInspector.panels.profiles.showProfile(profile);
+ profile.existingView()._refreshView();
+ callback();
+ }
+ HeapProfilerAgent.takeHeapSnapshot(true, didTakeHeapSnapshot.bind(this));
},
/**
@@ -937,23 +957,26 @@ WebInspector.HeapSnapshotProfileType.prototype = {
*/
addHeapSnapshotChunk: function(uid, chunk)
{
- var profile = this.getProfile(uid);
- if (profile)
- profile.transferChunk(chunk);
+ if (!this.profileBeingRecorded())
+ return;
+ this.profileBeingRecorded().transferChunk(chunk);
},
/**
* @override
* @param {number} done
* @param {number} total
+ * @param {boolean=} finished
*/
- reportHeapSnapshotProgress: function(done, total)
+ reportHeapSnapshotProgress: function(done, total, finished)
{
var profile = this.profileBeingRecorded();
if (!profile)
return;
profile.sidebarElement.subtitle = WebInspector.UIString("%.0f%", (done / total) * 100);
profile.sidebarElement.wait = true;
+ if (finished)
+ profile._prepareToLoad();
},
/**
@@ -992,8 +1015,7 @@ WebInspector.HeapSnapshotProfileType.prototype = {
*/
WebInspector.TrackingHeapSnapshotProfileType = function()
{
- WebInspector.ProfileType.call(this, WebInspector.TrackingHeapSnapshotProfileType.TypeId, WebInspector.UIString("Record Heap Allocations"));
- WebInspector.HeapProfilerDispatcher._dispatcher.register(this);
+ WebInspector.HeapSnapshotProfileType.call(this, WebInspector.TrackingHeapSnapshotProfileType.TypeId, WebInspector.UIString("Record Heap Allocations"));
}
WebInspector.TrackingHeapSnapshotProfileType.TypeId = "HEAP-RECORD";
@@ -1104,7 +1126,29 @@ WebInspector.TrackingHeapSnapshotProfileType.prototype = {
_stopRecordingProfile: function()
{
- HeapProfilerAgent.stopTrackingHeapObjects(true);
+
+ var profile = this._profileBeingRecorded;
+ var title = WebInspector.UIString("Snapshotting\u2026");
+ profile.title = title;
+ profile.sidebarElement.mainTitle = title;
+ /**
+ * @param {?string} error
+ * @this {WebInspector.HeapSnapshotProfileType}
+ */
+ function didTakeHeapSnapshot(error)
+ {
+ profile.uid = this._nextSnapshotId++;
+ var title = WebInspector.UIString("Snapshot %d", profile.uid);
+ profile.title = title;
+ profile.sidebarElement.mainTitle = title;
+ profile._finishLoad();
+ this._profileSamples = null;
+ this._profileBeingRecorded = null;
+ WebInspector.panels.profiles.showProfile(profile);
+ profile.existingView()._refreshView();
+ }
+
+ HeapProfilerAgent.stopTrackingHeapObjects(true, didTakeHeapSnapshot.bind(this));
this._recording = false;
this.dispatchEventToListeners(WebInspector.TrackingHeapSnapshotProfileType.TrackingStopped);
},
@@ -1213,36 +1257,29 @@ WebInspector.HeapProfileHeader.prototype = {
callback(this._snapshotProxy);
return;
}
+ this._loadCallbacks.push(callback);
+ },
+ _prepareToLoad: function()
+ {
+ console.assert(!this._receiver, "Already loading");
this._numberOfChunks = 0;
- if (!this._receiver) {
- this._setupWorker();
- this._transferHandler = new WebInspector.BackendSnapshotLoader(this);
- this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026");
- this.sidebarElement.wait = true;
- this._transferSnapshot();
- }
- console.assert(this._receiver);
- this._loadCallbacks.push(callback);
+ this._setupWorker();
+ this._transferHandler = new WebInspector.BackendSnapshotLoader(this);
+ this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026");
+ this.sidebarElement.wait = true;
},
- _transferSnapshot: function()
+ _finishLoad: function()
{
- /**
- * @this {WebInspector.HeapProfileHeader}
- */
- function finishTransfer()
- {
- if (this._transferHandler) {
- this._transferHandler.finishTransfer();
- this._totalNumberOfChunks = this._transferHandler._totalNumberOfChunks;
- }
- if (this._bufferedWriter) {
- this._bufferedWriter.close(this._didWriteToTempFile.bind(this));
- this._bufferedWriter = null;
- }
+ if (this._transferHandler) {
+ this._transferHandler.finishTransfer();
+ this._totalNumberOfChunks = this._transferHandler._totalNumberOfChunks;
+ }
+ if (this._bufferedWriter) {
+ this._bufferedWriter.close(this._didWriteToTempFile.bind(this));
+ this._bufferedWriter = null;
}
- HeapProfilerAgent.getHeapSnapshot(this.uid, finishTransfer.bind(this));
},
_didWriteToTempFile: function(tempFile)
« no previous file with comments | « Source/core/inspector/InspectorHeapProfilerAgent.cpp ('k') | Source/devtools/protocol.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698