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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/ScriptPromise.cpp

Issue 2144093002: Adding checks for V8 functions returning Maybe<bool> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding checks for V8 functions returning Maybe<bool> Created 3 years, 9 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
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 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "bindings/core/v8/ScriptPromise.h" 31 #include "bindings/core/v8/ScriptPromise.h"
32
33 #include "bindings/core/v8/ExceptionMessages.h" 32 #include "bindings/core/v8/ExceptionMessages.h"
34 #include "bindings/core/v8/ExceptionState.h" 33 #include "bindings/core/v8/ExceptionState.h"
35 #include "bindings/core/v8/ToV8.h" 34 #include "bindings/core/v8/ToV8.h"
36 #include "bindings/core/v8/V8ThrowException.h" 35 #include "bindings/core/v8/V8ThrowException.h"
37 #include "core/dom/DOMException.h" 36 #include "core/dom/DOMException.h"
38 #include "platform/InstanceCounters.h" 37 #include "platform/InstanceCounters.h"
39 #include "v8/include/v8.h" 38 #include "v8/include/v8.h"
40 39
41 namespace blink { 40 namespace blink {
42 41
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 ScriptPromise ScriptPromise::InternalResolver::promise() const { 180 ScriptPromise ScriptPromise::InternalResolver::promise() const {
182 if (m_resolver.isEmpty()) 181 if (m_resolver.isEmpty())
183 return ScriptPromise(); 182 return ScriptPromise();
184 return ScriptPromise(m_resolver.getScriptState(), v8Promise()); 183 return ScriptPromise(m_resolver.getScriptState(), v8Promise());
185 } 184 }
186 185
187 void ScriptPromise::InternalResolver::resolve(v8::Local<v8::Value> value) { 186 void ScriptPromise::InternalResolver::resolve(v8::Local<v8::Value> value) {
188 if (m_resolver.isEmpty()) 187 if (m_resolver.isEmpty())
189 return; 188 return;
190 m_resolver.v8Value().As<v8::Promise::Resolver>()->Resolve( 189 m_resolver.v8Value().As<v8::Promise::Resolver>()->Resolve(
191 m_resolver.context(), value); 190 m_resolver.context(), value).ToChecked();
192 clear(); 191 clear();
193 } 192 }
194 193
195 void ScriptPromise::InternalResolver::reject(v8::Local<v8::Value> value) { 194 void ScriptPromise::InternalResolver::reject(v8::Local<v8::Value> value) {
196 if (m_resolver.isEmpty()) 195 if (m_resolver.isEmpty())
197 return; 196 return;
198 m_resolver.v8Value().As<v8::Promise::Resolver>()->Reject(m_resolver.context(), 197 m_resolver.v8Value().As<v8::Promise::Resolver>()->Reject(
199 value); 198 m_resolver.context(), value).ToChecked();
200 clear(); 199 clear();
201 } 200 }
202 201
203 ScriptPromise::ScriptPromise() { 202 ScriptPromise::ScriptPromise() {
204 increaseInstanceCount(); 203 increaseInstanceCount();
205 } 204 }
206 205
207 ScriptPromise::ScriptPromise(ScriptState* scriptState, 206 ScriptPromise::ScriptPromise(ScriptState* scriptState,
208 v8::Local<v8::Value> value) 207 v8::Local<v8::Value> value)
209 : m_scriptState(scriptState) { 208 : m_scriptState(scriptState) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 } 303 }
305 304
306 v8::Local<v8::Promise> ScriptPromise::rejectRaw(ScriptState* scriptState, 305 v8::Local<v8::Promise> ScriptPromise::rejectRaw(ScriptState* scriptState,
307 v8::Local<v8::Value> value) { 306 v8::Local<v8::Value> value) {
308 if (value.IsEmpty()) 307 if (value.IsEmpty())
309 return v8::Local<v8::Promise>(); 308 return v8::Local<v8::Promise>();
310 v8::Local<v8::Promise::Resolver> resolver; 309 v8::Local<v8::Promise::Resolver> resolver;
311 if (!v8::Promise::Resolver::New(scriptState->context()).ToLocal(&resolver)) 310 if (!v8::Promise::Resolver::New(scriptState->context()).ToLocal(&resolver))
312 return v8::Local<v8::Promise>(); 311 return v8::Local<v8::Promise>();
313 v8::Local<v8::Promise> promise = resolver->GetPromise(); 312 v8::Local<v8::Promise> promise = resolver->GetPromise();
314 resolver->Reject(scriptState->context(), value); 313 resolver->Reject(scriptState->context(), value).ToChecked();
315 return promise; 314 return promise;
316 } 315 }
317 316
318 ScriptPromise ScriptPromise::all(ScriptState* scriptState, 317 ScriptPromise ScriptPromise::all(ScriptState* scriptState,
319 const Vector<ScriptPromise>& promises) { 318 const Vector<ScriptPromise>& promises) {
320 return PromiseAllHandler::all(scriptState, promises); 319 return PromiseAllHandler::all(scriptState, promises);
321 } 320 }
322 321
323 void ScriptPromise::increaseInstanceCount() { 322 void ScriptPromise::increaseInstanceCount() {
324 InstanceCounters::incrementCounter(InstanceCounters::ScriptPromiseCounter); 323 InstanceCounters::incrementCounter(InstanceCounters::ScriptPromiseCounter);
325 } 324 }
326 325
327 void ScriptPromise::decreaseInstanceCount() { 326 void ScriptPromise::decreaseInstanceCount() {
328 InstanceCounters::decrementCounter(InstanceCounters::ScriptPromiseCounter); 327 InstanceCounters::decrementCounter(InstanceCounters::ScriptPromiseCounter);
329 } 328 }
330 329
331 } // namespace blink 330 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698