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

Side by Side Diff: Source/bindings/v8/custom/V8PromiseCustom.cpp

Issue 121113004: Improve handling of failed integer type conversions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 11 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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 621
622 v8::Local<v8::Object> V8PromiseCustom::getInternal(v8::Handle<v8::Object> promis e) 622 v8::Local<v8::Object> V8PromiseCustom::getInternal(v8::Handle<v8::Object> promis e)
623 { 623 {
624 v8::Local<v8::Value> value = promise->GetInternalField(v8DOMWrapperObjectInd ex); 624 v8::Local<v8::Value> value = promise->GetInternalField(v8DOMWrapperObjectInd ex);
625 return value.As<v8::Object>(); 625 return value.As<v8::Object>();
626 } 626 }
627 627
628 V8PromiseCustom::PromiseState V8PromiseCustom::getState(v8::Handle<v8::Object> i nternal) 628 V8PromiseCustom::PromiseState V8PromiseCustom::getState(v8::Handle<v8::Object> i nternal)
629 { 629 {
630 v8::Handle<v8::Value> value = internal->GetInternalField(V8PromiseCustom::In ternalStateIndex); 630 v8::Handle<v8::Value> value = internal->GetInternalField(V8PromiseCustom::In ternalStateIndex);
631 bool ok = false; 631 uint32_t number = toInt32(value);
632 uint32_t number = toInt32(value, ok); 632 ASSERT(number == Pending || number == Fulfilled || number == Rejected || num ber == Following);
633 ASSERT(ok && (number == Pending || number == Fulfilled || number == Rejected || number == Following));
634 return static_cast<PromiseState>(number); 633 return static_cast<PromiseState>(number);
635 } 634 }
636 635
637 void V8PromiseCustom::setState(v8::Handle<v8::Object> internal, PromiseState sta te, v8::Handle<v8::Value> value, v8::Isolate* isolate) 636 void V8PromiseCustom::setState(v8::Handle<v8::Object> internal, PromiseState sta te, v8::Handle<v8::Value> value, v8::Isolate* isolate)
638 { 637 {
639 ASSERT(!value.IsEmpty()); 638 ASSERT(!value.IsEmpty());
640 ASSERT(state == Pending || state == Fulfilled || state == Rejected || state == Following); 639 ASSERT(state == Pending || state == Fulfilled || state == Rejected || state == Following);
641 internal->SetInternalField(InternalStateIndex, v8::Integer::New(isolate, sta te)); 640 internal->SetInternalField(InternalStateIndex, v8::Integer::New(isolate, sta te));
642 internal->SetInternalField(InternalResultIndex, value); 641 internal->SetInternalField(InternalResultIndex, value);
643 } 642 }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 } 784 }
786 785
787 void V8PromiseCustom::callHandler(v8::Handle<v8::Object> promise, v8::Handle<v8: :Function> handler, v8::Handle<v8::Value> argument, v8::Isolate* isolate) 786 void V8PromiseCustom::callHandler(v8::Handle<v8::Object> promise, v8::Handle<v8: :Function> handler, v8::Handle<v8::Value> argument, v8::Isolate* isolate)
788 { 787 {
789 ExecutionContext* executionContext = getExecutionContext(); 788 ExecutionContext* executionContext = getExecutionContext();
790 ASSERT(executionContext && executionContext->isContextThread()); 789 ASSERT(executionContext && executionContext->isContextThread());
791 executionContext->postTask(adoptPtr(new CallHandlerTask(promise, handler, ar gument, isolate, executionContext))); 790 executionContext->postTask(adoptPtr(new CallHandlerTask(promise, handler, ar gument, isolate, executionContext)));
792 } 791 }
793 792
794 } // namespace WebCore 793 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8PannerNodeCustom.cpp ('k') | Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698