| 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 } | 87 } |
| 88 | 88 |
| 89 ScriptPromise::ScriptPromise(ScriptState* scriptState, v8::Handle<v8::Value> val
ue) | 89 ScriptPromise::ScriptPromise(ScriptState* scriptState, v8::Handle<v8::Value> val
ue) |
| 90 : m_scriptState(scriptState) | 90 : m_scriptState(scriptState) |
| 91 { | 91 { |
| 92 if (value.IsEmpty()) | 92 if (value.IsEmpty()) |
| 93 return; | 93 return; |
| 94 | 94 |
| 95 if (!value->IsPromise()) { | 95 if (!value->IsPromise()) { |
| 96 m_promise = ScriptValue(scriptState, v8::Handle<v8::Value>()); | 96 m_promise = ScriptValue(scriptState, v8::Handle<v8::Value>()); |
| 97 V8ThrowException::throwTypeError("the given value is not a Promise", scr
iptState->isolate()); | 97 V8ThrowException::throwTypeError(scriptState->isolate(), "the given valu
e is not a Promise"); |
| 98 return; | 98 return; |
| 99 } | 99 } |
| 100 m_promise = ScriptValue(scriptState, value); | 100 m_promise = ScriptValue(scriptState, value); |
| 101 } | 101 } |
| 102 | 102 |
| 103 ScriptPromise ScriptPromise::then(v8::Handle<v8::Function> onFulfilled, v8::Hand
le<v8::Function> onRejected) | 103 ScriptPromise ScriptPromise::then(v8::Handle<v8::Function> onFulfilled, v8::Hand
le<v8::Function> onRejected) |
| 104 { | 104 { |
| 105 if (m_promise.isEmpty()) | 105 if (m_promise.isEmpty()) |
| 106 return ScriptPromise(); | 106 return ScriptPromise(); |
| 107 | 107 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 { | 169 { |
| 170 if (value.IsEmpty()) | 170 if (value.IsEmpty()) |
| 171 return v8::Local<v8::Promise>(); | 171 return v8::Local<v8::Promise>(); |
| 172 v8::Local<v8::Promise::Resolver> resolver = v8::Promise::Resolver::New(isola
te); | 172 v8::Local<v8::Promise::Resolver> resolver = v8::Promise::Resolver::New(isola
te); |
| 173 v8::Local<v8::Promise> promise = resolver->GetPromise(); | 173 v8::Local<v8::Promise> promise = resolver->GetPromise(); |
| 174 resolver->Reject(value); | 174 resolver->Reject(value); |
| 175 return promise; | 175 return promise; |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |