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

Unified Diff: Source/bindings/core/v8/NPV8Object.cpp

Issue 1067763002: bindings: Use Maybe version of Get in bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: Source/bindings/core/v8/NPV8Object.cpp
diff --git a/Source/bindings/core/v8/NPV8Object.cpp b/Source/bindings/core/v8/NPV8Object.cpp
index 45b2d7a5f630c4bab055fb0fb585649b5b60c214..30472b2e9154715e148bf2a7dc438ca1beca5674 100644
--- a/Source/bindings/core/v8/NPV8Object.cpp
+++ b/Source/bindings/core/v8/NPV8Object.cpp
@@ -257,8 +257,8 @@ bool _NPN_Invoke(NPP npp, NPObject* npObject, NPIdentifier methodName, const NPV
ExceptionCatcher exceptionCatcher;
v8::Local<v8::Object> v8Object = v8::Local<v8::Object>::New(isolate, v8NpObject->v8Object);
- v8::Local<v8::Value> functionObject = v8Object->Get(v8AtomicString(isolate, identifier->value.string));
- if (functionObject.IsEmpty() || functionObject->IsNull()) {
+ v8::Local<v8::Value> functionObject;
+ if (!v8Object->Get(scriptState->context(), v8AtomicString(scriptState->isolate(), identifier->value.string)).ToLocal(&functionObject) || functionObject->IsNull()) {
NULL_TO_NPVARIANT(*result);
return false;
}
@@ -397,9 +397,8 @@ bool _NPN_GetProperty(NPP npp, NPObject* npObject, NPIdentifier propertyName, NP
ExceptionCatcher exceptionCatcher;
v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object->v8Object);
- v8::Local<v8::Value> v8result = obj->Get(npIdentifierToV8Identifier(isolate, propertyName));
-
- if (v8result.IsEmpty())
+ v8::Local<v8::Value> v8result;
+ if (!obj->Get(scriptState->context(), npIdentifierToV8Identifier(scriptState->isolate(), propertyName)).ToLocal(&v8result))
return false;
convertV8ObjectToNPVariant(isolate, v8result, npObject, result);
@@ -498,7 +497,9 @@ bool _NPN_HasMethod(NPP npp, NPObject* npObject, NPIdentifier methodName)
ExceptionCatcher exceptionCatcher;
v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object->v8Object);
- v8::Local<v8::Value> prop = obj->Get(npIdentifierToV8Identifier(isolate, methodName));
+ v8::Local<v8::Value> prop;
+ if (!obj->Get(scriptState->context(), npIdentifierToV8Identifier(scriptState->isolate(), methodName)).ToLocal(&prop))
+ return false;
return prop->IsFunction();
}
@@ -540,7 +541,7 @@ bool _NPN_Enumerate(NPP npp, NPObject* npObject, NPIdentifier** identifier, uint
ScriptState::Scope scope(scriptState);
ExceptionCatcher exceptionCatcher;
- v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(isolate, object->v8Object);
+ v8::Local<v8::Object> obj = v8::Local<v8::Object>::New(scriptState->isolate(), object->v8Object);
// FIXME: http://b/issue?id=1210340: Use a v8::Object::Keys() method when it exists, instead of evaluating javascript.
@@ -554,15 +555,15 @@ bool _NPN_Enumerate(NPP npp, NPObject* npObject, NPIdentifier** identifier, uint
" }"
" return props;"
"});";
- v8::Local<v8::String> source = v8AtomicString(isolate, enumeratorCode);
+ v8::Local<v8::String> source = v8AtomicString(scriptState->isolate(), enumeratorCode);
v8::Local<v8::Value> result;
- if (!V8ScriptRunner::compileAndRunInternalScript(source, isolate).ToLocal(&result))
+ if (!V8ScriptRunner::compileAndRunInternalScript(source, scriptState->isolate()).ToLocal(&result))
return false;
ASSERT(result->IsFunction());
v8::Local<v8::Function> enumerator = v8::Local<v8::Function>::Cast(result);
v8::Local<v8::Value> argv[] = { obj };
v8::Local<v8::Value> propsObj;
- if (!V8ScriptRunner::callInternalFunction(enumerator, v8::Local<v8::Object>::Cast(result), WTF_ARRAY_LENGTH(argv), argv, isolate).ToLocal(&propsObj))
+ if (!V8ScriptRunner::callInternalFunction(enumerator, v8::Local<v8::Object>::Cast(result), WTF_ARRAY_LENGTH(argv), argv, scriptState->isolate()).ToLocal(&propsObj))
return false;
// Convert the results into an array of NPIdentifiers.
@@ -570,7 +571,9 @@ bool _NPN_Enumerate(NPP npp, NPObject* npObject, NPIdentifier** identifier, uint
*count = props->Length();
*identifier = static_cast<NPIdentifier*>(calloc(*count, sizeof(NPIdentifier)));
for (uint32_t i = 0; i < *count; ++i) {
- v8::Local<v8::Value> name = props->Get(v8::Integer::New(isolate, i));
+ v8::Local<v8::Value> name;
+ if (!props->Get(scriptState->context(), v8::Integer::New(scriptState->isolate(), i)).ToLocal(&name))
+ return false;
(*identifier)[i] = getStringIdentifier(v8::Local<v8::String>::Cast(name));
}
return true;
@@ -597,7 +600,7 @@ bool _NPN_Construct(NPP npp, NPObject* npObject, const NPVariant* arguments, uin
ExceptionCatcher exceptionCatcher;
// Lookup the constructor function.
- v8::Local<v8::Object> ctorObj = v8::Local<v8::Object>::New(isolate, object->v8Object);
+ v8::Local<v8::Object> ctorObj = v8::Local<v8::Object>::New(scriptState->isolate(), object->v8Object);
if (!ctorObj->IsFunction())
return false;

Powered by Google App Engine
This is Rietveld 408576698