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. 4 5 #ifndef CustomElementMicrotaskDispatcher_h 6 #define CustomElementMicrotaskDispatcher_h 7 8 #include "platform/heap/Handle.h" 9 #include "wtf/Noncopyable.h" 10 #include "wtf/PassOwnPtr.h" 11 #include "wtf/Vector.h" 12 13 namespace blink { 14 15 class CustomElementCallbackQueue; 16 class CustomElementMicrotaskImportStep; 17 class CustomElementMicrotaskStep; 18 class Document; 19 class HTMLImportLoader; 20 21 class CustomElementMicrotaskDispatcher FINAL : public NoBaseWillBeGarbageCollected<CustomElementMicrotaskDispatcher> { 22 WTF_MAKE_NONCOPYABLE(CustomElementMicrotaskDispatcher); 23 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CustomElementMicrotaskDispatcher); 24 public: 25 static CustomElementMicrotaskDispatcher& instance(); 26 27 void enqueue(CustomElementCallbackQueue*); 28 29 bool elementQueueIsEmpty() { return m_elements.isEmpty(); } 30 31 void trace(Visitor*); 32 33 private: 34 CustomElementMicrotaskDispatcher(); 35 36 void ensureMicrotaskScheduledForElementQueue(); 37 void ensureMicrotaskScheduled(); 38 39 static void dispatch(); 40 void doDispatch(); 41 42 bool m_hasScheduledMicrotask; 43 enum { 44 Quiescent, 45 Resolving, 46 DispatchingCallbacks 47 } m_phase; 48 49 WillBeHeapVector<RawPtrWillBeMember<CustomElementCallbackQueue> > m_elements; 50 }; 51 52 } 53 54 #endif // CustomElementMicrotaskDispatcher_h 55