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

Unified Diff: Source/bindings/core/v8/ScriptValue.h

Issue 1035623002: bindings: Use Maybe APIs in ScriptPromise (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 9 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 | « Source/bindings/core/v8/ScriptPromisePropertyBase.cpp ('k') | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/core/v8/ScriptValue.h
diff --git a/Source/bindings/core/v8/ScriptValue.h b/Source/bindings/core/v8/ScriptValue.h
index 7ad2aecaed7c51507d12e55ea33d1dd2cecd2704..d234a9783aa9402e8eb8ed1805f85691b89b1571 100644
--- a/Source/bindings/core/v8/ScriptValue.h
+++ b/Source/bindings/core/v8/ScriptValue.h
@@ -67,6 +67,14 @@ public:
ASSERT(isEmpty() || m_scriptState);
}
+ template <typename T>
+ ScriptValue(ScriptState* scriptState, v8::MaybeLocal<T> value)
+ : m_scriptState(scriptState)
+ , m_value(value.IsEmpty() ? nullptr : SharedPersistent<v8::Value>::create(value.ToLocalChecked(), scriptState->isolate()))
+ {
+ ASSERT(isEmpty() || m_scriptState);
+ }
+
ScriptValue(const ScriptValue& value)
: m_scriptState(value.m_scriptState)
, m_value(value.m_value)
@@ -84,6 +92,12 @@ public:
return m_scriptState ? m_scriptState->isolate() : v8::Isolate::GetCurrent();
}
+ v8::Local<v8::Context> context() const
+ {
+ ASSERT(m_scriptState.get());
+ return m_scriptState->context();
+ }
+
ScriptValue& operator=(const ScriptValue& value)
{
if (this != &value) {
« no previous file with comments | « Source/bindings/core/v8/ScriptPromisePropertyBase.cpp ('k') | Source/bindings/templates/methods.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698