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

Unified Diff: Source/core/html/parser/HTMLParserScheduler.cpp

Issue 876623002: Adds a CancellableTaskFactory and exposes postLoadingTasks to Blink (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 5 years, 11 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/html/parser/HTMLParserScheduler.h ('k') | Source/platform/blink_platform.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/html/parser/HTMLParserScheduler.cpp
diff --git a/Source/core/html/parser/HTMLParserScheduler.cpp b/Source/core/html/parser/HTMLParserScheduler.cpp
index 68797fcc39e0e387c22f2ce6961b2d62e68c4eed..c2d0eb3d56fcee74a3b84c99a99d888706dbe9c7 100644
--- a/Source/core/html/parser/HTMLParserScheduler.cpp
+++ b/Source/core/html/parser/HTMLParserScheduler.cpp
@@ -82,44 +82,38 @@ void SpeculationsPumpSession::addedElementTokens(size_t count)
HTMLParserScheduler::HTMLParserScheduler(HTMLDocumentParser* parser)
: m_parser(parser)
- , m_continueNextChunkTimer(this, &HTMLParserScheduler::continueNextChunkTimerFired)
+ , m_cancellableContinueParse(WTF::bind(&HTMLDocumentParser::resumeParsingAfterYield, m_parser))
, m_isSuspendedWithActiveTimer(false)
{
}
HTMLParserScheduler::~HTMLParserScheduler()
{
- m_continueNextChunkTimer.stop();
-}
-
-void HTMLParserScheduler::continueNextChunkTimerFired(Timer<HTMLParserScheduler>* timer)
-{
- ASSERT_UNUSED(timer, timer == &m_continueNextChunkTimer);
- m_parser->resumeParsingAfterYield();
}
void HTMLParserScheduler::scheduleForResume()
{
ASSERT(!m_isSuspendedWithActiveTimer);
- m_continueNextChunkTimer.startOneShot(0, FROM_HERE);
+ Scheduler::shared()->postLoadingTask(FROM_HERE, m_cancellableContinueParse.task());
}
void HTMLParserScheduler::suspend()
{
ASSERT(!m_isSuspendedWithActiveTimer);
- if (!m_continueNextChunkTimer.isActive())
+ if (!m_cancellableContinueParse.isPending())
return;
m_isSuspendedWithActiveTimer = true;
- m_continueNextChunkTimer.stop();
+ m_cancellableContinueParse.cancel();
}
void HTMLParserScheduler::resume()
{
- ASSERT(!m_continueNextChunkTimer.isActive());
+ ASSERT(!m_cancellableContinueParse.isPending());
if (!m_isSuspendedWithActiveTimer)
return;
m_isSuspendedWithActiveTimer = false;
- m_continueNextChunkTimer.startOneShot(0, FROM_HERE);
+
+ Scheduler::shared()->postLoadingTask(FROM_HERE, m_cancellableContinueParse.task());
}
inline bool HTMLParserScheduler::shouldYield(const SpeculationsPumpSession& session, bool startingScript) const
@@ -158,7 +152,7 @@ bool HTMLParserScheduler::yieldIfNeeded(const SpeculationsPumpSession& session,
void HTMLParserScheduler::forceResumeAfterYield()
{
- ASSERT(!m_continueNextChunkTimer.isActive());
+ ASSERT(!m_cancellableContinueParse.isPending());
m_isSuspendedWithActiveTimer = true;
}
« no previous file with comments | « Source/core/html/parser/HTMLParserScheduler.h ('k') | Source/platform/blink_platform.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698