Index: third_party/WebKit/Source/bindings/core/v8/V8Binding.h |
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8Binding.h b/third_party/WebKit/Source/bindings/core/v8/V8Binding.h |
index 3693e4ac407e94bb7fe4285dd37e0fa550ea3428..c2ed5ef83b98fde7d8d720bf52080f193d37cbd0 100644 |
--- a/third_party/WebKit/Source/bindings/core/v8/V8Binding.h |
+++ b/third_party/WebKit/Source/bindings/core/v8/V8Binding.h |
@@ -37,10 +37,12 @@ |
#include "bindings/core/v8/ExceptionMessages.h" |
#include "bindings/core/v8/ExceptionState.h" |
#include "bindings/core/v8/NativeValueTraits.h" |
+#include "bindings/core/v8/ScriptState.h" |
#include "bindings/core/v8/ScriptValue.h" |
#include "bindings/core/v8/ScriptWrappable.h" |
#include "bindings/core/v8/V8BindingMacros.h" |
#include "bindings/core/v8/V8PerIsolateData.h" |
+#include "bindings/core/v8/V8ScriptRunner.h" |
#include "bindings/core/v8/V8StringResource.h" |
#include "bindings/core/v8/V8ThrowException.h" |
#include "bindings/core/v8/V8ValueCache.h" |
@@ -1090,6 +1092,30 @@ CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName, |
typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Isolate*); |
+// Utiltiies for calling functions added to the V8 extras binding object. |
+ |
+inline v8::MaybeLocal<v8::Value> v8CallExtraHelper(ScriptState* scriptState, const char* name, size_t numArgs, v8::Local<v8::Value>* args) |
+{ |
+ v8::Isolate* isolate = scriptState->isolate(); |
+ ExecutionContext* ec = scriptState->executionContext(); |
+ v8::Local<v8::Value> undefined = v8::Undefined(isolate); |
+ v8::Local<v8::Value> functionValue = scriptState->getFromExtrasExports(name).v8Value(); |
+ v8::Local<v8::Function> function = functionValue.As<v8::Function>(); |
+ return V8ScriptRunner::callFunction(function, ec, undefined, numArgs, args, isolate); |
+} |
+ |
+template <size_t N> |
+v8::MaybeLocal<v8::Value> v8CallExtra(ScriptState* scriptState, const char* name, v8::Local<v8::Value>(&args)[N]) |
+{ |
+ return v8CallExtraHelper(scriptState, name, N, args); |
+} |
+ |
+template <size_t N> |
+v8::Local<v8::Value> v8CallExtraOrCrash(ScriptState* scriptState, const char* name, v8::Local<v8::Value>(&args)[N]) |
+{ |
+ return v8CallOrCrash(v8CallExtraHelper(scriptState, name, N, args)); |
+} |
+ |
} // namespace blink |
#endif // V8Binding_h |