| 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 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" | 5 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" |
| 6 | 6 |
| 7 #include "core/dom/Microtask.h" | 7 #include "core/dom/Microtask.h" |
| 8 #include "core/dom/custom/CustomElementAsyncImportMicrotaskQueue.h" | 8 #include "core/dom/custom/CustomElementAsyncImportMicrotaskQueue.h" |
| 9 #include "core/dom/custom/CustomElementSyncMicrotaskQueue.h" | 9 #include "core/dom/custom/CustomElementSyncMicrotaskQueue.h" |
| 10 #include "core/html/imports/HTMLImportLoader.h" | 10 #include "core/html/imports/HTMLImportLoader.h" |
| 11 | 11 |
| 12 namespace blink { | 12 namespace blink { |
| 13 | 13 |
| 14 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CustomElementMicrotaskRunQueue) | |
| 15 | |
| 16 CustomElementMicrotaskRunQueue::CustomElementMicrotaskRunQueue() | 14 CustomElementMicrotaskRunQueue::CustomElementMicrotaskRunQueue() |
| 17 : m_syncQueue(CustomElementSyncMicrotaskQueue::create()) | 15 : m_syncQueue(CustomElementSyncMicrotaskQueue::create()) |
| 18 , m_asyncQueue(CustomElementAsyncImportMicrotaskQueue::create()) | 16 , m_asyncQueue(CustomElementAsyncImportMicrotaskQueue::create()) |
| 19 , m_dispatchIsPending(false) | 17 , m_dispatchIsPending(false) |
| 20 #if !ENABLE(OILPAN) | 18 #if !ENABLE(OILPAN) |
| 21 , m_weakFactory(this) | 19 , m_weakFactory(this) |
| 22 #endif | 20 #endif |
| 23 { | 21 { |
| 24 } | 22 } |
| 25 | 23 |
| 26 void CustomElementMicrotaskRunQueue::enqueue(HTMLImportLoader* parentLoader, Pas
sOwnPtrWillBeRawPtr<CustomElementMicrotaskStep> step, bool importIsSync) | 24 void CustomElementMicrotaskRunQueue::enqueue(HTMLImportLoader* parentLoader, Raw
Ptr<CustomElementMicrotaskStep> step, bool importIsSync) |
| 27 { | 25 { |
| 28 if (importIsSync) { | 26 if (importIsSync) { |
| 29 if (parentLoader) | 27 if (parentLoader) |
| 30 parentLoader->microtaskQueue()->enqueue(step); | 28 parentLoader->microtaskQueue()->enqueue(step); |
| 31 else | 29 else |
| 32 m_syncQueue->enqueue(step); | 30 m_syncQueue->enqueue(step); |
| 33 } else { | 31 } else { |
| 34 m_asyncQueue->enqueue(step); | 32 m_asyncQueue->enqueue(step); |
| 35 } | 33 } |
| 36 | 34 |
| 37 requestDispatchIfNeeded(); | 35 requestDispatchIfNeeded(); |
| 38 } | 36 } |
| 39 | 37 |
| 40 void CustomElementMicrotaskRunQueue::dispatchIfAlive(WeakPtrWillBeWeakPersistent
<CustomElementMicrotaskRunQueue> self) | 38 void CustomElementMicrotaskRunQueue::dispatchIfAlive(WeakPersistent<CustomElemen
tMicrotaskRunQueue> self) |
| 41 { | 39 { |
| 42 if (self.get()) { | 40 if (self.get()) { |
| 43 RefPtrWillBeRawPtr<CustomElementMicrotaskRunQueue> protect(self.get()); | 41 RawPtr<CustomElementMicrotaskRunQueue> protect(self.get()); |
| 44 self->dispatch(); | 42 self->dispatch(); |
| 45 } | 43 } |
| 46 } | 44 } |
| 47 | 45 |
| 48 void CustomElementMicrotaskRunQueue::requestDispatchIfNeeded() | 46 void CustomElementMicrotaskRunQueue::requestDispatchIfNeeded() |
| 49 { | 47 { |
| 50 if (m_dispatchIsPending || isEmpty()) | 48 if (m_dispatchIsPending || isEmpty()) |
| 51 return; | 49 return; |
| 52 #if ENABLE(OILPAN) | 50 #if ENABLE(OILPAN) |
| 53 Microtask::enqueueMicrotask(WTF::bind(&CustomElementMicrotaskRunQueue::dispa
tchIfAlive, WeakPersistent<CustomElementMicrotaskRunQueue>(this))); | 51 Microtask::enqueueMicrotask(WTF::bind(&CustomElementMicrotaskRunQueue::dispa
tchIfAlive, WeakPersistent<CustomElementMicrotaskRunQueue>(this))); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 70 if (m_syncQueue->isEmpty()) | 68 if (m_syncQueue->isEmpty()) |
| 71 m_asyncQueue->dispatch(); | 69 m_asyncQueue->dispatch(); |
| 72 } | 70 } |
| 73 | 71 |
| 74 bool CustomElementMicrotaskRunQueue::isEmpty() const | 72 bool CustomElementMicrotaskRunQueue::isEmpty() const |
| 75 { | 73 { |
| 76 return m_syncQueue->isEmpty() && m_asyncQueue->isEmpty(); | 74 return m_syncQueue->isEmpty() && m_asyncQueue->isEmpty(); |
| 77 } | 75 } |
| 78 | 76 |
| 79 } // namespace blink | 77 } // namespace blink |
| OLD | NEW |