コード例 #1
0
ScriptPromise ScriptPromise::cast(ScriptState* scriptState, v8::Handle<v8::Value> value)
{
    if (value.IsEmpty())
        return ScriptPromise();
    if (value->IsPromise()) {
        return ScriptPromise(scriptState, value);
    }
    RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
    ScriptPromise promise = resolver->promise();
    resolver->resolve(value);
    return promise;
}
コード例 #2
0
ScriptPromise ScriptPromise::cast(ScriptState* scriptState, v8::Handle<v8::Value> value)
{
    if (value.IsEmpty())
        return ScriptPromise();
    if (value->IsPromise()) {
        return ScriptPromise(scriptState, value);
    }
    InternalResolver resolver(scriptState);
    ScriptPromise promise = resolver.promise();
    resolver.resolve(value);
    return promise;
}
コード例 #3
0
ファイル: ScriptPromise.cpp プロジェクト: coinpayee/blink
ScriptPromise::ScriptPromise(ScriptState* scriptState, v8::Handle<v8::Value> value)
    : m_scriptState(scriptState)
{
    if (value.IsEmpty())
        return;

    if (!V8PromiseCustom::isPromise(value, scriptState->isolate()) && !value->IsPromise()) {
        m_promise = ScriptValue(scriptState, v8::Handle<v8::Value>());
        V8ThrowException::throwTypeError("the given value is not a Promise", scriptState->isolate());
        return;
    }
    m_promise = ScriptValue(scriptState, value);
}