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

Unified Diff: Source/core/inspector/InspectorHeapProfilerAgent.cpp

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 | « LayoutTests/inspector/profiler/heap-snapshot-test.js ('k') | Source/devtools/front_end/HeapSnapshotView.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InspectorHeapProfilerAgent.cpp
diff --git a/Source/core/inspector/InspectorHeapProfilerAgent.cpp b/Source/core/inspector/InspectorHeapProfilerAgent.cpp
index c518ad8920194b23dff65798295914ec7c1e2fef..fafb081816ef94d261b88b206581b8de71c4158b 100644
--- a/Source/core/inspector/InspectorHeapProfilerAgent.cpp
+++ b/Source/core/inspector/InspectorHeapProfilerAgent.cpp
@@ -256,7 +256,7 @@ void InspectorHeapProfilerAgent::removeProfile(ErrorString*, int rawUid)
m_snapshots.remove(uid);
}
-void InspectorHeapProfilerAgent::takeHeapSnapshot(ErrorString*, const bool* reportProgress)
+void InspectorHeapProfilerAgent::takeHeapSnapshot(ErrorString* errorString, const bool* reportProgress)
{
class HeapSnapshotProgress FINAL : public ScriptProfiler::HeapSnapshotProgress {
public:
@@ -269,9 +269,14 @@ void InspectorHeapProfilerAgent::takeHeapSnapshot(ErrorString*, const bool* repo
virtual void Worked(int workDone) OVERRIDE
{
if (m_frontend)
- m_frontend->reportHeapSnapshotProgress(workDone, m_totalWork);
+ m_frontend->reportHeapSnapshotProgress(workDone, m_totalWork, 0);
+ }
+ virtual void Done() OVERRIDE
+ {
+ const bool finished = true;
+ if (m_frontend)
+ m_frontend->reportHeapSnapshotProgress(m_totalWork, m_totalWork, &finished);
}
- virtual void Done() OVERRIDE { }
virtual bool isCanceled() OVERRIDE { return false; }
private:
InspectorFrontend::HeapProfiler* m_frontend;
@@ -281,10 +286,26 @@ void InspectorHeapProfilerAgent::takeHeapSnapshot(ErrorString*, const bool* repo
String title = "Snapshot " + String::number(m_nextUserInitiatedHeapSnapshotNumber++);
HeapSnapshotProgress progress(reportProgress && *reportProgress ? m_frontend : 0);
RefPtr<ScriptHeapSnapshot> snapshot = ScriptProfiler::takeHeapSnapshot(title, &progress);
- if (snapshot) {
- m_snapshots.add(snapshot->uid(), snapshot);
- if (m_frontend)
- m_frontend->addProfileHeader(createSnapshotHeader(*snapshot));
+ if (!snapshot) {
+ *errorString = "Failed to take heap snapshot";
+ return;
+ }
+
+ class OutputStream : public ScriptHeapSnapshot::OutputStream {
+ public:
+ OutputStream(InspectorFrontend::HeapProfiler* frontend, unsigned uid)
+ : m_frontend(frontend), m_uid(uid) { }
+ void Write(const String& chunk) { m_frontend->addHeapSnapshotChunk(m_uid, chunk); }
+ void Close() { }
+ private:
+ InspectorFrontend::HeapProfiler* m_frontend;
+ int m_uid;
+ };
+
+ if (m_frontend) {
+ unsigned uid = static_cast<unsigned>(snapshot->uid());
+ OutputStream stream(m_frontend, uid);
+ snapshot->writeJSON(&stream);
}
}
« no previous file with comments | « LayoutTests/inspector/profiler/heap-snapshot-test.js ('k') | Source/devtools/front_end/HeapSnapshotView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698