| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CustomElementMicrotaskDispatcher_h | 5 #ifndef CustomElementMicrotaskDispatcher_h |
| 6 #define CustomElementMicrotaskDispatcher_h | 6 #define CustomElementMicrotaskDispatcher_h |
| 7 | 7 |
| 8 #include "core/dom/custom/CustomElementMicrotaskQueue.h" | 8 #include "core/dom/custom/CustomElementMicrotaskQueue.h" |
| 9 #include "wtf/Noncopyable.h" | 9 #include "wtf/Noncopyable.h" |
| 10 #include "wtf/PassOwnPtr.h" | 10 #include "wtf/PassOwnPtr.h" |
| 11 #include "wtf/Vector.h" | 11 #include "wtf/Vector.h" |
| 12 | 12 |
| 13 namespace WebCore { | 13 namespace WebCore { |
| 14 | 14 |
| 15 class CustomElementCallbackQueue; | 15 class CustomElementCallbackQueue; |
| 16 class CustomElementMicrotaskImportStep; | 16 class CustomElementMicrotaskImportStep; |
| 17 class CustomElementMicrotaskStep; | 17 class CustomElementMicrotaskStep; |
| 18 class HTMLImport; | 18 class HTMLImportLoader; |
| 19 | 19 |
| 20 class CustomElementMicrotaskDispatcher { | 20 class CustomElementMicrotaskDispatcher { |
| 21 WTF_MAKE_NONCOPYABLE(CustomElementMicrotaskDispatcher); | 21 WTF_MAKE_NONCOPYABLE(CustomElementMicrotaskDispatcher); |
| 22 public: | 22 public: |
| 23 ~CustomElementMicrotaskDispatcher() { } | 23 ~CustomElementMicrotaskDispatcher() { } |
| 24 | 24 |
| 25 static CustomElementMicrotaskDispatcher& instance(); | 25 static CustomElementMicrotaskDispatcher& instance(); |
| 26 | 26 |
| 27 void enqueue(HTMLImport*, PassOwnPtr<CustomElementMicrotaskStep>); | 27 void enqueue(HTMLImportLoader*, PassOwnPtr<CustomElementMicrotaskStep>); |
| 28 void enqueue(CustomElementCallbackQueue*); | 28 void enqueue(CustomElementCallbackQueue*); |
| 29 | 29 |
| 30 void importDidFinish(CustomElementMicrotaskImportStep*); | 30 void importDidFinish(CustomElementMicrotaskImportStep*); |
| 31 | 31 |
| 32 bool elementQueueIsEmpty() { return m_elements.isEmpty(); } | 32 bool elementQueueIsEmpty() { return m_elements.isEmpty(); } |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 CustomElementMicrotaskDispatcher(); | 35 CustomElementMicrotaskDispatcher(); |
| 36 | 36 |
| 37 void ensureMicrotaskScheduled(); | 37 void ensureMicrotaskScheduled(); |
| 38 | 38 |
| 39 static void dispatch(); | 39 static void dispatch(); |
| 40 void doDispatch(); | 40 void doDispatch(); |
| 41 | 41 |
| 42 bool m_hasScheduledMicrotask; | 42 bool m_hasScheduledMicrotask; |
| 43 enum { | 43 enum { |
| 44 Quiescent, | 44 Quiescent, |
| 45 Resolving, | 45 Resolving, |
| 46 DispatchingCallbacks | 46 DispatchingCallbacks |
| 47 } m_phase; | 47 } m_phase; |
| 48 | 48 |
| 49 CustomElementMicrotaskQueue m_resolutionAndImports; | 49 CustomElementMicrotaskQueue m_resolutionAndImports; |
| 50 Vector<CustomElementCallbackQueue*> m_elements; | 50 Vector<CustomElementCallbackQueue*> m_elements; |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 } | 53 } |
| 54 | 54 |
| 55 #endif // CustomElementMicrotaskDispatcher_h | 55 #endif // CustomElementMicrotaskDispatcher_h |
| OLD | NEW |