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

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

Issue 1914923002: Rename all existing custom element classes as V0 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CustomElementV0 -> V0CustomElement Created 4 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "core/dom/custom/CustomElementMicrotaskRunQueue.h"
6
7 #include "bindings/core/v8/Microtask.h"
8 #include "core/dom/custom/CustomElementAsyncImportMicrotaskQueue.h"
9 #include "core/dom/custom/CustomElementSyncMicrotaskQueue.h"
10 #include "core/html/imports/HTMLImportLoader.h"
11
12 namespace blink {
13
14 CustomElementMicrotaskRunQueue::CustomElementMicrotaskRunQueue()
15 : m_syncQueue(CustomElementSyncMicrotaskQueue::create())
16 , m_asyncQueue(CustomElementAsyncImportMicrotaskQueue::create())
17 , m_dispatchIsPending(false)
18 {
19 }
20
21 void CustomElementMicrotaskRunQueue::enqueue(HTMLImportLoader* parentLoader, Cus tomElementMicrotaskStep* step, bool importIsSync)
22 {
23 if (importIsSync) {
24 if (parentLoader)
25 parentLoader->microtaskQueue()->enqueue(step);
26 else
27 m_syncQueue->enqueue(step);
28 } else {
29 m_asyncQueue->enqueue(step);
30 }
31
32 requestDispatchIfNeeded();
33 }
34
35 void CustomElementMicrotaskRunQueue::requestDispatchIfNeeded()
36 {
37 if (m_dispatchIsPending || isEmpty())
38 return;
39 Microtask::enqueueMicrotask(WTF::bind(&CustomElementMicrotaskRunQueue::dispa tch, WeakPersistentThisPointer<CustomElementMicrotaskRunQueue>(this)));
40 m_dispatchIsPending = true;
41 }
42
43 DEFINE_TRACE(CustomElementMicrotaskRunQueue)
44 {
45 visitor->trace(m_syncQueue);
46 visitor->trace(m_asyncQueue);
47 }
48
49 void CustomElementMicrotaskRunQueue::dispatch()
50 {
51 m_dispatchIsPending = false;
52 m_syncQueue->dispatch();
53 if (m_syncQueue->isEmpty())
54 m_asyncQueue->dispatch();
55 }
56
57 bool CustomElementMicrotaskRunQueue::isEmpty() const
58 {
59 return m_syncQueue->isEmpty() && m_asyncQueue->isEmpty();
60 }
61
62 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698