Chromium Code Reviews| Index: third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h |
| diff --git a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h |
| index e6d777f24dfdb74d36b0dad642754a767b053cba..48a1e2ad486405bc03a5c34d5696e0e5a55bdb34 100644 |
| --- a/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h |
| +++ b/third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h |
| @@ -26,6 +26,9 @@ |
| #ifndef V8ScriptRunner_h |
| #define V8ScriptRunner_h |
| +#include "bindings/core/v8/ScriptState.h" |
| +#include "bindings/core/v8/ScriptValue.h" |
|
haraken
2016/02/05 00:56:41
This wouldn't be needed.
|
| +#include "bindings/core/v8/V8BindingMacros.h" |
| #include "bindings/core/v8/V8CacheOptions.h" |
| #include "core/CoreExport.h" |
| #include "core/fetch/AccessControlStatus.h" |
| @@ -68,6 +71,31 @@ public: |
| static unsigned tagForParserCache(CachedMetadataHandler*); |
| static unsigned tagForCodeCache(CachedMetadataHandler*); |
| + |
| + |
| + // Utiltiies for calling functions added to the V8 extras binding object. |
| + |
| + template <size_t N> |
| + static v8::MaybeLocal<v8::Value> callExtra(ScriptState* scriptState, const char* name, v8::Local<v8::Value>(&args)[N]) |
| + { |
| + return callExtraHelper(scriptState, name, N, args); |
| + } |
| + |
| + template <size_t N> |
| + static v8::Local<v8::Value> callExtraOrCrash(ScriptState* scriptState, const char* name, v8::Local<v8::Value>(&args)[N]) |
| + { |
| + return v8CallOrCrash(callExtraHelper(scriptState, name, N, args)); |
| + } |
| + |
| +private: |
| + static v8::MaybeLocal<v8::Value> callExtraHelper(ScriptState* scriptState, const char* name, size_t numArgs, v8::Local<v8::Value>* args) |
| + { |
| + v8::Isolate* isolate = scriptState->isolate(); |
| + 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::callInternalFunction(function, undefined, numArgs, args, isolate); |
| + } |
| }; |
| } // namespace blink |