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

Side by Side Diff: third_party/WebKit/Source/bindings/templates/callback_interface.cpp.tmpl

Issue 2811833002: Move ScriptState::GetExecutionContext (Part 2) (Closed)
Patch Set: Add 2 sp Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 {% filter format_blink_cpp_source_code %} 1 {% filter format_blink_cpp_source_code %}
2 2
3 {% include 'copyright_block.txt' %} 3 {% include 'copyright_block.txt' %}
4 #include "{{v8_class}}.h" 4 #include "{{v8_class}}.h"
5 5
6 {% for filename in cpp_includes %} 6 {% for filename in cpp_includes %}
7 #include "{{filename}}" 7 #include "{{filename}}"
8 {% endfor %} 8 {% endfor %}
9 9
10 namespace blink { 10 namespace blink {
11 11
12 {{v8_class}}::{{v8_class}}(v8::Local<v8::Function> callback, ScriptState* script State) 12 {{v8_class}}::{{v8_class}}(v8::Local<v8::Function> callback, ScriptState* script State)
13 : m_scriptState(scriptState) { 13 : m_scriptState(scriptState) {
14 m_callback.Set(scriptState->GetIsolate(), callback); 14 m_callback.Set(scriptState->GetIsolate(), callback);
15 } 15 }
16 16
17 {{v8_class}}::~{{v8_class}}() {} 17 {{v8_class}}::~{{v8_class}}() {}
18 18
19 DEFINE_TRACE({{v8_class}}) { 19 DEFINE_TRACE({{v8_class}}) {
20 {{cpp_class}}::Trace(visitor); 20 {{cpp_class}}::Trace(visitor);
21 } 21 }
22 22
23 {% for method in methods if not method.is_custom %} 23 {% for method in methods if not method.is_custom %}
24 {{method.cpp_type}} {{v8_class}}::{{method.name}}({{method.argument_declarations | join(', ')}}) { 24 {{method.cpp_type}} {{v8_class}}::{{method.name}}({{method.argument_declarations | join(', ')}}) {
25 {% set return_default = 'return true' 25 {% set return_default = 'return true'
26 if method.idl_type == 'boolean' else 'return' %}{# void #} 26 if method.idl_type == 'boolean' else 'return' %}{# void #}
27 ExecutionContext* executionContext = m_scriptState->GetExecutionContext(); 27 ExecutionContext* executionContext =
28 ExecutionContext::From(m_scriptState.Get());
28 if (!executionContext || executionContext->IsContextSuspended() || 29 if (!executionContext || executionContext->IsContextSuspended() ||
29 executionContext->IsContextDestroyed()) 30 executionContext->IsContextDestroyed())
30 {{return_default}}; 31 {{return_default}};
31 if (!m_scriptState->ContextIsValid()) 32 if (!m_scriptState->ContextIsValid())
32 {{return_default}}; 33 {{return_default}};
33 34
34 ScriptState::Scope scope(m_scriptState.Get()); 35 ScriptState::Scope scope(m_scriptState.Get());
35 {% if method.call_with_this_handle %} 36 {% if method.call_with_this_handle %}
36 v8::Local<v8::Value> thisHandle = thisValue.V8Value(); 37 v8::Local<v8::Value> thisHandle = thisValue.V8Value();
37 {% endif %} 38 {% endif %}
(...skipping 16 matching lines...) Expand all
54 exceptionCatcher.SetVerbose(true); 55 exceptionCatcher.SetVerbose(true);
55 V8ScriptRunner::CallFunction(m_callback.NewLocal(isolate), 56 V8ScriptRunner::CallFunction(m_callback.NewLocal(isolate),
56 executionContext, 57 executionContext,
57 {{this_handle_parameter}}, 58 {{this_handle_parameter}},
58 {{method.arguments | length}}, 59 {{method.arguments | length}},
59 argv, 60 argv,
60 isolate); 61 isolate);
61 return !exceptionCatcher.HasCaught(); 62 return !exceptionCatcher.HasCaught();
62 {% else %}{# void #} 63 {% else %}{# void #}
63 V8ScriptRunner::CallFunction(m_callback.NewLocal(isolate), 64 V8ScriptRunner::CallFunction(m_callback.NewLocal(isolate),
64 m_scriptState->GetExecutionContext(), 65 ExecutionContext::From(m_scriptState.Get()),
65 {{this_handle_parameter}}, 66 {{this_handle_parameter}},
66 {{method.arguments | length}}, 67 {{method.arguments | length}},
67 argv, 68 argv,
68 isolate); 69 isolate);
69 {% endif %} 70 {% endif %}
70 } 71 }
71 72
72 {% endfor %} 73 {% endfor %}
73 } // namespace blink 74 } // namespace blink
74 75
75 {% endfilter %}{# format_blink_cpp_source_code #} 76 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698