Index: Source/core/dom/custom/CustomElementPendingMicrotaskSet.cpp |
diff --git a/Source/core/dom/custom/CustomElementPendingMicrotaskSet.cpp b/Source/core/dom/custom/CustomElementPendingMicrotaskSet.cpp |
new file mode 100644 |
index 0000000000000000000000000000000000000000..cbde0222f0da71ddf36a3cdb7f3180e07bcbfddf |
--- /dev/null |
+++ b/Source/core/dom/custom/CustomElementPendingMicrotaskSet.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/CustomElementPendingMicrotaskSet.h" |
+ |
+#include "core/dom/custom/CustomElementMicrotaskImportStep.h" |
+#include "core/html/imports/HTMLImportLoader.h" |
+ |
+namespace WebCore { |
+ |
+CustomElementPendingMicrotaskSet::CustomElementPendingMicrotaskSet() |
+ : m_syncQueue(CustomElementSyncMicrotaskQueue::create()) |
+ , m_asyncQueue(CustomElementAsyncImportMicrotaskQueue::create()) |
+{ |
+} |
+ |
+void CustomElementPendingMicrotaskSet::enqueue(HTMLImportLoader* parentLoader, PassOwnPtrWillBeRawPtr<CustomElementMicrotaskStep> step) |
+{ |
+ if (parentLoader) |
+ parentLoader->microtaskQueue()->enqueue(step); |
+ else |
+ m_syncQueue->enqueue(step); |
+} |
+ |
+void CustomElementPendingMicrotaskSet::enqueue(HTMLImportLoader* parentLoader, PassOwnPtrWillBeRawPtr<CustomElementMicrotaskImportStep> step, bool importIsSync) |
+{ |
+ if (importIsSync) |
+ enqueue(parentLoader, PassOwnPtrWillBeRawPtr<CustomElementMicrotaskStep>(step)); |
+ else |
+ m_asyncQueue->enqueue(step); |
+} |
+ |
+void CustomElementPendingMicrotaskSet::dispatch() |
+{ |
+ m_syncQueue->dispatch(); |
+ if (m_syncQueue->isEmpty()) |
+ m_asyncQueue->dispatch(); |
+} |
+ |
+void CustomElementPendingMicrotaskSet::trace(Visitor* visitor) |
+{ |
+ visitor->trace(m_syncQueue); |
+ visitor->trace(m_asyncQueue); |
+} |
+ |
+#if !defined(NDEBUG) |
+void CustomElementPendingMicrotaskSet::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 |