diff options
Diffstat (limited to 'WebCore/inspector/InspectorProfilerAgent.cpp')
-rw-r--r-- | WebCore/inspector/InspectorProfilerAgent.cpp | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/WebCore/inspector/InspectorProfilerAgent.cpp b/WebCore/inspector/InspectorProfilerAgent.cpp index 3f107d6..6d5364f 100644 --- a/WebCore/inspector/InspectorProfilerAgent.cpp +++ b/WebCore/inspector/InspectorProfilerAgent.cpp @@ -30,7 +30,7 @@ #include "config.h" #include "InspectorProfilerAgent.h" -#if ENABLE(JAVASCRIPT_DEBUGGER) +#if ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR) #include "Console.h" #include "InspectorController.h" @@ -156,6 +156,21 @@ void InspectorProfilerAgent::getProfileHeaders(RefPtr<InspectorArray>* headers) (*headers)->pushObject(createSnapshotHeader(*it->second)); } +namespace { + +class OutputStream : public ScriptHeapSnapshot::OutputStream { +public: + OutputStream(InspectorFrontend* frontend, unsigned long uid) + : m_frontend(frontend), m_uid(uid) { } + void Write(const String& chunk) { m_frontend->addHeapSnapshotChunk(m_uid, chunk); } + void Close() { m_frontend->finishHeapSnapshot(m_uid); } +private: + InspectorFrontend* m_frontend; + unsigned long m_uid; +}; + +} // namespace + void InspectorProfilerAgent::getProfile(const String& type, unsigned uid, RefPtr<InspectorObject>* profileObject) { if (type == CPUProfileType) { @@ -167,8 +182,12 @@ void InspectorProfilerAgent::getProfile(const String& type, unsigned uid, RefPtr } else if (type == HeapProfileType) { HeapSnapshotsMap::iterator it = m_snapshots.find(uid); if (it != m_snapshots.end()) { - *profileObject = createSnapshotHeader(*it->second); - (*profileObject)->setObject("head", it->second->buildInspectorObjectForHead()); + RefPtr<ScriptHeapSnapshot> snapshot = it->second; + *profileObject = createSnapshotHeader(*snapshot); + if (m_frontend) { + OutputStream stream(m_frontend, uid); + snapshot->writeJSON(&stream); + } } } } @@ -259,4 +278,4 @@ void InspectorProfilerAgent::toggleRecordButton(bool isProfiling) } // namespace WebCore -#endif // ENABLE(JAVASCRIPT_DEBUGGER) +#endif // ENABLE(JAVASCRIPT_DEBUGGER) && ENABLE(INSPECTOR) |