Skip to content
Permalink
Browse files
Migrate Performance::resourceTimingBufferFullTimerFired to HTML event…
… loop

https://bugs.webkit.org/show_bug.cgi?id=229044

Patch by Alex Christensen <achristensen@webkit.org> 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:

Canonical link: https://commits.webkit.org/240480@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@280977 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Alex Christensen authored and webkit-commit-queue committed Aug 12, 2021
1 parent e3995c6 commit 5a8a506c71eb9350f4840a23d26152f81b205172
Showing 3 changed files with 28 additions and 15 deletions.
@@ -1,3 +1,21 @@
2021-08-12 Alex Christensen <achristensen@webkit.org>

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 <jer.noble@apple.com>

[macOS] Enter fullscreen animation interferes with auto-hiding menu bar
@@ -60,20 +60,13 @@ WTF_MAKE_ISO_ALLOCATED_IMPL(Performance);

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);
}

Performance::~Performance() = default;

void Performance::contextDestroyed()
{
m_resourceTimingBufferFullTimer.stop();
ContextDestructionObserver::contextDestroyed();
}

DOMHighResTimeStamp Performance::now() const
{
return nowInReducedResolutionSeconds().milliseconds();
@@ -263,10 +256,14 @@ void Performance::addResourceTiming(ResourceTiming&& resourceTiming)
}

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 @@ bool Performance::isResourceTimingBufferFull() const
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();
@@ -119,15 +119,13 @@ class Performance final : public RefCounted<Performance>, public ContextDestruct
private:
Performance(ScriptExecutionContext*, MonotonicTime timeOrigin);

void contextDestroyed() override;

EventTargetInterface eventTargetInterface() const final { return PerformanceEventTargetInterfaceType; }

void refEventTarget() final { ref(); }
void derefEventTarget() final { deref(); }

bool isResourceTimingBufferFull() const;
void resourceTimingBufferFullTimerFired();
void dispatchResourceTimingBufferFullEvent();

void queueEntry(PerformanceEntry&);
void scheduleTaskIfNeeded();
@@ -139,7 +137,6 @@ class Performance final : public RefCounted<Performance>, public ContextDestruct
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

0 comments on commit 5a8a506

Please sign in to comment.