1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CustomElementMicrotaskDispatcher_h
6 #define CustomElementMicrotaskDispatcher_h
8 #include "platform/heap/Handle.h"
9 #include "wtf/Noncopyable.h"
10 #include "wtf/PassOwnPtr.h"
11 #include "wtf/Vector.h"
15 class CustomElementCallbackQueue;
17 class CustomElementMicrotaskDispatcher final : public NoBaseWillBeGarbageCollected<CustomElementMicrotaskDispatcher> {
18 WTF_MAKE_NONCOPYABLE(CustomElementMicrotaskDispatcher);
19 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CustomElementMicrotaskDispatcher);
21 static CustomElementMicrotaskDispatcher& instance();
23 void enqueue(CustomElementCallbackQueue*);
25 bool elementQueueIsEmpty() { return m_elements.isEmpty(); }
30 CustomElementMicrotaskDispatcher();
32 void ensureMicrotaskScheduledForElementQueue();
33 void ensureMicrotaskScheduled();
35 static void dispatch();
38 bool m_hasScheduledMicrotask;
45 WillBeHeapVector<RawPtrWillBeMember<CustomElementCallbackQueue> > m_elements;
50 #endif // CustomElementMicrotaskDispatcher_h