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

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

Issue 1591033002: Add toV8(value, scriptState) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update in response to review comments 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 | « no previous file | third_party/WebKit/Source/bindings/core/v8/ToV8Test.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/bindings/core/v8/ToV8.h
diff --git a/third_party/WebKit/Source/bindings/core/v8/ToV8.h b/third_party/WebKit/Source/bindings/core/v8/ToV8.h
index 5c8c07cf37e40afb087e23746658b8a75048d55e..e211d9ca61313f245fe71486a6d4c3e545c1fbec 100644
--- a/third_party/WebKit/Source/bindings/core/v8/ToV8.h
+++ b/third_party/WebKit/Source/bindings/core/v8/ToV8.h
@@ -9,12 +9,14 @@
// handle. Call sites must check IsEmpty() before using return value.
#include "bindings/core/v8/DOMDataStore.h"
+#include "bindings/core/v8/ScriptState.h"
#include "bindings/core/v8/ScriptValue.h"
#include "bindings/core/v8/ScriptWrappable.h"
#include "bindings/core/v8/V8Binding.h"
#include "core/CoreExport.h"
#include "platform/heap/Handle.h"
#include "wtf/Forward.h"
+#include <utility>
#include <v8.h>
namespace blink {
@@ -241,6 +243,15 @@ inline v8::Local<v8::Value> toV8(const Vector<std::pair<String, T>>& value, v8::
return object;
}
+// In all cases allow script state instead of creation context + isolate.
+// Use this function only if the call site does not otherwise need the global,
+// since v8::Context::Global is heavy.
+template<typename T>
+inline v8::Local<v8::Value> toV8(T&& value, ScriptState* scriptState)
+{
+ return toV8(std::forward<T>(value), scriptState->context()->Global(), scriptState->isolate());
+}
+
// Only declare toV8(void*,...) for checking function overload mismatch.
// This toV8(void*,...) should be never used. So we will find mismatch
// because of "unresolved external symbol".
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/ToV8Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698