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

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

Issue 1594653003: Move utilities for V8 extras functions into V8Binding.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move to V8Binding.h and fix tests Created 4 years, 11 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/ReadableStreamOperationsTest.cpp ('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/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
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ReadableStreamOperationsTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698