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

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

Issue 2455483002: Use v8::TryCatch in toImplSequence (Closed)
Patch Set: Created 4 years, 1 month 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 | « third_party/WebKit/Source/bindings/core/v8/V8Binding.h ('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) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 2009 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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 return true; 890 return true;
891 } 891 }
892 892
893 v8::Local<v8::Function> getBoundFunction(v8::Local<v8::Function> function) { 893 v8::Local<v8::Function> getBoundFunction(v8::Local<v8::Function> function) {
894 v8::Local<v8::Value> boundFunction = function->GetBoundFunction(); 894 v8::Local<v8::Value> boundFunction = function->GetBoundFunction();
895 return boundFunction->IsFunction() 895 return boundFunction->IsFunction()
896 ? v8::Local<v8::Function>::Cast(boundFunction) 896 ? v8::Local<v8::Function>::Cast(boundFunction)
897 : function; 897 : function;
898 } 898 }
899 899
900 v8::MaybeLocal<v8::Object> getEsIterator(v8::Isolate* isolate, 900 v8::Local<v8::Object> getEsIterator(v8::Isolate* isolate,
901 v8::Local<v8::Object> object, 901 v8::Local<v8::Object> object,
902 ExceptionState& exceptionState) { 902 ExceptionState& exceptionState) {
903 v8::TryCatch block(isolate);
903 v8::Local<v8::Context> context = isolate->GetCurrentContext(); 904 v8::Local<v8::Context> context = isolate->GetCurrentContext();
904 v8::Local<v8::Value> iteratorGetter; 905 v8::Local<v8::Value> iteratorGetter;
905 if (!object->Get(context, v8::Symbol::GetIterator(isolate)) 906 if (!object->Get(context, v8::Symbol::GetIterator(isolate))
906 .ToLocal(&iteratorGetter)) 907 .ToLocal(&iteratorGetter)) {
907 return v8::MaybeLocal<v8::Object>(); 908 exceptionState.rethrowV8Exception(block.Exception());
909 return v8::Local<v8::Object>();
910 }
908 if (!iteratorGetter->IsFunction()) { 911 if (!iteratorGetter->IsFunction()) {
909 exceptionState.throwTypeError("Iterator getter is not callable."); 912 exceptionState.throwTypeError("Iterator getter is not callable.");
910 return v8::MaybeLocal<v8::Object>(); 913 return v8::Local<v8::Object>();
911 } 914 }
912 915
913 v8::Local<v8::Function> getterFunction = iteratorGetter.As<v8::Function>(); 916 v8::Local<v8::Function> getterFunction = iteratorGetter.As<v8::Function>();
914 v8::Local<v8::Value> iterator; 917 v8::Local<v8::Value> iterator;
915 if (!V8ScriptRunner::callFunction(getterFunction, toExecutionContext(context), 918 if (!V8ScriptRunner::callFunction(getterFunction, toExecutionContext(context),
916 object, 0, nullptr, isolate) 919 object, 0, nullptr, isolate)
917 .ToLocal(&iterator)) 920 .ToLocal(&iterator)) {
918 return v8::MaybeLocal<v8::Object>(); 921 exceptionState.rethrowV8Exception(block.Exception());
922 return v8::Local<v8::Object>();
923 }
919 if (!iterator->IsObject()) { 924 if (!iterator->IsObject()) {
920 exceptionState.throwTypeError("Iterator is not an object."); 925 exceptionState.throwTypeError("Iterator is not an object.");
921 return v8::MaybeLocal<v8::Object>(); 926 return v8::Local<v8::Object>();
922 } 927 }
923 return v8::MaybeLocal<v8::Object>(iterator.As<v8::Object>()); 928 return iterator.As<v8::Object>();
924 } 929 }
925 930
926 bool addHiddenValueToArray(v8::Isolate* isolate, 931 bool addHiddenValueToArray(v8::Isolate* isolate,
927 v8::Local<v8::Object> object, 932 v8::Local<v8::Object> object,
928 v8::Local<v8::Value> value, 933 v8::Local<v8::Value> value,
929 int arrayIndex) { 934 int arrayIndex) {
930 ASSERT(!value.IsEmpty()); 935 ASSERT(!value.IsEmpty());
931 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex); 936 v8::Local<v8::Value> arrayValue = object->GetInternalField(arrayIndex);
932 if (arrayValue->IsNull() || arrayValue->IsUndefined()) { 937 if (arrayValue->IsNull() || arrayValue->IsUndefined()) {
933 arrayValue = v8::Array::New(isolate); 938 arrayValue = v8::Array::New(isolate);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value, 998 v8::Local<v8::Value> freezeV8Object(v8::Local<v8::Value> value,
994 v8::Isolate* isolate) { 999 v8::Isolate* isolate) {
995 value.As<v8::Object>() 1000 value.As<v8::Object>()
996 ->SetIntegrityLevel(isolate->GetCurrentContext(), 1001 ->SetIntegrityLevel(isolate->GetCurrentContext(),
997 v8::IntegrityLevel::kFrozen) 1002 v8::IntegrityLevel::kFrozen)
998 .ToChecked(); 1003 .ToChecked();
999 return value; 1004 return value;
1000 } 1005 }
1001 1006
1002 } // namespace blink 1007 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8Binding.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698