Title: [197826] trunk
Revision
197826
Author
[email protected]
Date
2016-03-08 18:06:45 -0800 (Tue, 08 Mar 2016)

Log Message

Web Inspector: Add Heap domain start/stop tracking commands
https://bugs.webkit.org/show_bug.cgi?id=155190

Reviewed by Brian Burg.

Source/_javascript_Core:

* inspector/agents/InspectorHeapAgent.cpp:
(Inspector::InspectorHeapAgent::willDestroyFrontendAndBackend):
(Inspector::InspectorHeapAgent::startTracking):
(Inspector::InspectorHeapAgent::stopTracking):
* inspector/agents/InspectorHeapAgent.h:
* inspector/protocol/Heap.json:

Source/WebInspectorUI:

* UserInterface/Protocol/HeapObserver.js:
(WebInspector.HeapObserver.prototype.trackingStart):
(WebInspector.HeapObserver.prototype.trackingComplete):
To be used when we have a HeapAllocationsInstrument and timeline.

LayoutTests:

* inspector/heap/tracking-expected.txt: Added.
* inspector/heap/tracking.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (197825 => 197826)


--- trunk/LayoutTests/ChangeLog	2016-03-09 02:05:13 UTC (rev 197825)
+++ trunk/LayoutTests/ChangeLog	2016-03-09 02:06:45 UTC (rev 197826)
@@ -1,5 +1,15 @@
 2016-03-08  Joseph Pecoraro  <[email protected]>
 
+        Web Inspector: Add Heap domain start/stop tracking commands
+        https://bugs.webkit.org/show_bug.cgi?id=155190
+
+        Reviewed by Brian Burg.
+
+        * inspector/heap/tracking-expected.txt: Added.
+        * inspector/heap/tracking.html: Added.
+
+2016-03-08  Joseph Pecoraro  <[email protected]>
+
         Web Inspector: Add a way to create a Heap Snapshot
         https://bugs.webkit.org/show_bug.cgi?id=155188
 

Added: trunk/LayoutTests/inspector/heap/tracking-expected.txt (0 => 197826)


--- trunk/LayoutTests/inspector/heap/tracking-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/heap/tracking-expected.txt	2016-03-09 02:06:45 UTC (rev 197826)
@@ -0,0 +1,12 @@
+Tests that Heap.startTracking and Heap.stopTracking trigger trackingStart and trackingComplete events with expected data.
+
+
+== Running test suite: Heap.startTracking and Heap.stopTracking
+-- Running test case: StartAndStopTrackingIncludeSnapshots
+Heap.trackingStart
+PASS: Should have a timestamp when starting.
+PASS: Should have snapshotData when starting.
+Heap.trackingComplete
+PASS: Should have a timestamp when stopping.
+PASS: Should have snapshotData when stopping.
+

Added: trunk/LayoutTests/inspector/heap/tracking.html (0 => 197826)


--- trunk/LayoutTests/inspector/heap/tracking.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/heap/tracking.html	2016-03-09 02:06:45 UTC (rev 197826)
@@ -0,0 +1,38 @@
+<!doctype html>
+<html>
+<head>
+<script src=""
+<script>
+function test()
+{
+    let suite = ProtocolTest.createAsyncSuite("Heap.startTracking and Heap.stopTracking");
+
+    suite.addTestCase({
+        name: "StartAndStopTrackingIncludeSnapshots",
+        test: function(resolve, reject) {
+            InspectorProtocol.awaitEvent({event: "Heap.trackingStart"}).then((messageObject) => {
+                ProtocolTest.log("Heap.trackingStart");
+                ProtocolTest.expectThat(typeof messageObject.params.timestamp === "number", "Should have a timestamp when starting.");
+                ProtocolTest.expectThat(typeof messageObject.params.snapshotData === "string", "Should have snapshotData when starting.");
+                InspectorProtocol.sendCommand("Heap.stopTracking", {});
+            });
+
+            InspectorProtocol.awaitEvent({event: "Heap.trackingComplete"}).then((messageObject) => {
+                ProtocolTest.log("Heap.trackingComplete");
+                ProtocolTest.expectThat(typeof messageObject.params.timestamp === "number", "Should have a timestamp when stopping.");
+                ProtocolTest.expectThat(typeof messageObject.params.snapshotData === "string", "Should have snapshotData when stopping.");
+                resolve();
+            });
+
+            InspectorProtocol.sendCommand("Heap.startTracking", {});
+        }
+    });
+
+    suite.runTestCasesAndFinish();
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Tests that Heap.startTracking and Heap.stopTracking trigger trackingStart and trackingComplete events with expected data.</p>
+</body>
+</html>

Modified: trunk/Source/_javascript_Core/ChangeLog (197825 => 197826)


--- trunk/Source/_javascript_Core/ChangeLog	2016-03-09 02:05:13 UTC (rev 197825)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-03-09 02:06:45 UTC (rev 197826)
@@ -1,5 +1,19 @@
 2016-03-08  Joseph Pecoraro  <[email protected]>
 
+        Web Inspector: Add Heap domain start/stop tracking commands
+        https://bugs.webkit.org/show_bug.cgi?id=155190
+
+        Reviewed by Brian Burg.
+
+        * inspector/agents/InspectorHeapAgent.cpp:
+        (Inspector::InspectorHeapAgent::willDestroyFrontendAndBackend):
+        (Inspector::InspectorHeapAgent::startTracking):
+        (Inspector::InspectorHeapAgent::stopTracking):
+        * inspector/agents/InspectorHeapAgent.h:
+        * inspector/protocol/Heap.json:
+
+2016-03-08  Joseph Pecoraro  <[email protected]>
+
         Web Inspector: Add a way to create a Heap Snapshot
         https://bugs.webkit.org/show_bug.cgi?id=155188
 

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorHeapAgent.cpp (197825 => 197826)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorHeapAgent.cpp	2016-03-09 02:05:13 UTC (rev 197825)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorHeapAgent.cpp	2016-03-09 02:06:45 UTC (rev 197826)
@@ -56,6 +56,7 @@
 void InspectorHeapAgent::willDestroyFrontendAndBackend(DisconnectReason)
 {
     ErrorString ignored;
+    stopTracking(ignored);
     disable(ignored);
 }
 
@@ -109,6 +110,34 @@
     });
 }
 
+void InspectorHeapAgent::startTracking(ErrorString& errorString)
+{
+    if (m_tracking)
+        return;
+
+    m_tracking = true;
+
+    double timestamp;
+    String snapshotData;
+    snapshot(errorString, &timestamp, &snapshotData);
+
+    m_frontendDispatcher->trackingStart(timestamp, snapshotData);
+}
+
+void InspectorHeapAgent::stopTracking(ErrorString& errorString)
+{
+    if (!m_tracking)
+        return;
+
+    m_tracking = false;
+
+    double timestamp;
+    String snapshotData;
+    snapshot(errorString, &timestamp, &snapshotData);
+
+    m_frontendDispatcher->trackingComplete(timestamp, snapshotData);
+}
+
 static Inspector::Protocol::Heap::GarbageCollection::Type protocolTypeForHeapOperation(HeapOperation operation)
 {
     switch (operation) {

Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorHeapAgent.h (197825 => 197826)


--- trunk/Source/_javascript_Core/inspector/agents/InspectorHeapAgent.h	2016-03-09 02:05:13 UTC (rev 197825)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorHeapAgent.h	2016-03-09 02:06:45 UTC (rev 197826)
@@ -52,6 +52,8 @@
     void disable(ErrorString&) override;
     void gc(ErrorString&) override;
     void snapshot(ErrorString&, double* timestamp, String* snapshotData) override;
+    void startTracking(ErrorString&) override;
+    void stopTracking(ErrorString&) override;
 
     // HeapObserver
     void willGarbageCollect() override;
@@ -65,6 +67,7 @@
     InspectorEnvironment& m_environment;
 
     bool m_enabled { false };
+    bool m_tracking { false };
     double m_gcStartTime { NAN };
 };
 

Modified: trunk/Source/_javascript_Core/inspector/protocol/Heap.json (197825 => 197826)


--- trunk/Source/_javascript_Core/inspector/protocol/Heap.json	2016-03-09 02:05:13 UTC (rev 197825)
+++ trunk/Source/_javascript_Core/inspector/protocol/Heap.json	2016-03-09 02:06:45 UTC (rev 197826)
@@ -38,6 +38,14 @@
                 { "name": "timestamp", "type": "number" },
                 { "name": "snapshotData", "$ref": "HeapSnapshotData" }
             ]
+        },
+        {
+            "name": "startTracking",
+            "description": "Start tracking heap changes. This will produce a `trackingStart` event."
+        },
+        {
+            "name": "stopTracking",
+            "description": "Stop tracking heap changes. This will produce a `trackingComplete` event."
         }
     ],
     "events": [
@@ -47,6 +55,22 @@
             "parameters": [
                 { "name": "collection", "type": "GarbageCollection" }
             ]
+        },
+        {
+            "name": "trackingStart",
+            "description": "Tracking started.",
+            "parameters": [
+                { "name": "timestamp", "type": "number" },
+                { "name": "snapshotData", "$ref": "HeapSnapshotData", "description": "Snapshot at the start of tracking." }
+            ]
+        },
+        {
+            "name": "trackingComplete",
+            "description": "Tracking stopped.",
+            "parameters": [
+                { "name": "timestamp", "type": "number" },
+                { "name": "snapshotData", "$ref": "HeapSnapshotData", "description": "Snapshot at the end of tracking." }
+            ]
         }
     ]
 }

Modified: trunk/Source/WebInspectorUI/ChangeLog (197825 => 197826)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-03-09 02:05:13 UTC (rev 197825)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-03-09 02:06:45 UTC (rev 197826)
@@ -1,5 +1,17 @@
 2016-03-08  Joseph Pecoraro  <[email protected]>
 
+        Web Inspector: Add Heap domain start/stop tracking commands
+        https://bugs.webkit.org/show_bug.cgi?id=155190
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Protocol/HeapObserver.js:
+        (WebInspector.HeapObserver.prototype.trackingStart):
+        (WebInspector.HeapObserver.prototype.trackingComplete):
+        To be used when we have a HeapAllocationsInstrument and timeline.
+
+2016-03-08  Joseph Pecoraro  <[email protected]>
+
         Web Inspector: Make debugging Test.html easier
         https://bugs.webkit.org/show_bug.cgi?id=155207
 

Modified: trunk/Source/WebInspectorUI/UserInterface/Protocol/HeapObserver.js (197825 => 197826)


--- trunk/Source/WebInspectorUI/UserInterface/Protocol/HeapObserver.js	2016-03-09 02:05:13 UTC (rev 197825)
+++ trunk/Source/WebInspectorUI/UserInterface/Protocol/HeapObserver.js	2016-03-09 02:06:45 UTC (rev 197826)
@@ -31,4 +31,18 @@
     {
         WebInspector.heapManager.garbageCollected(collection);
     }
+
+    trackingStart(timestamp, snapshotData)
+    {
+        let payload = JSON.parse(snapshotData);
+        let snapshot = WebInspector.HeapSnapshot.fromPayload(payload);
+        // FIXME: Heap Allocations Timeline.
+    }
+
+    trackingComplete(timestamp, snapshotData)
+    {
+        let payload = JSON.parse(snapshotData);
+        let snapshot = WebInspector.HeapSnapshot.fromPayload(payload);
+        // FIXME: Heap Allocations Timeline.
+    }
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to