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

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

Issue 334253005: Custom Elements: Encapsulates Async and Sync Queues into one class. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated Created 6 years, 6 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/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

Powered by Google App Engine
This is Rietveld 408576698