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

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

Issue 1167343002: Add methods for creating V8 extras-based ReadableStreams from C++ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Don't modify UnderlyingSource.h, oops 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
Index: third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h b/third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h
index 3b55b06f35914fa096a57ab701b88beba9dff105..c4ca60586ae1f8a165efc57b82d0c5b102091db6 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h
+++ b/third_party/WebKit/Source/bindings/core/v8/V8BindingMacros.h
@@ -31,6 +31,10 @@
#ifndef V8BindingMacros_h
#define V8BindingMacros_h
+#include "bindings/core/v8/ScriptState.h"
+#include "bindings/core/v8/ScriptValue.h"
+#include <v8.h>
+
namespace blink {
// type is an instance of class template V8StringResource<>,
@@ -103,6 +107,28 @@ inline v8::Local<T> v8CallOrCrash(v8::MaybeLocal<T> maybeLocal)
return maybeLocal.ToLocalChecked();
}
+v8::MaybeLocal<v8::Value> v8CallExtra(ScriptState* scriptState, const char* name, size_t numArgs, v8::Local<v8::Value>* args)
+{
+ v8::Isolate* isolate = scriptState->isolate();
+ v8::Local<v8::Context> context = scriptState->context();
+ 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 function->Call(context, undefined, numArgs, args);
+}
+
+template <size_t N>
+v8::MaybeLocal<v8::Value> v8CallExtra(ScriptState* scriptState, const char* name, v8::Local<v8::Value>(&args)[N])
+{
+ return v8CallExtra(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(v8CallExtra(scriptState, name, N, args));
+}
+
// The last "else" is to avoid dangling else problem.
#define V8_CALL(outVariable, handle, methodCall, failureExpression) \
if (handle.IsEmpty() || !v8Call(handle->methodCall, outVariable)) { \

Powered by Google App Engine
This is Rietveld 408576698