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

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

Issue 2857853007: Rename |m_scriptState| to |script_state_| in IDL bindings. (Closed)
Patch Set: Created 3 years, 7 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 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %} 1 {% from 'utilities.cpp.tmpl' import v8_value_to_local_cpp_value %}
2 {% filter format_blink_cpp_source_code %} 2 {% filter format_blink_cpp_source_code %}
3 3
4 {% include 'copyright_block.txt' %} 4 {% include 'copyright_block.txt' %}
5 5
6 #include "{{cpp_class}}.h" 6 #include "{{cpp_class}}.h"
7 7
8 {% for filename in cpp_includes %} 8 {% for filename in cpp_includes %}
9 #include "{{filename}}" 9 #include "{{filename}}"
10 {% endfor %} 10 {% endfor %}
11 11
12 namespace blink { 12 namespace blink {
13 13
14 // static 14 // static
15 {{cpp_class}}* {{cpp_class}}::Create(ScriptState* scriptState, v8::Local<v8::Val ue> callback) { 15 {{cpp_class}}* {{cpp_class}}::Create(ScriptState* scriptState, v8::Local<v8::Val ue> callback) {
16 if (IsUndefinedOrNull(callback)) 16 if (IsUndefinedOrNull(callback))
17 return nullptr; 17 return nullptr;
18 return new {{cpp_class}}(scriptState, v8::Local<v8::Function>::Cast(callback)) ; 18 return new {{cpp_class}}(scriptState, v8::Local<v8::Function>::Cast(callback)) ;
19 } 19 }
20 20
21 {{cpp_class}}::{{cpp_class}}(ScriptState* scriptState, v8::Local<v8::Function> c allback) 21 {{cpp_class}}::{{cpp_class}}(ScriptState* scriptState, v8::Local<v8::Function> c allback)
22 : m_scriptState(scriptState), 22 : script_state_(scriptState),
23 m_callback(scriptState->GetIsolate(), this, callback) { 23 m_callback(scriptState->GetIsolate(), this, callback) {
24 DCHECK(!m_callback.IsEmpty()); 24 DCHECK(!m_callback.IsEmpty());
25 } 25 }
26 26
27 DEFINE_TRACE_WRAPPERS({{cpp_class}}) { 27 DEFINE_TRACE_WRAPPERS({{cpp_class}}) {
28 visitor->TraceWrappers(m_callback.Cast<v8::Value>()); 28 visitor->TraceWrappers(m_callback.Cast<v8::Value>());
29 } 29 }
30 30
31 bool {{cpp_class}}::call({{argument_declarations | join(', ')}}) { 31 bool {{cpp_class}}::call({{argument_declarations | join(', ')}}) {
32 if (m_callback.IsEmpty()) 32 if (m_callback.IsEmpty())
33 return false; 33 return false;
34 34
35 if (!m_scriptState->ContextIsValid()) 35 if (!script_state_->ContextIsValid())
36 return false; 36 return false;
37 37
38 ExecutionContext* context = ExecutionContext::From(m_scriptState.Get()); 38 ExecutionContext* context = ExecutionContext::From(script_state_.Get());
39 DCHECK(context); 39 DCHECK(context);
40 if (context->IsContextSuspended() || context->IsContextDestroyed()) 40 if (context->IsContextSuspended() || context->IsContextDestroyed())
41 return false; 41 return false;
42 42
43 // TODO(bashi): Make sure that using DummyExceptionStateForTesting is OK. 43 // TODO(bashi): Make sure that using DummyExceptionStateForTesting is OK.
44 // crbug.com/653769 44 // crbug.com/653769
45 DummyExceptionStateForTesting exceptionState; 45 DummyExceptionStateForTesting exceptionState;
46 ScriptState::Scope scope(m_scriptState.Get()); 46 ScriptState::Scope scope(script_state_.Get());
47 v8::Isolate* isolate = m_scriptState->GetIsolate(); 47 v8::Isolate* isolate = script_state_->GetIsolate();
48 48
49 v8::Local<v8::Value> thisValue = ToV8( 49 v8::Local<v8::Value> thisValue = ToV8(
50 scriptWrappable, 50 scriptWrappable,
51 m_scriptState->GetContext()->Global(), 51 script_state_->GetContext()->Global(),
52 isolate); 52 isolate);
53 53
54 {% for argument in arguments %} 54 {% for argument in arguments %}
55 v8::Local<v8::Value> {{argument.argument_name}} = {{argument.cpp_value_to_v8_v alue}}; 55 v8::Local<v8::Value> {{argument.argument_name}} = {{argument.cpp_value_to_v8_v alue}};
56 {% endfor %} 56 {% endfor %}
57 {% if arguments %} 57 {% if arguments %}
58 v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'argument_name')}} }; 58 v8::Local<v8::Value> argv[] = { {{arguments | join(', ', 'argument_name')}} };
59 {% else %} 59 {% else %}
60 {# Empty array initializers are illegal, and don\'t compile in MSVC. #} 60 {# Empty array initializers are illegal, and don\'t compile in MSVC. #}
61 v8::Local<v8::Value> *argv = nullptr; 61 v8::Local<v8::Value> *argv = nullptr;
(...skipping 23 matching lines...) Expand all
85 if (!nativeValue) { 85 if (!nativeValue) {
86 exceptionState.ThrowTypeError(ExceptionMessages::FailedToConvertJSValue( 86 exceptionState.ThrowTypeError(ExceptionMessages::FailedToConvertJSValue(
87 "{{callback_function_name}}")); 87 "{{callback_function_name}}"));
88 } 88 }
89 return nativeValue; 89 return nativeValue;
90 } 90 }
91 91
92 } // namespace blink 92 } // namespace blink
93 93
94 {% endfilter %}{# format_blink_cpp_source_code #} 94 {% endfilter %}{# format_blink_cpp_source_code #}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698