JSReadableStreamSourceCustom.cpp [plain text]
#include "config.h"
#include "JSReadableStreamSource.h"
#if ENABLE(READABLE_STREAM_API)
using namespace JSC;
namespace WebCore {
static void startReadableStream(JSC::ExecState& state, Ref<DeferredPromise>&& promise)
{
JSReadableStreamSource* source = jsDynamicDowncast<JSReadableStreamSource*>(state.thisValue());
ASSERT(source);
ASSERT(state.argumentCount());
JSReadableStreamDefaultController* controller = jsDynamicDowncast<JSReadableStreamDefaultController*>(state.uncheckedArgument(0));
ASSERT(controller);
source->wrapped().start(ReadableStreamDefaultController(controller), WTFMove(promise));
}
JSValue JSReadableStreamSource::start(ExecState& state)
{
ASSERT(state.argumentCount());
JSReadableStreamDefaultController* controller = jsDynamicDowncast<JSReadableStreamDefaultController*>(state.uncheckedArgument(0));
ASSERT(controller);
m_controller.set(state.vm(), this, controller);
return callPromiseFunction<startReadableStream, PromiseExecutionScope::WindowOrWorker>(state);
}
static void pullReadableStream(JSC::ExecState& state, Ref<DeferredPromise>&& promise)
{
JSReadableStreamSource* source = jsDynamicDowncast<JSReadableStreamSource*>(state.thisValue());
ASSERT(source);
source->wrapped().pull(WTFMove(promise));
}
JSValue JSReadableStreamSource::pull(ExecState& state)
{
return callPromiseFunction<pullReadableStream, PromiseExecutionScope::WindowOrWorker>(state);
}
JSValue JSReadableStreamSource::controller(ExecState&) const
{
ASSERT_NOT_REACHED();
return jsUndefined();
}
}
#endif // ENABLE(READABLE_STREAM_API)