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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8ScriptRunner.h

Issue 1670743002: Move V8 extra-calling utilities to V8ScriptRunner (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/V8Binding.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« 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