Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / core / dom / custom / CustomElementMicrotaskDispatcher.h
blob6e362742dd72d4243b3ac9f505c6f7ec399299f0
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"
13 namespace blink {
15 class CustomElementCallbackQueue;
17 class CustomElementMicrotaskDispatcher final : public NoBaseWillBeGarbageCollected<CustomElementMicrotaskDispatcher> {
18 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(CustomElementMicrotaskDispatcher);
19 WTF_MAKE_NONCOPYABLE(CustomElementMicrotaskDispatcher);
20 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CustomElementMicrotaskDispatcher);
21 public:
22 static CustomElementMicrotaskDispatcher& instance();
24 void enqueue(CustomElementCallbackQueue*);
26 bool elementQueueIsEmpty() { return m_elements.isEmpty(); }
28 DECLARE_TRACE();
30 private:
31 CustomElementMicrotaskDispatcher();
33 void ensureMicrotaskScheduledForElementQueue();
34 void ensureMicrotaskScheduled();
36 static void dispatch();
37 void doDispatch();
39 bool m_hasScheduledMicrotask;
40 enum {
41 Quiescent,
42 Resolving,
43 DispatchingCallbacks
44 } m_phase;
46 WillBeHeapVector<RawPtrWillBeMember<CustomElementCallbackQueue>> m_elements;
49 } // namespace blink
51 #endif // CustomElementMicrotaskDispatcher_h