Commit e28a736c authored by yurys@chromium.org's avatar yurys@chromium.org

Continue recording object allocation after navigation

Old profile is removed on HeapProfiler.resetProfiles message and a new one is added immediately to collect all object allocation events from the backend after navigation.

BUG=None

Review URL: https://codereview.chromium.org/172163005

git-svn-id: svn://svn.chromium.org/blink/trunk@168565 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 09b7776e
......@@ -45,6 +45,8 @@ typedef uint32_t SnapshotObjectId;
namespace HeapProfilerAgentState {
static const char heapProfilerEnabled[] = "heapProfilerEnabled";
static const char heapObjectsTrackingEnabled[] = "heapObjectsTrackingEnabled";
static const char allocationTrackingEnabled[] = "allocationTrackingEnabled";
}
class InspectorHeapProfilerAgent::HeapStatsUpdateTask {
......@@ -97,6 +99,8 @@ void InspectorHeapProfilerAgent::restore()
{
if (m_state->getBoolean(HeapProfilerAgentState::heapProfilerEnabled))
m_frontend->resetProfiles();
if (m_state->getBoolean(HeapProfilerAgentState::heapObjectsTrackingEnabled))
startTrackingHeapObjectsInternal(m_state->getBoolean(HeapProfilerAgentState::allocationTrackingEnabled));
}
void InspectorHeapProfilerAgent::collectGarbage(WebCore::ErrorString*)
......@@ -142,11 +146,10 @@ private:
void InspectorHeapProfilerAgent::startTrackingHeapObjects(ErrorString*, const bool* trackAllocations)
{
if (m_heapStatsUpdateTask)
return;
ScriptProfiler::startTrackingHeapObjects(trackAllocations && *trackAllocations);
m_heapStatsUpdateTask = adoptPtr(new HeapStatsUpdateTask(this));
m_heapStatsUpdateTask->startTimer();
m_state->setBoolean(HeapProfilerAgentState::heapObjectsTrackingEnabled, true);
bool allocationTrackingEnabled = trackAllocations && *trackAllocations;
m_state->setBoolean(HeapProfilerAgentState::allocationTrackingEnabled, allocationTrackingEnabled);
startTrackingHeapObjectsInternal(allocationTrackingEnabled);
}
void InspectorHeapProfilerAgent::requestHeapStatsUpdate()
......@@ -179,6 +182,15 @@ void InspectorHeapProfilerAgent::stopTrackingHeapObjects(ErrorString* error, con
stopTrackingHeapObjectsInternal();
}
void InspectorHeapProfilerAgent::startTrackingHeapObjectsInternal(bool trackAllocations)
{
if (m_heapStatsUpdateTask)
return;
ScriptProfiler::startTrackingHeapObjects(trackAllocations);
m_heapStatsUpdateTask = adoptPtr(new HeapStatsUpdateTask(this));
m_heapStatsUpdateTask->startTimer();
}
void InspectorHeapProfilerAgent::stopTrackingHeapObjectsInternal()
{
if (!m_heapStatsUpdateTask)
......@@ -186,6 +198,8 @@ void InspectorHeapProfilerAgent::stopTrackingHeapObjectsInternal()
ScriptProfiler::stopTrackingHeapObjects();
m_heapStatsUpdateTask->resetTimer();
m_heapStatsUpdateTask.clear();
m_state->setBoolean(HeapProfilerAgentState::heapObjectsTrackingEnabled, false);
m_state->setBoolean(HeapProfilerAgentState::allocationTrackingEnabled, false);
}
void InspectorHeapProfilerAgent::enable(ErrorString*)
......
......@@ -79,6 +79,7 @@ private:
void requestHeapStatsUpdate();
void pushHeapStatsUpdate(const uint32_t* const data, const int size);
void startTrackingHeapObjectsInternal(bool trackAllocations);
void stopTrackingHeapObjectsInternal();
InjectedScriptManager* m_injectedScriptManager;
......
......@@ -1005,6 +1005,12 @@ WebInspector.TrackingHeapSnapshotProfileType.prototype = {
{
if (this.profileBeingRecorded())
return;
this._addNewProfile();
HeapProfilerAgent.startTrackingHeapObjects(WebInspector.experimentsSettings.allocationProfiler.isEnabled());
},
_addNewProfile: function()
{
this._profileBeingRecorded = new WebInspector.HeapProfileHeader(this);
this._lastSeenIndex = -1;
this._profileSamples = {
......@@ -1018,7 +1024,6 @@ WebInspector.TrackingHeapSnapshotProfileType.prototype = {
this._recording = true;
this.addProfile(this._profileBeingRecorded);
this._profileBeingRecorded.updateStatus(WebInspector.UIString("Recording\u2026"));
HeapProfilerAgent.startTrackingHeapObjects(WebInspector.experimentsSettings.allocationProfiler.isEnabled());
this.dispatchEventToListeners(WebInspector.TrackingHeapSnapshotProfileType.TrackingStarted);
},
......@@ -1066,11 +1071,14 @@ WebInspector.TrackingHeapSnapshotProfileType.prototype = {
_reset: function()
{
var wasRecording = this._recording;
// Clear current profile to avoid stopping backend.
this._profileBeingRecorded = null;
WebInspector.HeapSnapshotProfileType.prototype._reset.call(this);
if (this._recording)
this._stopRecordingProfile();
this._profileSamples = null;
this._lastSeenIndex = -1;
if (wasRecording)
this._addNewProfile();
},
/**
......@@ -1158,6 +1166,7 @@ WebInspector.HeapProfileHeader.prototype = {
_finishLoad: function()
{
if (!this._wasDisposed)
this._receiver.close(function() {});
if (this._bufferedWriter) {
this._bufferedWriter.close(this._didWriteToTempFile.bind(this));
......@@ -1167,6 +1176,11 @@ WebInspector.HeapProfileHeader.prototype = {
_didWriteToTempFile: function(tempFile)
{
if (this._wasDisposed) {
if (tempFile)
tempFile.remove();
return;
}
this._tempFile = tempFile;
if (!tempFile)
this._failedToCreateTempFile = true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment