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

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

Issue 242123005: Allow posting a Task to Microtasks (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: use WebThread::Tasl Created 6 years, 8 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
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/CustomElementMicrotaskDispatcher.h" 6 #include "core/dom/custom/CustomElementMicrotaskDispatcher.h"
7 7
8 #include "core/dom/Microtask.h" 8 #include "core/dom/Microtask.h"
9 #include "core/dom/custom/CustomElementCallbackDispatcher.h" 9 #include "core/dom/custom/CustomElementCallbackDispatcher.h"
10 #include "core/dom/custom/CustomElementCallbackQueue.h" 10 #include "core/dom/custom/CustomElementCallbackQueue.h"
11 #include "core/dom/custom/CustomElementMicrotaskImportStep.h" 11 #include "core/dom/custom/CustomElementMicrotaskImportStep.h"
12 #include "core/dom/custom/CustomElementScheduler.h" 12 #include "core/dom/custom/CustomElementScheduler.h"
13 #include "core/html/imports/HTMLImport.h" 13 #include "core/html/imports/HTMLImport.h"
14 #include "platform/Task.h"
14 #include "wtf/MainThread.h" 15 #include "wtf/MainThread.h"
15 16
16 namespace WebCore { 17 namespace WebCore {
17 18
18 static const CustomElementCallbackQueue::ElementQueueId kMicrotaskQueueId = 0; 19 static const CustomElementCallbackQueue::ElementQueueId kMicrotaskQueueId = 0;
19 20
20 CustomElementMicrotaskDispatcher::CustomElementMicrotaskDispatcher() 21 CustomElementMicrotaskDispatcher::CustomElementMicrotaskDispatcher()
21 : m_hasScheduledMicrotask(false) 22 : m_hasScheduledMicrotask(false)
22 , m_phase(Quiescent) 23 , m_phase(Quiescent)
23 { 24 {
(...skipping 25 matching lines...) Expand all
49 50
50 void CustomElementMicrotaskDispatcher::importDidFinish(CustomElementMicrotaskImp ortStep* step) 51 void CustomElementMicrotaskDispatcher::importDidFinish(CustomElementMicrotaskImp ortStep* step)
51 { 52 {
52 ASSERT(m_phase == Quiescent || m_phase == DispatchingCallbacks); 53 ASSERT(m_phase == Quiescent || m_phase == DispatchingCallbacks);
53 ensureMicrotaskScheduled(); 54 ensureMicrotaskScheduled();
54 } 55 }
55 56
56 void CustomElementMicrotaskDispatcher::ensureMicrotaskScheduled() 57 void CustomElementMicrotaskDispatcher::ensureMicrotaskScheduled()
57 { 58 {
58 if (!m_hasScheduledMicrotask) { 59 if (!m_hasScheduledMicrotask) {
59 Microtask::enqueueMicrotask(&dispatch); 60 Microtask::enqueueMicrotask(new Task(WTF::bind(&dispatch)));
60 m_hasScheduledMicrotask = true; 61 m_hasScheduledMicrotask = true;
61 } 62 }
62 } 63 }
63 64
64 void CustomElementMicrotaskDispatcher::dispatch() 65 void CustomElementMicrotaskDispatcher::dispatch()
65 { 66 {
66 instance().doDispatch(); 67 instance().doDispatch();
67 } 68 }
68 69
69 void CustomElementMicrotaskDispatcher::doDispatch() 70 void CustomElementMicrotaskDispatcher::doDispatch()
(...skipping 17 matching lines...) Expand all
87 CustomElementCallbackDispatcher::CallbackDeliveryScope scope; 88 CustomElementCallbackDispatcher::CallbackDeliveryScope scope;
88 (*it)->processInElementQueue(kMicrotaskQueueId); 89 (*it)->processInElementQueue(kMicrotaskQueueId);
89 } 90 }
90 91
91 m_elements.clear(); 92 m_elements.clear();
92 CustomElementScheduler::microtaskDispatcherDidFinish(); 93 CustomElementScheduler::microtaskDispatcherDidFinish();
93 m_phase = Quiescent; 94 m_phase = Quiescent;
94 } 95 }
95 96
96 } // namespace WebCore 97 } // namespace WebCore
OLDNEW
« Source/core/dom/MutationObserver.cpp ('K') | « Source/core/dom/MutationObserver.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698