Title: [280977] trunk/Source/WebCore
Revision
280977
Author
[email protected]
Date
2021-08-12 12:25:04 -0700 (Thu, 12 Aug 2021)

Log Message

Migrate Performance::resourceTimingBufferFullTimerFired to HTML event loop
https://bugs.webkit.org/show_bug.cgi?id=229044

Patch by Alex Christensen <[email protected]> on 2021-08-12
Reviewed by Geoff Garen.

Covered by existing tests.
There should be no change in behavior.

* page/Performance.cpp:
(WebCore::Performance::Performance):
(WebCore::Performance::addResourceTiming):
(WebCore::Performance::dispatchResourceTimingBufferFullEvent):
(WebCore::Performance::contextDestroyed): Deleted.
(WebCore::Performance::resourceTimingBufferFullTimerFired): Deleted.
* page/Performance.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (280976 => 280977)


--- trunk/Source/WebCore/ChangeLog	2021-08-12 19:16:04 UTC (rev 280976)
+++ trunk/Source/WebCore/ChangeLog	2021-08-12 19:25:04 UTC (rev 280977)
@@ -1,3 +1,21 @@
+2021-08-12  Alex Christensen  <[email protected]>
+
+        Migrate Performance::resourceTimingBufferFullTimerFired to HTML event loop
+        https://bugs.webkit.org/show_bug.cgi?id=229044
+
+        Reviewed by Geoff Garen.
+
+        Covered by existing tests.
+        There should be no change in behavior.
+
+        * page/Performance.cpp:
+        (WebCore::Performance::Performance):
+        (WebCore::Performance::addResourceTiming):
+        (WebCore::Performance::dispatchResourceTimingBufferFullEvent):
+        (WebCore::Performance::contextDestroyed): Deleted.
+        (WebCore::Performance::resourceTimingBufferFullTimerFired): Deleted.
+        * page/Performance.h:
+
 2021-08-12  Jer Noble  <[email protected]>
 
         [macOS] Enter fullscreen animation interferes with auto-hiding menu bar

Modified: trunk/Source/WebCore/page/Performance.cpp (280976 => 280977)


--- trunk/Source/WebCore/page/Performance.cpp	2021-08-12 19:16:04 UTC (rev 280976)
+++ trunk/Source/WebCore/page/Performance.cpp	2021-08-12 19:25:04 UTC (rev 280977)
@@ -60,7 +60,6 @@
 
 Performance::Performance(ScriptExecutionContext* context, MonotonicTime timeOrigin)
     : ContextDestructionObserver(context)
-    , m_resourceTimingBufferFullTimer(*this, &Performance::resourceTimingBufferFullTimerFired) // FIXME: Migrate this to the event loop as well.
     , m_timeOrigin(timeOrigin)
 {
     ASSERT(m_timeOrigin);
@@ -68,12 +67,6 @@
 
 Performance::~Performance() = default;
 
-void Performance::contextDestroyed()
-{
-    m_resourceTimingBufferFullTimer.stop();
-    ContextDestructionObserver::contextDestroyed();
-}
-
 DOMHighResTimeStamp Performance::now() const
 {
     return nowInReducedResolutionSeconds().milliseconds();
@@ -263,10 +256,14 @@
     }
 
     if (isResourceTimingBufferFull()) {
-        ASSERT(!m_resourceTimingBufferFullTimer.isActive());
         m_backupResourceTimingBuffer.append(WTFMove(entry));
         m_waitingForBackupBufferToBeProcessed = true;
-        m_resourceTimingBufferFullTimer.startOneShot(0_s);
+        auto* context = scriptExecutionContext();
+        if (!context)
+            return;
+        context->eventLoop().queueTask(TaskSource::PerformanceTimeline, [protectedThis = makeRef(*this)] {
+            protectedThis->dispatchResourceTimingBufferFullEvent();
+        });
         return;
     }
 
@@ -279,9 +276,10 @@
     return m_resourceTimingBuffer.size() >= m_resourceTimingBufferSize;
 }
 
-void Performance::resourceTimingBufferFullTimerFired()
+void Performance::dispatchResourceTimingBufferFullEvent()
 {
-    ASSERT(scriptExecutionContext());
+    if (!scriptExecutionContext())
+        return;
 
     while (!m_backupResourceTimingBuffer.isEmpty()) {
         auto beforeCount = m_backupResourceTimingBuffer.size();

Modified: trunk/Source/WebCore/page/Performance.h (280976 => 280977)


--- trunk/Source/WebCore/page/Performance.h	2021-08-12 19:16:04 UTC (rev 280976)
+++ trunk/Source/WebCore/page/Performance.h	2021-08-12 19:25:04 UTC (rev 280977)
@@ -119,8 +119,6 @@
 private:
     Performance(ScriptExecutionContext*, MonotonicTime timeOrigin);
 
-    void contextDestroyed() override;
-
     EventTargetInterface eventTargetInterface() const final { return PerformanceEventTargetInterfaceType; }
 
     void refEventTarget() final { ref(); }
@@ -127,7 +125,7 @@
     void derefEventTarget() final { deref(); }
 
     bool isResourceTimingBufferFull() const;
-    void resourceTimingBufferFullTimerFired();
+    void dispatchResourceTimingBufferFullEvent();
 
     void queueEntry(PerformanceEntry&);
     void scheduleTaskIfNeeded();
@@ -139,7 +137,6 @@
     Vector<RefPtr<PerformanceEntry>> m_resourceTimingBuffer;
     unsigned m_resourceTimingBufferSize { 150 };
 
-    Timer m_resourceTimingBufferFullTimer;
     Vector<RefPtr<PerformanceEntry>> m_backupResourceTimingBuffer;
 
     // https://w3c.github.io/resource-timing/#dfn-resource-timing-buffer-full-flag
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to