Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / core / dom / custom / CustomElementMicrotaskRunQueue.h
blob2ebdd17872eef115bed426728fd79ed814045e37
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 CustomElementMicrotaskRunQueue_h
6 #define CustomElementMicrotaskRunQueue_h
8 #include "platform/heap/Handle.h"
9 #include "wtf/RefCounted.h"
10 #include "wtf/WeakPtr.h"
12 namespace blink {
14 class CustomElementSyncMicrotaskQueue;
15 class CustomElementAsyncImportMicrotaskQueue;
16 class CustomElementMicrotaskStep;
17 class HTMLImportLoader;
19 class CustomElementMicrotaskRunQueue : public RefCountedWillBeGarbageCollectedFinalized<CustomElementMicrotaskRunQueue> {
20 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CustomElementMicrotaskRunQueue)
21 public:
22 static PassRefPtrWillBeRawPtr<CustomElementMicrotaskRunQueue> create() { return adoptRefWillBeNoop(new CustomElementMicrotaskRunQueue()); }
24 void enqueue(HTMLImportLoader* parentLoader, PassOwnPtrWillBeRawPtr<CustomElementMicrotaskStep>, bool importIsSync);
25 void requestDispatchIfNeeded();
26 bool isEmpty() const;
28 // Must be promptly finalized to prevent unsafe dispatching.
29 EAGERLY_FINALIZE();
30 DECLARE_TRACE();
32 private:
33 static void dispatchIfAlive(WeakPtr<CustomElementMicrotaskRunQueue> self);
35 CustomElementMicrotaskRunQueue();
37 void dispatch();
39 WeakPtrFactory<CustomElementMicrotaskRunQueue> m_weakFactory;
40 RefPtrWillBeMember<CustomElementSyncMicrotaskQueue> m_syncQueue;
41 RefPtrWillBeMember<CustomElementAsyncImportMicrotaskQueue> m_asyncQueue;
42 bool m_dispatchIsPending;
45 } // namespace blink
47 #endif // CustomElementMicrotaskRunQueue_h