Title: [198786] trunk
Revision
198786
Author
[email protected]
Date
2016-03-29 11:51:35 -0700 (Tue, 29 Mar 2016)

Log Message

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 <[email protected]> on 2016-03-29
Reviewed by Timothy Hatcher.

Source/_javascript_Core:

* 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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (198785 => 198786)


--- trunk/LayoutTests/ChangeLog	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/LayoutTests/ChangeLog	2016-03-29 18:51:35 UTC (rev 198786)
@@ -1,3 +1,16 @@
+2016-03-29  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: We should have a way to capture heap snapshots programatically.
+        https://bugs.webkit.org/show_bug.cgi?id=154407
+        <rdar://problem/24726292>
+
+        Reviewed by Timothy Hatcher.
+
+        * 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.
+
 2016-03-29  Eric Carlson  <[email protected]>
 
         media/track/track-remove-track.html is flaky, crashing and failing

Added: trunk/LayoutTests/inspector/console/heapSnapshot-expected.txt (0 => 198786)


--- trunk/LayoutTests/inspector/console/heapSnapshot-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/heapSnapshot-expected.txt	2016-03-29 18:51:35 UTC (rev 198786)
@@ -0,0 +1,16 @@
+Test for the Console.heapSnapshot event triggered by console.takeHeapSnapshot.
+
+
+== Running test suite: Console.heapSnapshot
+-- Running test case: TriggerHeapSnapshotNoTitle
+Console.heapSnapshot
+PASS: Should have a timestamp.
+PASS: Should have snapshotData.
+PASS: Should not have a title.
+
+-- Running test case: TriggerHeapSnapshotWithTitle
+Console.heapSnapshot
+PASS: Should have a timestamp.
+PASS: Should have snapshotData.
+PASS: Should have expected title.
+

Added: trunk/LayoutTests/inspector/console/heapSnapshot.html (0 => 198786)


--- trunk/LayoutTests/inspector/console/heapSnapshot.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/console/heapSnapshot.html	2016-03-29 18:51:35 UTC (rev 198786)
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function triggerHeapSnapshotNoTitle() {
+    console.takeHeapSnapshot();
+}
+
+function triggerHeapSnapshotWithTitle() {
+    console.takeHeapSnapshot("Snapshot Title");
+}
+
+function test()
+{
+    let suite = ProtocolTest.createAsyncSuite("Console.heapSnapshot");
+
+    suite.addTestCase({
+        name: "TriggerHeapSnapshotNoTitle",
+        test: function(resolve, reject) {
+            InspectorProtocol.awaitEvent({event: "Console.heapSnapshot"}).then((messageObject) => {
+                ProtocolTest.log("Console.heapSnapshot");
+                ProtocolTest.expectThat(typeof messageObject.params.timestamp === "number", "Should have a timestamp.");
+                ProtocolTest.expectThat(typeof messageObject.params.snapshotData === "string", "Should have snapshotData.");
+                ProtocolTest.expectThat(!messageObject.params.title, "Should not have a title.");
+                resolve();
+            });
+
+            ProtocolTest.evaluateInPage("triggerHeapSnapshotNoTitle()");
+        }
+    });
+
+    suite.addTestCase({
+        name: "TriggerHeapSnapshotWithTitle",
+        test: function(resolve, reject) {
+            InspectorProtocol.awaitEvent({event: "Console.heapSnapshot"}).then((messageObject) => {
+                ProtocolTest.log("Console.heapSnapshot");
+                ProtocolTest.expectThat(typeof messageObject.params.timestamp === "number", "Should have a timestamp.");
+                ProtocolTest.expectThat(typeof messageObject.params.snapshotData === "string", "Should have snapshotData.");
+                ProtocolTest.expectThat(messageObject.params.title === "Snapshot Title", "Should have expected title.");
+                resolve();
+            });
+
+            ProtocolTest.evaluateInPage("triggerHeapSnapshotWithTitle()");
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Test for the Console.heapSnapshot event triggered by console.takeHeapSnapshot.</p>
+</body>
+</html>

Modified: trunk/Source/_javascript_Core/ChangeLog (198785 => 198786)


--- trunk/Source/_javascript_Core/ChangeLog	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-03-29 18:51:35 UTC (rev 198786)
@@ -1,3 +1,39 @@
+2016-03-29  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: We should have a way to capture heap snapshots programatically.
+        https://bugs.webkit.org/show_bug.cgi?id=154407
+        <rdar://problem/24726292>
+
+        Reviewed by Timothy Hatcher.
+
+        * 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.
+
 2016-03-29  Yusuke Suzuki  <[email protected]>
 
         REGRESSION(r192914): 10% regression on Sunspider's date-format-tofte

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.cpp (198785 => 198786)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.cpp	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.cpp	2016-03-29 18:51:35 UTC (rev 198786)
@@ -83,6 +83,11 @@
     // FIXME: support |console.profile| for JSContexts. <https://webkit.org/b/136466>
 }
 
+void JSGlobalObjectConsoleClient::takeHeapSnapshot(JSC::ExecState*, const String& title)
+{
+    m_consoleAgent->takeHeapSnapshot(title);
+}
+
 void JSGlobalObjectConsoleClient::time(ExecState*, const String& title)
 {
     m_consoleAgent->startTiming(title);

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.h (198785 => 198786)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.h	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectConsoleClient.h	2016-03-29 18:51:35 UTC (rev 198786)
@@ -46,6 +46,7 @@
     void count(JSC::ExecState*, RefPtr<ScriptArguments>&&) override;
     void profile(JSC::ExecState*, const String& title) override;
     void profileEnd(JSC::ExecState*, const String& title) override;
+    void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
     void time(JSC::ExecState*, const String& title) override;
     void timeEnd(JSC::ExecState*, const String& title) override;
     void timeStamp(JSC::ExecState*, RefPtr<ScriptArguments>&&) override;

Modified: trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp (198785 => 198786)


--- trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/_javascript_Core/inspector/JSGlobalObjectInspectorController.cpp	2016-03-29 18:51:35 UTC (rev 198786)
@@ -85,7 +85,8 @@
 
     auto inspectorAgent = std::make_unique<InspectorAgent>(context);
     auto runtimeAgent = std::make_unique<JSGlobalObjectRuntimeAgent>(context);
-    auto consoleAgent = std::make_unique<JSGlobalObjectConsoleAgent>(context);
+    auto heapAgent = std::make_unique<InspectorHeapAgent>(context);
+    auto consoleAgent = std::make_unique<JSGlobalObjectConsoleAgent>(context, heapAgent.get());
     auto debuggerAgent = std::make_unique<JSGlobalObjectDebuggerAgent>(context, consoleAgent.get());
 
     m_inspectorAgent = inspectorAgent.get();
@@ -97,7 +98,7 @@
     m_agents.append(WTFMove(runtimeAgent));
     m_agents.append(WTFMove(consoleAgent));
     m_agents.append(WTFMove(debuggerAgent));
-    m_agents.append(std::make_unique<InspectorHeapAgent>(context));
+    m_agents.append(WTFMove(heapAgent));
     m_agents.append(std::make_unique<InspectorScriptProfilerAgent>(context));
 
     m_executionStopwatch->start();

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.cpp (198785 => 198786)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.cpp	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.cpp	2016-03-29 18:51:35 UTC (rev 198786)
@@ -29,6 +29,7 @@
 #include "ConsoleMessage.h"
 #include "InjectedScriptManager.h"
 #include "InspectorFrontendRouter.h"
+#include "InspectorHeapAgent.h"
 #include "ScriptArguments.h"
 #include "ScriptCallFrame.h"
 #include "ScriptCallStack.h"
@@ -43,11 +44,12 @@
 static const unsigned maximumConsoleMessages = 100;
 static const int expireConsoleMessagesStep = 10;
 
-InspectorConsoleAgent::InspectorConsoleAgent(AgentContext& context)
+InspectorConsoleAgent::InspectorConsoleAgent(AgentContext& context, InspectorHeapAgent* heapAgent)
     : InspectorAgentBase(ASCIILiteral("Console"))
     , m_injectedScriptManager(context.injectedScriptManager)
     , m_frontendDispatcher(std::make_unique<ConsoleFrontendDispatcher>(context.frontendRouter))
     , m_backendDispatcher(ConsoleBackendDispatcher::create(context.backendDispatcher, this))
+    , m_heapAgent(heapAgent)
 {
 }
 
@@ -153,6 +155,19 @@
     addMessageToConsole(std::make_unique<ConsoleMessage>(MessageSource::ConsoleAPI, MessageType::Timing, MessageLevel::Debug, message, callStack));
 }
 
+void InspectorConsoleAgent::takeHeapSnapshot(const String& title)
+{
+    if (!m_injectedScriptManager.inspectorEnvironment().developerExtrasEnabled())
+        return;
+
+    ErrorString ignored;
+    double timestamp;
+    String snapshotData;
+    m_heapAgent->snapshot(ignored, &timestamp, &snapshotData);
+
+    m_frontendDispatcher->heapSnapshot(timestamp, snapshotData, title.isEmpty() ? nullptr : &title);
+}
+
 void InspectorConsoleAgent::count(JSC::ExecState* state, PassRefPtr<ScriptArguments> arguments)
 {
     RefPtr<ScriptCallStack> callStack(createScriptCallStackForConsole(state, ScriptCallStack::maxCallStackSizeToCapture));

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.h (198785 => 198786)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.h	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorConsoleAgent.h	2016-03-29 18:51:35 UTC (rev 198786)
@@ -44,6 +44,7 @@
 
 class ConsoleMessage;
 class InjectedScriptManager;
+class InspectorHeapAgent;
 class ScriptArguments;
 class ScriptCallStack;
 typedef String ErrorString;
@@ -52,7 +53,7 @@
     WTF_MAKE_NONCOPYABLE(InspectorConsoleAgent);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    InspectorConsoleAgent(AgentContext&);
+    InspectorConsoleAgent(AgentContext&, InspectorHeapAgent*);
     virtual ~InspectorConsoleAgent();
 
     void didCreateFrontendAndBackend(FrontendRouter*, BackendDispatcher*) override;
@@ -71,6 +72,7 @@
 
     void startTiming(const String& title);
     void stopTiming(const String& title, PassRefPtr<ScriptCallStack>);
+    void takeHeapSnapshot(const String& title);
     void count(JSC::ExecState*, PassRefPtr<ScriptArguments>);
 
 protected:
@@ -79,6 +81,7 @@
     InjectedScriptManager& m_injectedScriptManager;
     std::unique_ptr<ConsoleFrontendDispatcher> m_frontendDispatcher;
     RefPtr<ConsoleBackendDispatcher> m_backendDispatcher;
+    InspectorHeapAgent* m_heapAgent;
 
     ConsoleMessage* m_previousMessage { nullptr };
     Vector<std::unique_ptr<ConsoleMessage>> m_consoleMessages;

Modified: trunk/Source/_javascript_Core/inspector/agents/JSGlobalObjectConsoleAgent.cpp (198785 => 198786)


--- trunk/Source/_javascript_Core/inspector/agents/JSGlobalObjectConsoleAgent.cpp	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/_javascript_Core/inspector/agents/JSGlobalObjectConsoleAgent.cpp	2016-03-29 18:51:35 UTC (rev 198786)
@@ -28,8 +28,8 @@
 
 namespace Inspector {
 
-JSGlobalObjectConsoleAgent::JSGlobalObjectConsoleAgent(AgentContext& context)
-    : InspectorConsoleAgent(context)
+JSGlobalObjectConsoleAgent::JSGlobalObjectConsoleAgent(AgentContext& context, InspectorHeapAgent* heapAgent)
+    : InspectorConsoleAgent(context, heapAgent)
 {
 }
 

Modified: trunk/Source/_javascript_Core/inspector/agents/JSGlobalObjectConsoleAgent.h (198785 => 198786)


--- trunk/Source/_javascript_Core/inspector/agents/JSGlobalObjectConsoleAgent.h	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/_javascript_Core/inspector/agents/JSGlobalObjectConsoleAgent.h	2016-03-29 18:51:35 UTC (rev 198786)
@@ -35,7 +35,7 @@
     WTF_MAKE_NONCOPYABLE(JSGlobalObjectConsoleAgent);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    JSGlobalObjectConsoleAgent(AgentContext&);
+    JSGlobalObjectConsoleAgent(AgentContext&, InspectorHeapAgent*);
     virtual ~JSGlobalObjectConsoleAgent() { }
 
     // FIXME: XHRs and Nodes only makes sense debugging a Web context. Can this be moved to a different agent?

Modified: trunk/Source/_javascript_Core/inspector/protocol/Console.json (198785 => 198786)


--- trunk/Source/_javascript_Core/inspector/protocol/Console.json	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/_javascript_Core/inspector/protocol/Console.json	2016-03-29 18:51:35 UTC (rev 198786)
@@ -84,6 +84,15 @@
         {
             "name": "messagesCleared",
             "description": "Issued when console is cleared. This happens either upon <code>clearMessages</code> command or after page navigation."
+        },
+        {
+            "name": "heapSnapshot",
+            "description": "Issued from console.takeHeapSnapshot.",
+            "parameters": [
+                { "name": "timestamp", "type": "number" },
+                { "name": "snapshotData", "$ref": "Heap.HeapSnapshotData", "description": "Snapshot at the end of tracking." },
+                { "name": "title", "type": "string", "optional": true, "description": "Optional title provided to console.takeHeapSnapshot." }
+            ]
         }
     ]
 }

Modified: trunk/Source/_javascript_Core/runtime/ConsoleClient.h (198785 => 198786)


--- trunk/Source/_javascript_Core/runtime/ConsoleClient.h	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/_javascript_Core/runtime/ConsoleClient.h	2016-03-29 18:51:35 UTC (rev 198786)
@@ -59,6 +59,7 @@
     virtual void count(ExecState*, RefPtr<Inspector::ScriptArguments>&&) = 0;
     virtual void profile(ExecState*, const String& title) = 0;
     virtual void profileEnd(ExecState*, const String& title) = 0;
+    virtual void takeHeapSnapshot(ExecState*, const String& title) = 0;
     virtual void time(ExecState*, const String& title) = 0;
     virtual void timeEnd(ExecState*, const String& title) = 0;
     virtual void timeStamp(ExecState*, RefPtr<Inspector::ScriptArguments>&&) = 0;

Modified: trunk/Source/_javascript_Core/runtime/ConsolePrototype.cpp (198785 => 198786)


--- trunk/Source/_javascript_Core/runtime/ConsolePrototype.cpp	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/_javascript_Core/runtime/ConsolePrototype.cpp	2016-03-29 18:51:35 UTC (rev 198786)
@@ -52,6 +52,7 @@
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncCount(ExecState*);
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncProfile(ExecState*);
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncProfileEnd(ExecState*);
+static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTakeHeapSnapshot(ExecState*);
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTime(ExecState*);
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeEnd(ExecState*);
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTimeStamp(ExecState*);
@@ -86,6 +87,7 @@
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("time", consoleProtoFuncTime, None, 0);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("timeEnd", consoleProtoFuncTimeEnd, None, 0);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("timeStamp", consoleProtoFuncTimeStamp, None, 0);
+    JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("takeHeapSnapshot", consoleProtoFuncTakeHeapSnapshot, None, 0);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("group", consoleProtoFuncGroup, None, 0);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("groupCollapsed", consoleProtoFuncGroupCollapsed, None, 0);
     JSC_NATIVE_FUNCTION_WITHOUT_TRANSITION("groupEnd", consoleProtoFuncGroupEnd, None, 0);
@@ -258,7 +260,7 @@
         return JSValue::encode(jsUndefined());
 
     size_t argsCount = exec->argumentCount();
-    if (argsCount <= 0) {
+    if (!argsCount) {
         client->profile(exec, String());
         return JSValue::encode(jsUndefined());
     }
@@ -282,7 +284,7 @@
         return JSValue::encode(jsUndefined());
 
     size_t argsCount = exec->argumentCount();
-    if (argsCount <= 0) {
+    if (!argsCount) {
         client->profileEnd(exec, String());
         return JSValue::encode(jsUndefined());
     }
@@ -295,6 +297,30 @@
     return JSValue::encode(jsUndefined());
 }
 
+static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTakeHeapSnapshot(ExecState* exec)
+{
+    JSConsole* castedThis = jsDynamicCast<JSConsole*>(exec->thisValue());
+    if (!castedThis)
+        return throwVMTypeError(exec);
+    ASSERT_GC_OBJECT_INHERITS(castedThis, JSConsole::info());
+    ConsoleClient* client = castedThis->globalObject()->consoleClient();
+    if (!client)
+        return JSValue::encode(jsUndefined());
+
+    size_t argsCount = exec->argumentCount();
+    if (!argsCount) {
+        client->takeHeapSnapshot(exec, String());
+        return JSValue::encode(jsUndefined());
+    }
+
+    const String& title(valueToStringWithUndefinedOrNullCheck(exec, exec->argument(0)));
+    if (exec->hadException())
+        return JSValue::encode(jsUndefined());
+
+    client->takeHeapSnapshot(exec, title);
+    return JSValue::encode(jsUndefined());
+}
+
 static EncodedJSValue JSC_HOST_CALL consoleProtoFuncTime(ExecState* exec)
 {
     JSConsole* castedThis = jsDynamicCast<JSConsole*>(exec->thisValue());

Modified: trunk/Source/WebCore/ChangeLog (198785 => 198786)


--- trunk/Source/WebCore/ChangeLog	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebCore/ChangeLog	2016-03-29 18:51:35 UTC (rev 198786)
@@ -1,3 +1,38 @@
+2016-03-29  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: We should have a way to capture heap snapshots programatically.
+        https://bugs.webkit.org/show_bug.cgi?id=154407
+        <rdar://problem/24726292>
+
+        Reviewed by Timothy Hatcher.
+
+        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.
+
 2016-03-29  Zalan Bujtas  <[email protected]>
 
         REGRESSION (r196813): Missing plug-in placeholder is missing

Modified: trunk/Source/WebCore/inspector/InspectorConsoleInstrumentation.h (198785 => 198786)


--- trunk/Source/WebCore/inspector/InspectorConsoleInstrumentation.h	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebCore/inspector/InspectorConsoleInstrumentation.h	2016-03-29 18:51:35 UTC (rev 198786)
@@ -54,6 +54,13 @@
     consoleCountImpl(instrumentingAgentsForPage(page), state, WTFMove(arguments));
 }
 
+inline void InspectorInstrumentation::takeHeapSnapshot(Frame& frame, const String& title)
+{
+    FAST_RETURN_IF_NO_FRONTENDS(void());
+    if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))
+        takeHeapSnapshotImpl(*instrumentingAgents, title);
+}
+
 inline void InspectorInstrumentation::startConsoleTiming(Frame& frame, const String& title)
 {
     if (InstrumentingAgents* instrumentingAgents = instrumentingAgentsForFrame(frame))

Modified: trunk/Source/WebCore/inspector/InspectorController.cpp (198785 => 198786)


--- trunk/Source/WebCore/inspector/InspectorController.cpp	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebCore/inspector/InspectorController.cpp	2016-03-29 18:51:35 UTC (rev 198786)
@@ -162,7 +162,11 @@
     m_timelineAgent = timelineAgentPtr.get();
     m_agents.append(WTFMove(timelineAgentPtr));
 
-    auto consoleAgentPtr = std::make_unique<PageConsoleAgent>(pageContext, m_domAgent);
+    auto heapAgentPtr = std::make_unique<InspectorHeapAgent>(pageContext);
+    InspectorHeapAgent* heapAgent = heapAgentPtr.get();
+    m_agents.append(WTFMove(heapAgentPtr));
+
+    auto consoleAgentPtr = std::make_unique<PageConsoleAgent>(pageContext, heapAgent, m_domAgent);
     WebConsoleAgent* consoleAgent = consoleAgentPtr.get();
     m_instrumentingAgents->setWebConsoleAgent(consoleAgentPtr.get());
     m_agents.append(WTFMove(consoleAgentPtr));
@@ -172,7 +176,6 @@
     m_agents.append(WTFMove(debuggerAgentPtr));
 
     m_agents.append(std::make_unique<InspectorDOMDebuggerAgent>(pageContext, m_domAgent, debuggerAgent));
-    m_agents.append(std::make_unique<InspectorHeapAgent>(pageContext));
     m_agents.append(std::make_unique<InspectorScriptProfilerAgent>(pageContext));
     m_agents.append(std::make_unique<InspectorApplicationCacheAgent>(pageContext, pageAgent));
     m_agents.append(std::make_unique<InspectorLayerTreeAgent>(pageContext));

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp (198785 => 198786)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.cpp	2016-03-29 18:51:35 UTC (rev 198786)
@@ -855,6 +855,12 @@
         consoleAgent->count(state, arguments);
 }
 
+void InspectorInstrumentation::takeHeapSnapshotImpl(InstrumentingAgents& instrumentingAgents, const String& title)
+{
+    if (WebConsoleAgent* consoleAgent = instrumentingAgents.webConsoleAgent())
+        consoleAgent->takeHeapSnapshot(title);
+}
+
 void InspectorInstrumentation::startConsoleTimingImpl(InstrumentingAgents& instrumentingAgents, Frame& frame, const String& title)
 {
     if (InspectorTimelineAgent* timelineAgent = instrumentingAgents.inspectorTimelineAgent())

Modified: trunk/Source/WebCore/inspector/InspectorInstrumentation.h (198785 => 198786)


--- trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebCore/inspector/InspectorInstrumentation.h	2016-03-29 18:51:35 UTC (rev 198786)
@@ -209,6 +209,7 @@
     static void addMessageToConsole(WorkerGlobalScope*, std::unique_ptr<Inspector::ConsoleMessage>);
 
     static void consoleCount(Page&, JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&);
+    static void takeHeapSnapshot(Frame&, const String& title);
     static void startConsoleTiming(Frame&, const String& title);
     static void stopConsoleTiming(Frame&, const String& title, RefPtr<Inspector::ScriptCallStack>&&);
     static void consoleTimeStamp(Frame&, RefPtr<Inspector::ScriptArguments>&&);
@@ -382,6 +383,7 @@
     static void addMessageToConsoleImpl(InstrumentingAgents&, std::unique_ptr<Inspector::ConsoleMessage>);
 
     static void consoleCountImpl(InstrumentingAgents&, JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&);
+    static void takeHeapSnapshotImpl(InstrumentingAgents&, const String& title);
     static void startConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title);
     static void stopConsoleTimingImpl(InstrumentingAgents&, Frame&, const String& title, RefPtr<Inspector::ScriptCallStack>&&);
     static void consoleTimeStampImpl(InstrumentingAgents&, Frame&, RefPtr<Inspector::ScriptArguments>&&);

Modified: trunk/Source/WebCore/inspector/PageConsoleAgent.cpp (198785 => 198786)


--- trunk/Source/WebCore/inspector/PageConsoleAgent.cpp	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebCore/inspector/PageConsoleAgent.cpp	2016-03-29 18:51:35 UTC (rev 198786)
@@ -41,8 +41,8 @@
 
 namespace WebCore {
 
-PageConsoleAgent::PageConsoleAgent(WebAgentContext& context, InspectorDOMAgent* domAgent)
-    : WebConsoleAgent(context)
+PageConsoleAgent::PageConsoleAgent(WebAgentContext& context, InspectorHeapAgent* heapAgent, InspectorDOMAgent* domAgent)
+    : WebConsoleAgent(context, heapAgent)
     , m_inspectorDOMAgent(domAgent)
 {
 }

Modified: trunk/Source/WebCore/inspector/PageConsoleAgent.h (198785 => 198786)


--- trunk/Source/WebCore/inspector/PageConsoleAgent.h	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebCore/inspector/PageConsoleAgent.h	2016-03-29 18:51:35 UTC (rev 198786)
@@ -43,7 +43,7 @@
     WTF_MAKE_NONCOPYABLE(PageConsoleAgent);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    PageConsoleAgent(WebAgentContext&, InspectorDOMAgent*);
+    PageConsoleAgent(WebAgentContext&, Inspector::InspectorHeapAgent*, InspectorDOMAgent*);
     virtual ~PageConsoleAgent() { }
 
 private:

Modified: trunk/Source/WebCore/inspector/WebConsoleAgent.cpp (198785 => 198786)


--- trunk/Source/WebCore/inspector/WebConsoleAgent.cpp	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebCore/inspector/WebConsoleAgent.cpp	2016-03-29 18:51:35 UTC (rev 198786)
@@ -41,8 +41,8 @@
 
 namespace WebCore {
 
-WebConsoleAgent::WebConsoleAgent(AgentContext& context)
-    : InspectorConsoleAgent(context)
+WebConsoleAgent::WebConsoleAgent(AgentContext& context, InspectorHeapAgent* heapAgent)
+    : InspectorConsoleAgent(context, heapAgent)
 {
 }
 

Modified: trunk/Source/WebCore/inspector/WebConsoleAgent.h (198785 => 198786)


--- trunk/Source/WebCore/inspector/WebConsoleAgent.h	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebCore/inspector/WebConsoleAgent.h	2016-03-29 18:51:35 UTC (rev 198786)
@@ -39,7 +39,7 @@
     WTF_MAKE_NONCOPYABLE(WebConsoleAgent);
     WTF_MAKE_FAST_ALLOCATED;
 public:
-    WebConsoleAgent(Inspector::AgentContext&);
+    WebConsoleAgent(Inspector::AgentContext&, Inspector::InspectorHeapAgent*);
     virtual ~WebConsoleAgent() { }
 
     void setMonitoringXHREnabled(ErrorString&, bool enabled) final;

Modified: trunk/Source/WebCore/page/PageConsoleClient.cpp (198785 => 198786)


--- trunk/Source/WebCore/page/PageConsoleClient.cpp	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebCore/page/PageConsoleClient.cpp	2016-03-29 18:51:35 UTC (rev 198786)
@@ -195,6 +195,11 @@
         m_profiles.append(WTFMove(profile));
 }
 
+void PageConsoleClient::takeHeapSnapshot(JSC::ExecState*, const String& title)
+{
+    InspectorInstrumentation::takeHeapSnapshot(m_page.mainFrame(), title);
+}
+
 void PageConsoleClient::time(JSC::ExecState*, const String& title)
 {
     InspectorInstrumentation::startConsoleTiming(m_page.mainFrame(), title);

Modified: trunk/Source/WebCore/page/PageConsoleClient.h (198785 => 198786)


--- trunk/Source/WebCore/page/PageConsoleClient.h	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebCore/page/PageConsoleClient.h	2016-03-29 18:51:35 UTC (rev 198786)
@@ -69,6 +69,7 @@
     void count(JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) override;
     void profile(JSC::ExecState*, const String& title) override;
     void profileEnd(JSC::ExecState*, const String& title) override;
+    void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
     void time(JSC::ExecState*, const String& title) override;
     void timeEnd(JSC::ExecState*, const String& title) override;
     void timeStamp(JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) override;

Modified: trunk/Source/WebCore/workers/WorkerConsoleClient.cpp (198785 => 198786)


--- trunk/Source/WebCore/workers/WorkerConsoleClient.cpp	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebCore/workers/WorkerConsoleClient.cpp	2016-03-29 18:51:35 UTC (rev 198786)
@@ -56,6 +56,7 @@
 
 // FIXME: <https://webkit.org/b/127634> Web Inspector: support debugging web workers
 void WorkerConsoleClient::count(JSC::ExecState*, RefPtr<ScriptArguments>&&) { }
+void WorkerConsoleClient::takeHeapSnapshot(JSC::ExecState*, const String&) { }
 void WorkerConsoleClient::time(JSC::ExecState*, const String&) { }
 void WorkerConsoleClient::timeEnd(JSC::ExecState*, const String&) { }
 void WorkerConsoleClient::timeStamp(JSC::ExecState*, RefPtr<ScriptArguments>&&) { }

Modified: trunk/Source/WebCore/workers/WorkerConsoleClient.h (198785 => 198786)


--- trunk/Source/WebCore/workers/WorkerConsoleClient.h	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebCore/workers/WorkerConsoleClient.h	2016-03-29 18:51:35 UTC (rev 198786)
@@ -47,6 +47,7 @@
     void count(JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) override;
     void profile(JSC::ExecState*, const String& title) override;
     void profileEnd(JSC::ExecState*, const String& title) override;
+    void takeHeapSnapshot(JSC::ExecState*, const String& title) override;
     void time(JSC::ExecState*, const String& title) override;
     void timeEnd(JSC::ExecState*, const String& title) override;
     void timeStamp(JSC::ExecState*, RefPtr<Inspector::ScriptArguments>&&) override;

Modified: trunk/Source/WebInspectorUI/ChangeLog (198785 => 198786)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-03-29 18:51:35 UTC (rev 198786)
@@ -1,3 +1,34 @@
+2016-03-29  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: We should have a way to capture heap snapshots programatically.
+        https://bugs.webkit.org/show_bug.cgi?id=154407
+        <rdar://problem/24726292>
+
+        Reviewed by Timothy Hatcher.
+
+        * 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.
+
 2016-03-28  Joseph Pecoraro  <[email protected]>
 
         Web Inspector: Ensure maximum accuracy while profiling

Modified: trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js (198785 => 198786)


--- trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js	2016-03-29 18:51:35 UTC (rev 198786)
@@ -661,6 +661,7 @@
 localizedStrings["Small %s"] = "Small %s";
 localizedStrings["Small Icons"] = "Small Icons";
 localizedStrings["Snapshot %d"] = "Snapshot %d";
+localizedStrings["Snapshot %d \u2014 %s"] = "Snapshot %d \u2014 %s";
 localizedStrings["Snapshot Comparison (%d and %d)"] = "Snapshot Comparison (%d and %d)";
 localizedStrings["Snapshot List"] = "Snapshot List";
 localizedStrings["Socket"] = "Socket";

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/ConsoleObserver.js (198785 => 198786)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/ConsoleObserver.js	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/ConsoleObserver.js	2016-03-29 18:51:35 UTC (rev 198786)
@@ -52,4 +52,13 @@
     {
         WebInspector.logManager.messagesCleared();
     }
+
+    heapSnapshot(timestamp, snapshotStringData, title)
+    {
+        let workerProxy = WebInspector.HeapSnapshotWorkerProxy.singleton();
+        workerProxy.createSnapshot(snapshotStringData, title || null, ({objectId, snapshot: serializedSnapshot}) => {
+            let snapshot = WebInspector.HeapSnapshotProxy.deserialize(objectId, serializedSnapshot);
+            WebInspector.timelineManager.heapSnapshotAdded(timestamp, snapshot);
+        });
+    }
 };

Modified: trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotProxy.js (198785 => 198786)


--- trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotProxy.js	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebInspectorUI/UserInterface/Proxies/HeapSnapshotProxy.js	2016-03-29 18:51:35 UTC (rev 198786)
@@ -25,13 +25,14 @@
 
 WebInspector.HeapSnapshotProxy = class HeapSnapshotProxy extends WebInspector.Object
 {
-    constructor(snapshotObjectId, identifier, totalSize, totalObjectCount, categories)
+    constructor(snapshotObjectId, identifier, title, totalSize, totalObjectCount, categories)
     {
         super();
 
         this._proxyObjectId = snapshotObjectId;
 
         this._identifier = identifier;
+        this._title = title;
         this._totalSize = totalSize;
         this._totalObjectCount = totalObjectCount;
         this._categories = Map.fromObject(categories);
@@ -41,14 +42,15 @@
 
     static deserialize(objectId, serializedSnapshot)
     {
-        let {identifier, totalSize, totalObjectCount, categories} = serializedSnapshot;
-        return new WebInspector.HeapSnapshotProxy(objectId, identifier, totalSize, totalObjectCount, categories);
+        let {identifier, title, totalSize, totalObjectCount, categories} = serializedSnapshot;
+        return new WebInspector.HeapSnapshotProxy(objectId, identifier, title, totalSize, totalObjectCount, categories);
     }
 
     // Public
 
     get proxyObjectId() { return this._proxyObjectId; }
     get identifier() { return this._identifier; }
+    get title() { return this._title; }
     get totalSize() { return this._totalSize; }
     get totalObjectCount() { return this._totalObjectCount; }
     get categories() { return this._categories; }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineDataGridNode.js (198785 => 198786)


--- trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineDataGridNode.js	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/HeapAllocationsTimelineDataGridNode.js	2016-03-29 18:51:35 UTC (rev 198786)
@@ -33,7 +33,7 @@
         this._heapAllocationsView = heapAllocationsView;
 
         this._data = {
-            name: WebInspector.UIString("Snapshot %d").format(this._record.heapSnapshot.identifier),
+            name: WebInspector.TimelineTabContentView.displayNameForRecord(heapAllocationsTimelineRecord),
             timestamp: this._record.timestamp - zeroTime,
             size: this._record.heapSnapshot.totalSize,
         };

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js (198785 => 198786)


--- trunk/Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/TimelineTabContentView.js	2016-03-29 18:51:35 UTC (rev 198786)
@@ -251,6 +251,8 @@
         case WebInspector.TimelineRecord.Type.RenderingFrame:
             return WebInspector.UIString("Frame %d").format(timelineRecord.frameNumber);
         case WebInspector.TimelineRecord.Type.HeapAllocations:
+            if (timelineRecord.heapSnapshot.title)
+                return WebInspector.UIString("Snapshot %d \u2014 %s").format(timelineRecord.heapSnapshot.identifier, timelineRecord.heapSnapshot.title);
             return WebInspector.UIString("Snapshot %d").format(timelineRecord.heapSnapshot.identifier);
         case WebInspector.TimelineRecord.Type.Memory:
             // Not used. Fall through to error just in case.

Modified: trunk/Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshot.js (198785 => 198786)


--- trunk/Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshot.js	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshot.js	2016-03-29 18:51:35 UTC (rev 198786)
@@ -72,10 +72,11 @@
 
 HeapSnapshot = class HeapSnapshot
 {
-    constructor(objectId, snapshotDataString)
+    constructor(objectId, snapshotDataString, title = null)
     {
         this._identifier = nextSnapshotIdentifier++;
         this._objectId = objectId;
+        this._title = title;
 
         let json = JSON.parse(snapshotDataString);
         snapshotDataString = null;
@@ -309,6 +310,7 @@
     {
         return {
             identifier: this._identifier,
+            title: this._title,
             totalSize: this._totalSize,
             totalObjectCount: this._nodeCount - 1, // <root>.
             categories: this._categories,

Modified: trunk/Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js (198785 => 198786)


--- trunk/Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js	2016-03-29 18:33:35 UTC (rev 198785)
+++ trunk/Source/WebInspectorUI/UserInterface/Workers/HeapSnapshot/HeapSnapshotWorker.js	2016-03-29 18:51:35 UTC (rev 198786)
@@ -39,10 +39,10 @@
 
     // Actions
 
-    createSnapshot(snapshotString)
+    createSnapshot(snapshotString, title)
     {
         let objectId = this._nextObjectId++;
-        let snapshot = new HeapSnapshot(objectId, snapshotString);
+        let snapshot = new HeapSnapshot(objectId, snapshotString, title);
         this._objects.set(objectId, snapshot);
         return {objectId, snapshot: snapshot.serialize()};
     }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to