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 "config.h" | 5 #include "config.h" |
6 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" | 6 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h" |
7 | 7 |
8 #include "core/dom/Microtask.h" | 8 #include "core/dom/Microtask.h" |
9 #include "core/dom/custom/CustomElementAsyncImportMicrotaskQueue.h" | 9 #include "core/dom/custom/CustomElementAsyncImportMicrotaskQueue.h" |
10 #include "core/dom/custom/CustomElementSyncMicrotaskQueue.h" | 10 #include "core/dom/custom/CustomElementSyncMicrotaskQueue.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 m_syncQueue->enqueue(step); | 33 m_syncQueue->enqueue(step); |
34 } else { | 34 } else { |
35 m_asyncQueue->enqueue(step); | 35 m_asyncQueue->enqueue(step); |
36 } | 36 } |
37 | 37 |
38 requestDispatchIfNeeded(); | 38 requestDispatchIfNeeded(); |
39 } | 39 } |
40 | 40 |
41 void CustomElementMicrotaskRunQueue::dispatchIfAlive(WeakPtr<CustomElementMicrot
askRunQueue> self) | 41 void CustomElementMicrotaskRunQueue::dispatchIfAlive(WeakPtr<CustomElementMicrot
askRunQueue> self) |
42 { | 42 { |
43 if (self.get()) | 43 if (self.get()) { |
| 44 RefPtrWillBeRawPtr<CustomElementMicrotaskRunQueue> protect(self.get()); |
44 self->dispatch(); | 45 self->dispatch(); |
| 46 } |
45 } | 47 } |
46 | 48 |
47 void CustomElementMicrotaskRunQueue::requestDispatchIfNeeded() | 49 void CustomElementMicrotaskRunQueue::requestDispatchIfNeeded() |
48 { | 50 { |
49 if (m_dispatchIsPending || isEmpty()) | 51 if (m_dispatchIsPending || isEmpty()) |
50 return; | 52 return; |
51 Microtask::enqueueMicrotask(WTF::bind(&CustomElementMicrotaskRunQueue::dispa
tchIfAlive, m_weakFactory.createWeakPtr())); | 53 Microtask::enqueueMicrotask(WTF::bind(&CustomElementMicrotaskRunQueue::dispa
tchIfAlive, m_weakFactory.createWeakPtr())); |
52 m_dispatchIsPending = true; | 54 m_dispatchIsPending = true; |
53 } | 55 } |
54 | 56 |
(...skipping 10 matching lines...) Expand all Loading... |
65 if (m_syncQueue->isEmpty()) | 67 if (m_syncQueue->isEmpty()) |
66 m_asyncQueue->dispatch(); | 68 m_asyncQueue->dispatch(); |
67 } | 69 } |
68 | 70 |
69 bool CustomElementMicrotaskRunQueue::isEmpty() const | 71 bool CustomElementMicrotaskRunQueue::isEmpty() const |
70 { | 72 { |
71 return m_syncQueue->isEmpty() && m_asyncQueue->isEmpty(); | 73 return m_syncQueue->isEmpty() && m_asyncQueue->isEmpty(); |
72 } | 74 } |
73 | 75 |
74 } // namespace blink | 76 } // namespace blink |
OLD | NEW |