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

Unified Diff: third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl

Issue 2458573002: bindings: Store ScriptState in generated callback functions (Closed)
Patch Set: Created 4 years, 2 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/templates/callback_function.cpp.tmpl
diff --git a/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl
index 1ce54c3f62f68e614383c215cbbf744f76d454ec..1fd35321f4c756844000000ebf80853098d30859 100644
--- a/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl
+++ b/third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl
@@ -11,8 +11,9 @@
namespace blink {
-{{cpp_class}}::{{cpp_class}}(v8::Isolate* isolate, v8::Local<v8::Function> callback)
- : m_callback(isolate, callback)
+{{cpp_class}}::{{cpp_class}}(ScriptState* scriptState, v8::Local<v8::Function> callback)
+ : m_scriptState(scriptState),
+ m_callback(scriptState->isolate(), callback)
{
DCHECK(!m_callback.isEmpty());
m_callback.setPhantom();
@@ -29,10 +30,10 @@ DEFINE_TRACE_WRAPPERS({{cpp_class}})
bool {{cpp_class}}::call({{argument_declarations | join(', ')}})
{
- if (!scriptState->contextIsValid())
+ if (!m_scriptState->contextIsValid())
return false;
- ExecutionContext* context = scriptState->getExecutionContext();
+ ExecutionContext* context = m_scriptState->getExecutionContext();
DCHECK(context);
if (context->activeDOMObjectsAreSuspended() || context->activeDOMObjectsAreStopped())
return false;
@@ -43,13 +44,13 @@ bool {{cpp_class}}::call({{argument_declarations | join(', ')}})
// TODO(bashi): Make sure that using TrackExceptionState is OK.
// crbug.com/653769
TrackExceptionState exceptionState;
- ScriptState::Scope scope(scriptState);
+ ScriptState::Scope scope(m_scriptState.get());
{% for argument in arguments %}
v8::Local<v8::Value> {{argument.argument_name}} = {{argument.cpp_value_to_v8_value}};
{% endfor %}
- v8::Local<v8::Value> thisValue = toV8(scriptWrappable, scriptState->context()->Global(), scriptState->isolate());
+ v8::Local<v8::Value> thisValue = toV8(scriptWrappable, m_scriptState->context()->Global(), m_scriptState->isolate());
{% if arguments %}
v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'argument_name')}} };
@@ -59,10 +60,10 @@ bool {{cpp_class}}::call({{argument_declarations | join(', ')}})
{% endif %}
v8::Local<v8::Value> v8ReturnValue;
- v8::TryCatch exceptionCatcher(scriptState->isolate());
+ v8::TryCatch exceptionCatcher(m_scriptState->isolate());
exceptionCatcher.SetVerbose(true);
- if (V8ScriptRunner::callFunction(m_callback.newLocal(scriptState->isolate()), scriptState->getExecutionContext(), thisValue, {{arguments | length}}, argv, scriptState->isolate()).ToLocal(&v8ReturnValue))
+ if (V8ScriptRunner::callFunction(m_callback.newLocal(m_scriptState->isolate()), m_scriptState->getExecutionContext(), thisValue, {{arguments | length}}, argv, m_scriptState->isolate()).ToLocal(&v8ReturnValue))
{
{% if return_value %}
{{v8_value_to_local_cpp_value(return_value) | indent(8)}}

Powered by Google App Engine
This is Rietveld 408576698