Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(738)

Side by Side Diff: Source/bindings/v8/ScriptPromise.cpp

Issue 316453002: Use v8::Promise::Then in ScriptPromise::then. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/fast/js/Promise-native-then.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 72
73 v8::Local<v8::Object> promise = m_promise.v8Value().As<v8::Object>(); 73 v8::Local<v8::Object> promise = m_promise.v8Value().As<v8::Object>();
74 v8::Local<v8::Function> v8OnFulfilled = ScriptFunction::adoptByGarbageCollec tor(onFulfilled); 74 v8::Local<v8::Function> v8OnFulfilled = ScriptFunction::adoptByGarbageCollec tor(onFulfilled);
75 v8::Local<v8::Function> v8OnRejected = ScriptFunction::adoptByGarbageCollect or(onRejected); 75 v8::Local<v8::Function> v8OnRejected = ScriptFunction::adoptByGarbageCollect or(onRejected);
76 76
77 ASSERT(promise->IsPromise()); 77 ASSERT(promise->IsPromise());
78 // Return this Promise if no handlers are given. 78 // Return this Promise if no handlers are given.
79 // In fact it is not the exact bahavior of Promise.prototype.then 79 // In fact it is not the exact bahavior of Promise.prototype.then
80 // but that is not a problem in this case. 80 // but that is not a problem in this case.
81 v8::Local<v8::Promise> resultPromise = promise.As<v8::Promise>(); 81 v8::Local<v8::Promise> resultPromise = promise.As<v8::Promise>();
82 // FIXME: Use Then once it is introduced.
83 if (!v8OnFulfilled.IsEmpty()) { 82 if (!v8OnFulfilled.IsEmpty()) {
84 resultPromise = resultPromise->Chain(v8OnFulfilled); 83 resultPromise = resultPromise->Then(v8OnFulfilled);
85 if (resultPromise.IsEmpty()) { 84 if (resultPromise.IsEmpty()) {
86 // v8::Promise::Chain may return an empty value, for example when 85 // v8::Promise::Then may return an empty value, for example when
87 // the stack is exhausted. 86 // the stack is exhausted.
88 return ScriptPromise(); 87 return ScriptPromise();
89 } 88 }
90 } 89 }
91 if (!v8OnRejected.IsEmpty()) 90 if (!v8OnRejected.IsEmpty())
92 resultPromise = resultPromise->Catch(v8OnRejected); 91 resultPromise = resultPromise->Catch(v8OnRejected);
93 92
94 return ScriptPromise(m_scriptState.get(), resultPromise); 93 return ScriptPromise(m_scriptState.get(), resultPromise);
95 } 94 }
96 95
(...skipping 30 matching lines...) Expand all
127 return promise; 126 return promise;
128 } 127 }
129 128
130 ScriptPromise ScriptPromise::rejectWithDOMException(ScriptState* scriptState, Pa ssRefPtrWillBeRawPtr<DOMException> exception) 129 ScriptPromise ScriptPromise::rejectWithDOMException(ScriptState* scriptState, Pa ssRefPtrWillBeRawPtr<DOMException> exception)
131 { 130 {
132 ASSERT(scriptState->isolate()->InContext()); 131 ASSERT(scriptState->isolate()->InContext());
133 return reject(scriptState, ToV8Value<WithScriptState, v8::Handle<v8::Object> >::toV8Value(exception, scriptState->context()->Global(), scriptState->isolate( ))); 132 return reject(scriptState, ToV8Value<WithScriptState, v8::Handle<v8::Object> >::toV8Value(exception, scriptState->context()->Global(), scriptState->isolate( )));
134 } 133 }
135 134
136 } // namespace WebCore 135 } // namespace WebCore
OLDNEW
« no previous file with comments | « LayoutTests/fast/js/Promise-native-then.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698