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

Side by Side Diff: sky/engine/core/dom/custom/CustomElementMicrotaskRunQueue.cpp

Issue 950523002: Delete sky/engine/core/dom/custom (Closed) Base URL: git@github.com:domokit/mojo.git@master
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
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 "sky/engine/config.h"
6 #include "sky/engine/core/dom/custom/CustomElementMicrotaskRunQueue.h"
7
8 #include "base/bind.h"
9 #include "sky/engine/core/dom/Microtask.h"
10 #include "sky/engine/core/dom/custom/CustomElementAsyncImportMicrotaskQueue.h"
11 #include "sky/engine/core/dom/custom/CustomElementSyncMicrotaskQueue.h"
12 #include "sky/engine/core/html/imports/HTMLImportLoader.h"
13
14 #include <stdio.h>
15
16 namespace blink {
17
18 CustomElementMicrotaskRunQueue::CustomElementMicrotaskRunQueue()
19 : m_syncQueue(CustomElementSyncMicrotaskQueue::create())
20 , m_asyncQueue(CustomElementAsyncImportMicrotaskQueue::create())
21 , m_dispatchIsPending(false)
22 , m_weakFactory(this)
23 {
24 }
25
26 CustomElementMicrotaskRunQueue::~CustomElementMicrotaskRunQueue()
27 {
28 }
29
30 void CustomElementMicrotaskRunQueue::enqueue(HTMLImportLoader* parentLoader, Pas sOwnPtr<CustomElementMicrotaskStep> step, bool importIsSync)
31 {
32 if (importIsSync) {
33 if (parentLoader)
34 parentLoader->microtaskQueue()->enqueue(step);
35 else
36 m_syncQueue->enqueue(step);
37 } else {
38 m_asyncQueue->enqueue(step);
39 }
40
41 requestDispatchIfNeeded();
42 }
43
44 void CustomElementMicrotaskRunQueue::requestDispatchIfNeeded()
45 {
46 if (m_dispatchIsPending || isEmpty())
47 return;
48 Microtask::enqueueMicrotask(base::Bind(&CustomElementMicrotaskRunQueue::disp atch, m_weakFactory.GetWeakPtr()));
49 m_dispatchIsPending = true;
50 }
51
52 void CustomElementMicrotaskRunQueue::dispatch()
53 {
54 m_dispatchIsPending = false;
55 m_syncQueue->dispatch();
56 if (m_syncQueue->isEmpty())
57 m_asyncQueue->dispatch();
58 }
59
60 bool CustomElementMicrotaskRunQueue::isEmpty() const
61 {
62 return m_syncQueue->isEmpty() && m_asyncQueue->isEmpty();
63 }
64
65 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/dom/custom/CustomElementMicrotaskRunQueue.h ('k') | sky/engine/core/dom/custom/CustomElementMicrotaskStep.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698