summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskStepDispatcher.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskStepDispatcher.cpp')
-rw-r--r--chromium/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskStepDispatcher.cpp58
1 files changed, 58 insertions, 0 deletions
diff --git a/chromium/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskStepDispatcher.cpp b/chromium/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskStepDispatcher.cpp
new file mode 100644
index 00000000000..bfddfe9aa7d
--- /dev/null
+++ b/chromium/third_party/WebKit/Source/core/dom/custom/CustomElementMicrotaskStepDispatcher.cpp
@@ -0,0 +1,58 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+#include "core/dom/custom/CustomElementMicrotaskStepDispatcher.h"
+
+#include "core/dom/custom/CustomElementMicrotaskImportStep.h"
+#include "core/html/imports/HTMLImportLoader.h"
+
+namespace WebCore {
+
+CustomElementMicrotaskStepDispatcher::CustomElementMicrotaskStepDispatcher()
+ : m_syncQueue(CustomElementSyncMicrotaskQueue::create())
+ , m_asyncQueue(CustomElementAsyncImportMicrotaskQueue::create())
+{
+}
+
+void CustomElementMicrotaskStepDispatcher::enqueue(HTMLImportLoader* parentLoader, PassOwnPtrWillBeRawPtr<CustomElementMicrotaskStep> step)
+{
+ if (parentLoader)
+ parentLoader->microtaskQueue()->enqueue(step);
+ else
+ m_syncQueue->enqueue(step);
+}
+
+void CustomElementMicrotaskStepDispatcher::enqueue(HTMLImportLoader* parentLoader, PassOwnPtrWillBeRawPtr<CustomElementMicrotaskImportStep> step, bool importIsSync)
+{
+ if (importIsSync)
+ enqueue(parentLoader, PassOwnPtrWillBeRawPtr<CustomElementMicrotaskStep>(step));
+ else
+ m_asyncQueue->enqueue(step);
+}
+
+void CustomElementMicrotaskStepDispatcher::dispatch()
+{
+ m_syncQueue->dispatch();
+ if (m_syncQueue->isEmpty())
+ m_asyncQueue->dispatch();
+}
+
+void CustomElementMicrotaskStepDispatcher::trace(Visitor* visitor)
+{
+ visitor->trace(m_syncQueue);
+ visitor->trace(m_asyncQueue);
+}
+
+#if !defined(NDEBUG)
+void CustomElementMicrotaskStepDispatcher::show(unsigned indent)
+{
+ fprintf(stderr, "%*sSync:\n", indent, "");
+ m_syncQueue->show(indent + 1);
+ fprintf(stderr, "%*sAsync:\n", indent, "");
+ m_asyncQueue->show(indent + 1);
+}
+#endif
+
+} // namespace WebCore