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

Unified Diff: Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp

Issue 288323004: HTML Imports: Get rid of needsProcessOrStop() from dom/custom/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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
Index: Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp
diff --git a/Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp b/Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp
index ca716e61001b11c4b98e170b4aa435a6073a4d09..0046a008bcb1975e90975e82802d798cf43e1509 100644
--- a/Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp
+++ b/Source/core/dom/custom/CustomElementMicrotaskDispatcher.cpp
@@ -6,6 +6,7 @@
#include "core/dom/custom/CustomElementMicrotaskDispatcher.h"
#include "core/dom/Microtask.h"
+#include "core/dom/custom/CustomElementAsyncImportMicrotaskQueue.h"
#include "core/dom/custom/CustomElementCallbackDispatcher.h"
#include "core/dom/custom/CustomElementCallbackQueue.h"
#include "core/dom/custom/CustomElementMicrotaskImportStep.h"
@@ -22,6 +23,11 @@ CustomElementMicrotaskDispatcher::CustomElementMicrotaskDispatcher()
: m_hasScheduledMicrotask(false)
, m_phase(Quiescent)
, m_resolutionAndImports(CustomElementMicrotaskQueue::create())
+ , m_asyncImports(CustomElementAsyncImportMicrotaskQueue::create())
+{
+}
+
+CustomElementMicrotaskDispatcher::~CustomElementMicrotaskDispatcher()
{
}
@@ -33,14 +39,22 @@ CustomElementMicrotaskDispatcher& CustomElementMicrotaskDispatcher::instance()
void CustomElementMicrotaskDispatcher::enqueue(HTMLImportLoader* importLoader, PassOwnPtr<CustomElementMicrotaskStep> step)
{
- ASSERT(m_phase == Quiescent || m_phase == DispatchingCallbacks);
- ensureMicrotaskScheduled();
+ willOrDidEnqueueStep();
dominicc (has gone to gerrit) 2014/05/27 23:41:25 Thanks for fighting duplication.
if (importLoader)
importLoader->microtaskQueue()->enqueue(step);
else
m_resolutionAndImports->enqueue(step);
}
+void CustomElementMicrotaskDispatcher::enqueue(HTMLImportLoader* importLoader, PassOwnPtr<CustomElementMicrotaskImportStep> step)
+{
+ willOrDidEnqueueStep();
+ if (step->isSync())
dominicc (has gone to gerrit) 2014/05/27 23:41:25 Very neat; I love it.
+ enqueue(importLoader, PassOwnPtr<CustomElementMicrotaskStep>(step));
+ else
+ m_asyncImports->enqueue(step);
+}
+
void CustomElementMicrotaskDispatcher::enqueue(CustomElementCallbackQueue* queue)
{
ASSERT(m_phase == Quiescent || m_phase == Resolving);
@@ -51,6 +65,11 @@ void CustomElementMicrotaskDispatcher::enqueue(CustomElementCallbackQueue* queue
void CustomElementMicrotaskDispatcher::importDidFinish(CustomElementMicrotaskImportStep* step)
{
+ willOrDidEnqueueStep();
dominicc (has gone to gerrit) 2014/05/27 23:41:25 Think willOrDidEnqueueStep is mis-named, because i
Hajime Morrita 2014/05/28 00:41:37 Agreed. I just did't came up with any better name.
dominicc (has gone to gerrit) 2014/05/28 01:41:34 OK. Can you extract the two lines from enqueue(Cus
+}
+
+void CustomElementMicrotaskDispatcher::willOrDidEnqueueStep()
+{
ASSERT(m_phase == Quiescent || m_phase == DispatchingCallbacks);
ensureMicrotaskScheduled();
}
@@ -82,6 +101,8 @@ void CustomElementMicrotaskDispatcher::doDispatch()
m_phase = Resolving;
m_resolutionAndImports->dispatch();
+ if (m_resolutionAndImports->isEmpty())
+ m_asyncImports->dispatch();
m_phase = DispatchingCallbacks;
for (Vector<CustomElementCallbackQueue*>::iterator it = m_elements.begin();it != m_elements.end(); ++it) {
@@ -99,7 +120,11 @@ void CustomElementMicrotaskDispatcher::doDispatch()
void CustomElementMicrotaskDispatcher::show()
{
fprintf(stderr, "Dispatcher:\n");
- m_resolutionAndImports->show(1);
+ fprintf(stderr, " Sync:\n");
+ m_resolutionAndImports->show(3);
+ fprintf(stderr, " Async:\n");
+ m_asyncImports->show(3);
+
}
#endif

Powered by Google App Engine
This is Rietveld 408576698