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

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: Created 7 years 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
Index: Source/devtools/front_end/HeapSnapshotView.js
diff --git a/Source/devtools/front_end/HeapSnapshotView.js b/Source/devtools/front_end/HeapSnapshotView.js
index 63ac183a4bf1a428a530951f8aabb2a98415755e..64e99c67aafc6dc043e0ae4033baaa77466161c5 100644
--- a/Source/devtools/front_end/HeapSnapshotView.js
+++ b/Source/devtools/front_end/HeapSnapshotView.js
@@ -781,8 +781,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");
},
@@ -802,11 +803,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";
@@ -888,9 +893,22 @@ 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;
+ callback();
+ }
+ HeapProfilerAgent.takeHeapSnapshot(true, didTakeHeapSnapshot.bind(this));
},
/**
@@ -923,23 +941,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();
},
/**
@@ -979,9 +1000,8 @@ WebInspector.HeapSnapshotProfileType.prototype = {
*/
WebInspector.TrackingHeapSnapshotProfileType = function(profilesPanel)
{
- WebInspector.ProfileType.call(this, WebInspector.TrackingHeapSnapshotProfileType.TypeId, WebInspector.UIString("Record Heap Allocations"));
+ WebInspector.HeapSnapshotProfileType.call(this, WebInspector.TrackingHeapSnapshotProfileType.TypeId, WebInspector.UIString("Record Heap Allocations"));
this._profilesPanel = profilesPanel;
- WebInspector.HeapProfilerDispatcher._dispatcher.register(this);
}
WebInspector.TrackingHeapSnapshotProfileType.TypeId = "HEAP-RECORD";
@@ -1092,7 +1112,30 @@ 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}
alph 2013/12/23 14:06:59 WebInspector.TrackingHeapSnapshotProfileType
+ */
+ function didTakeHeapSnapshot(error)
alph 2013/12/23 14:06:59 It seems to have a bunch of similar code to its fr
+ {
+ profile.uid = this._nextSnapshotId++;
+ var title = WebInspector.UIString("Snapshot %d", profile.uid);
+ profile.title = title;
+ profile.sidebarElement.mainTitle = title;
+ WebInspector.log("didTakeHeapSnapshot " + this._profileBeingRecorded);
alph 2013/12/23 14:06:59 is that intended?
+ profile._finishLoad();
+ this._profileSamples = null;
+ this._profileBeingRecorded = null;
+ WebInspector.panels.profiles._showProfile(profile);
alph 2013/12/23 14:06:59 Event broadcasting would look more elegant here. w
+ profile.existingView()._refreshView();
+ }
+
+ HeapProfilerAgent.stopTrackingHeapObjects(true, didTakeHeapSnapshot.bind(this));
this._recording = false;
this.dispatchEventToListeners(WebInspector.TrackingHeapSnapshotProfileType.TrackingStopped);
},
@@ -1183,19 +1226,29 @@ WebInspector.HeapProfileHeader.prototype = {
return;
}
- 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();
- }
var loaderProxy = /** @type {?WebInspector.HeapSnapshotLoaderProxy} */ (this._receiver);
console.assert(loaderProxy);
loaderProxy.addConsumer(callback);
},
+ _prepareToLoad: function()
+ {
+ console.assert(!this._receiver, "Already loading");
+ this._numberOfChunks = 0;
+ this._setupWorker();
+ this._transferHandler = new WebInspector.BackendSnapshotLoader(this);
+ this.sidebarElement.subtitle = WebInspector.UIString("Loading\u2026");
+ this.sidebarElement.wait = true;
+ },
+
+ _finishLoad: function()
+ {
+ if (this._transferHandler) {
+ this._transferHandler.finishTransfer();
+ this._totalNumberOfChunks = this._transferHandler._totalNumberOfChunks;
+ }
+ },
+
_transferSnapshot: function()
{
/**

Powered by Google App Engine
This is Rietveld 408576698