Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(282)

Unified Diff: Source/core/css/FontFaceSet.cpp

Issue 27571005: Replace Timers used in ActiveDOMObject with AsyncMethodRunner (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/FontFaceSet.h ('k') | Source/core/xml/XMLHttpRequest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/FontFaceSet.cpp
diff --git a/Source/core/css/FontFaceSet.cpp b/Source/core/css/FontFaceSet.cpp
index b0c6b33d3933ee3b0ada816640d3269d6f1c8f9f..6dbbfee4906e2acb5d42e69141d704268e179c62 100644
--- a/Source/core/css/FontFaceSet.cpp
+++ b/Source/core/css/FontFaceSet.cpp
@@ -138,7 +138,7 @@ FontFaceSet::FontFaceSet(Document* document)
: ActiveDOMObject(document)
, m_loadingCount(0)
, m_shouldFireDoneEvent(false)
- , m_timer(this, &FontFaceSet::timerFired)
+ , m_asyncRunner(this, &FontFaceSet::handlePendingEventsAndPromises)
{
suspendIfNeeded();
}
@@ -169,6 +169,13 @@ AtomicString FontFaceSet::status() const
return (m_loadingCount > 0 || m_shouldFireDoneEvent) ? loading : loaded;
}
+void FontFaceSet::handlePendingEventsAndPromisesSoon()
+{
+ // setPendingActivity() is unnecessary because m_asyncRunner will be
+ // automatically stopped on destruction.
+ m_asyncRunner.runAsync();
+}
+
void FontFaceSet::didLayout()
{
Document* d = document();
@@ -178,11 +185,10 @@ void FontFaceSet::didLayout()
return;
if (m_loadingCount || (!m_shouldFireDoneEvent && m_readyResolvers.isEmpty()))
return;
- if (!m_timer.isActive())
- m_timer.startOneShot(0);
+ handlePendingEventsAndPromisesSoon();
}
-void FontFaceSet::timerFired(Timer<FontFaceSet>*)
+void FontFaceSet::handlePendingEventsAndPromises()
{
firePendingEvents();
resolvePendingLoadPromises();
@@ -192,8 +198,7 @@ void FontFaceSet::timerFired(Timer<FontFaceSet>*)
void FontFaceSet::scheduleEvent(PassRefPtr<Event> event)
{
m_pendingEvents.append(event);
- if (!m_timer.isActive())
- m_timer.startOneShot(0);
+ handlePendingEventsAndPromisesSoon();
}
void FontFaceSet::firePendingEvents()
@@ -207,11 +212,25 @@ void FontFaceSet::firePendingEvents()
dispatchEvent(pendingEvents[index].release());
}
+void FontFaceSet::suspend()
+{
+ m_asyncRunner.suspend();
+}
+
+void FontFaceSet::resume()
+{
+ m_asyncRunner.resume();
+}
+
+void FontFaceSet::stop()
+{
+ m_asyncRunner.stop();
+}
+
void FontFaceSet::scheduleResolve(LoadFontPromiseResolver* resolver)
{
m_pendingLoadResolvers.append(resolver);
- if (!m_timer.isActive())
- m_timer.startOneShot(0);
+ handlePendingEventsAndPromisesSoon();
}
void FontFaceSet::resolvePendingLoadPromises()
@@ -260,8 +279,7 @@ void FontFaceSet::queueDoneEvent(FontFace* fontFace)
if (!m_loadingCount) {
ASSERT(!m_shouldFireDoneEvent);
m_shouldFireDoneEvent = true;
- if (!m_timer.isActive())
- m_timer.startOneShot(0);
+ handlePendingEventsAndPromisesSoon();
}
}
@@ -270,8 +288,7 @@ ScriptPromise FontFaceSet::ready()
ScriptPromise promise = ScriptPromise::createPending(executionContext());
OwnPtr<FontsReadyPromiseResolver> resolver = FontsReadyPromiseResolver::create(promise, executionContext());
m_readyResolvers.append(resolver.release());
- if (!m_timer.isActive())
- m_timer.startOneShot(0);
+ handlePendingEventsAndPromisesSoon();
return promise;
}
« no previous file with comments | « Source/core/css/FontFaceSet.h ('k') | Source/core/xml/XMLHttpRequest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698