Web Inspector: We should have a way to capture heap snapshots programatically.
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Mar 2016 18:51:35 +0000 (18:51 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 29 Mar 2016 18:51:35 +0000 (18:51 +0000)
commit0ff42ac6a5e8989d1c77ccca629b2d427c92fbc6
treee12d6272811a8a88d4bd206de65487efd5b7ed3a
parent64f2f28535fa01fad3d25f630f040d639adcba68
Web Inspector: We should have a way to capture heap snapshots programatically.
https://bugs.webkit.org/show_bug.cgi?id=154407
<rdar://problem/24726292>

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2016-03-29
Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

* inspector/protocol/Console.json:
Add a new Console.heapSnapshot event for when a heap snapshot is taken.

* runtime/ConsolePrototype.cpp:
(JSC::ConsolePrototype::finishCreation):
(JSC::consoleProtoFuncProfile):
(JSC::consoleProtoFuncProfileEnd):
(JSC::consoleProtoFuncTakeHeapSnapshot):
* runtime/ConsoleClient.h:
Add the console.takeHeapSnapshot method and dispatch to the ConsoleClient.

* inspector/JSGlobalObjectConsoleClient.cpp:
(Inspector::JSGlobalObjectConsoleClient::takeHeapSnapshot):
* inspector/JSGlobalObjectConsoleClient.h:
Have the InspectorConsoleAgent handle this.

* inspector/JSGlobalObjectInspectorController.cpp:
(Inspector::JSGlobalObjectInspectorController::JSGlobalObjectInspectorController):
* inspector/agents/InspectorConsoleAgent.cpp:
(Inspector::InspectorConsoleAgent::InspectorConsoleAgent):
(Inspector::InspectorConsoleAgent::takeHeapSnapshot):
* inspector/agents/InspectorConsoleAgent.h:
* inspector/agents/JSGlobalObjectConsoleAgent.cpp:
(Inspector::JSGlobalObjectConsoleAgent::JSGlobalObjectConsoleAgent):
* inspector/agents/JSGlobalObjectConsoleAgent.h:
Give the ConsoleAgent a HeapAgent pointer so that it can have the HeapAgent
perform the snapshot building work like it normally does.

Source/WebCore:

Test: inspector/console/heapSnapshot.html

* page/PageConsoleClient.cpp:
(WebCore::PageConsoleClient::takeHeapSnapshot):
* page/PageConsoleClient.h:
Pass through to Inspector Instrumentation.

* inspector/InspectorConsoleInstrumentation.h:
(WebCore::InspectorInstrumentation::takeHeapSnapshot):
* inspector/InspectorInstrumentation.cpp:
(WebCore::InspectorInstrumentation::takeHeapSnapshotImpl):
* inspector/InspectorInstrumentation.h:
Pass through to InspectorConsoleAgent.

* inspector/InspectorController.cpp:
(WebCore::InspectorController::InspectorController):
* inspector/PageConsoleAgent.cpp:
(WebCore::PageConsoleAgent::PageConsoleAgent):
* inspector/PageConsoleAgent.h:
* inspector/WebConsoleAgent.cpp:
(WebCore::WebConsoleAgent::WebConsoleAgent):
* inspector/WebConsoleAgent.h:
* workers/WorkerConsoleClient.cpp:
(WebCore::WorkerConsoleClient::takeHeapSnapshot):
* workers/WorkerConsoleClient.h:
Provide a HeapAgent to the ConsoleAgent.

Source/WebInspectorUI:

* Localizations/en.lproj/localizedStrings.js:
* UserInterface/Protocol/ConsoleObserver.js:
(WebInspector.ConsoleObserver.prototype.heapSnapshot):
(WebInspector.ConsoleObserver):
Create a HeapSnapshot with an optional title and add to the timeline.

(WebInspector.HeapAllocationsTimelineDataGridNode):
* UserInterface/Views/TimelineTabContentView.js:
(WebInspector.TimelineTabContentView.displayNameForRecord):
Share code for snapshot display names which may now include a title.

* UserInterface/Proxies/HeapSnapshotProxy.js:
(WebInspector.HeapSnapshotProxy):
(WebInspector.HeapSnapshotProxy.deserialize):
(WebInspector.HeapSnapshotProxy.prototype.get title):
* UserInterface/Views/HeapAllocationsTimelineDataGridNode.js:
* UserInterface/Workers/HeapSnapshot/HeapSnapshot.js:
(HeapSnapshot):
(HeapSnapshot.prototype.serialize):
* UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js:
(HeapSnapshotWorker.prototype.createSnapshot):
Include an optional title in a HeapSnapshot.

LayoutTests:

* inspector/console/heapSnapshot-expected.txt: Added.
* inspector/console/heapSnapshot.html: Added.
Test that we get expected data and events after calling
console.takeHeapSnapshot when the inspector is open.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198786 268f45cc-cd09-0410-ab3c-d52691b4dbfc
35 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/console/heapSnapshot-expected.txt [new file with mode: 0644]
LayoutTests/inspector/console/heapSnapshot.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.cpp
Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h
Source/JavaScriptCore/inspector/JSGlobalObjectInspectorController.cpp
Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorConsoleAgent.h
Source/JavaScriptCore/inspector/agents/JSGlobalObjectConsoleAgent.cpp
Source/JavaScriptCore/inspector/agents/JSGlobalObjectConsoleAgent.h
Source/JavaScriptCore/inspector/protocol/Console.json
Source/JavaScriptCore/runtime/ConsoleClient.h
Source/JavaScriptCore/runtime/ConsolePrototype.cpp
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorConsoleInstrumentation.h
Source/WebCore/inspector/InspectorController.cpp
Source/WebCore/inspector/InspectorInstrumentation.cpp
Source/WebCore/inspector/InspectorInstrumentation.h
Source/WebCore/inspector/PageConsoleAgent.cpp
Source/WebCore/inspector/PageConsoleAgent.h
Source/WebCore/inspector/WebConsoleAgent.cpp
Source/WebCore/inspector/WebConsoleAgent.h
Source/WebCore/page/PageConsoleClient.cpp
Source/WebCore/page/PageConsoleClient.h
Source/WebCore/workers/WorkerConsoleClient.cpp
Source/WebCore/workers/WorkerConsoleClient.h
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Protocol/ConsoleObserver.js
Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotProxy.js
Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineDataGridNode.js
Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js
Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshot.js
Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js