| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 // the stack is exhausted. | 87 // the stack is exhausted. |
| 88 return ScriptPromise(); | 88 return ScriptPromise(); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 if (!v8OnRejected.IsEmpty()) | 91 if (!v8OnRejected.IsEmpty()) |
| 92 resultPromise = resultPromise->Catch(v8OnRejected); | 92 resultPromise = resultPromise->Catch(v8OnRejected); |
| 93 | 93 |
| 94 return ScriptPromise(m_scriptState.get(), resultPromise); | 94 return ScriptPromise(m_scriptState.get(), resultPromise); |
| 95 } | 95 } |
| 96 | 96 |
| 97 ScriptPromise ScriptPromise::cast(ScriptState* scriptState, const ScriptValue& v
alue) | 97 ScriptPromise ScriptPromise::cast(const ScriptValue& value) |
| 98 { | 98 { |
| 99 return ScriptPromise::cast(scriptState, value.v8Value()); | 99 return ScriptPromise::cast(value.scriptState(), value.v8Value()); |
| 100 } | 100 } |
| 101 | 101 |
| 102 ScriptPromise ScriptPromise::cast(ScriptState* scriptState, v8::Handle<v8::Value
> value) | 102 ScriptPromise ScriptPromise::cast(ScriptState* scriptState, v8::Handle<v8::Value
> value) |
| 103 { | 103 { |
| 104 if (value.IsEmpty()) | 104 if (value.IsEmpty()) |
| 105 return ScriptPromise(); | 105 return ScriptPromise(); |
| 106 if (value->IsPromise()) { | 106 if (value->IsPromise()) { |
| 107 return ScriptPromise(scriptState, value); | 107 return ScriptPromise(scriptState, value); |
| 108 } | 108 } |
| 109 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); | 109 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); |
| 110 ScriptPromise promise = resolver->promise(); | 110 ScriptPromise promise = resolver->promise(); |
| 111 resolver->resolve(value); | 111 resolver->resolve(value); |
| 112 return promise; | 112 return promise; |
| 113 } | 113 } |
| 114 | 114 |
| 115 ScriptPromise ScriptPromise::reject(ScriptState* scriptState, const ScriptValue&
value) | 115 ScriptPromise ScriptPromise::reject(const ScriptValue& value) |
| 116 { | 116 { |
| 117 return ScriptPromise::reject(scriptState, value.v8Value()); | 117 return ScriptPromise::reject(value.scriptState(), value.v8Value()); |
| 118 } | 118 } |
| 119 | 119 |
| 120 ScriptPromise ScriptPromise::reject(ScriptState* scriptState, v8::Handle<v8::Val
ue> value) | 120 ScriptPromise ScriptPromise::reject(ScriptState* scriptState, v8::Handle<v8::Val
ue> value) |
| 121 { | 121 { |
| 122 if (value.IsEmpty()) | 122 if (value.IsEmpty()) |
| 123 return ScriptPromise(); | 123 return ScriptPromise(); |
| 124 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); | 124 RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scrip
tState); |
| 125 ScriptPromise promise = resolver->promise(); | 125 ScriptPromise promise = resolver->promise(); |
| 126 resolver->reject(value); | 126 resolver->reject(value); |
| 127 return promise; | 127 return promise; |
| 128 } | 128 } |
| 129 | 129 |
| 130 ScriptPromise ScriptPromise::rejectWithDOMException(ScriptState* scriptState, Pa
ssRefPtrWillBeRawPtr<DOMException> exception) | 130 ScriptPromise ScriptPromise::rejectWithDOMException(ScriptState* scriptState, Pa
ssRefPtrWillBeRawPtr<DOMException> exception) |
| 131 { | 131 { |
| 132 ASSERT(scriptState->isolate()->InContext()); | 132 ASSERT(scriptState->isolate()->InContext()); |
| 133 return reject(scriptState, ToV8Value<WithScriptState, v8::Handle<v8::Object>
>::toV8Value(exception, scriptState->context()->Global(), scriptState->isolate(
))); | 133 return reject(scriptState, ToV8Value<WithScriptState, v8::Handle<v8::Object>
>::toV8Value(exception, scriptState->context()->Global(), scriptState->isolate(
))); |
| 134 } | 134 } |
| 135 | 135 |
| 136 } // namespace WebCore | 136 } // namespace WebCore |
| OLD | NEW |