Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: Source/core/dom/custom/CustomElementMicrotaskRunQueue.cpp

Issue 916403003: Make dispatchIfAlive ensure the life of its queue. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/custom/CustomElementMicrotaskQueueBase.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « Source/core/dom/custom/CustomElementMicrotaskQueueBase.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698