flutter_flutter/engine/core/dom/custom/CustomElementMicrotaskRunQueue.cpp
Eric Seidel 64b5cb61a1 Remove all oilpan transitional types
I used do-webcore-rename from Blink/WebKit
which is very good at doing this kind
of search-replace.

Also removed toRefPrtNativeArray after
conversion since it previously had two
separate flavors.  Both versions are no longer
used so I've removed the code until we
need one again.

https://www.irccloud.com/pastebin/5C16p5cE
is the diff I used to do-webcore-rename

TBR=abarth@chromium.org
2014-10-27 14:13:01 -07:00

70 lines
1.9 KiB
C++

// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "config.h"
#include "core/dom/custom/CustomElementMicrotaskRunQueue.h"
#include "base/bind.h"
#include "core/dom/Microtask.h"
#include "core/dom/custom/CustomElementAsyncImportMicrotaskQueue.h"
#include "core/dom/custom/CustomElementSyncMicrotaskQueue.h"
#include "core/html/imports/HTMLImportLoader.h"
#include <stdio.h>
namespace blink {
DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(CustomElementMicrotaskRunQueue)
CustomElementMicrotaskRunQueue::CustomElementMicrotaskRunQueue()
: m_syncQueue(CustomElementSyncMicrotaskQueue::create())
, m_asyncQueue(CustomElementAsyncImportMicrotaskQueue::create())
, m_dispatchIsPending(false)
, m_weakFactory(this)
{
}
void CustomElementMicrotaskRunQueue::enqueue(HTMLImportLoader* parentLoader, PassOwnPtr<CustomElementMicrotaskStep> step, bool importIsSync)
{
if (importIsSync) {
if (parentLoader)
parentLoader->microtaskQueue()->enqueue(step);
else
m_syncQueue->enqueue(step);
} else {
m_asyncQueue->enqueue(step);
}
requestDispatchIfNeeded();
}
void CustomElementMicrotaskRunQueue::requestDispatchIfNeeded()
{
if (m_dispatchIsPending || isEmpty())
return;
Microtask::enqueueMicrotask(base::Bind(&CustomElementMicrotaskRunQueue::dispatch, m_weakFactory.GetWeakPtr()));
m_dispatchIsPending = true;
}
void CustomElementMicrotaskRunQueue::trace(Visitor* visitor)
{
visitor->trace(m_syncQueue);
visitor->trace(m_asyncQueue);
}
void CustomElementMicrotaskRunQueue::dispatch()
{
m_dispatchIsPending = false;
m_syncQueue->dispatch();
if (m_syncQueue->isEmpty())
m_asyncQueue->dispatch();
}
bool CustomElementMicrotaskRunQueue::isEmpty() const
{
return m_syncQueue->isEmpty() && m_asyncQueue->isEmpty();
}
} // namespace blink