OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file has been auto-generated by code_generator_v8.py. | 5 // This file has been auto-generated by code_generator_v8.py. |
6 // DO NOT MODIFY! | 6 // DO NOT MODIFY! |
7 | 7 |
8 // This file has been generated from the Jinja2 template in | 8 // This file has been generated from the Jinja2 template in |
9 // third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl | 9 // third_party/WebKit/Source/bindings/templates/callback_function.cpp.tmpl |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 namespace blink { | 22 namespace blink { |
23 | 23 |
24 // static | 24 // static |
25 VoidCallbackFunctionModules* VoidCallbackFunctionModules::Create(ScriptState* sc
riptState, v8::Local<v8::Value> callback) { | 25 VoidCallbackFunctionModules* VoidCallbackFunctionModules::Create(ScriptState* sc
riptState, v8::Local<v8::Value> callback) { |
26 if (IsUndefinedOrNull(callback)) | 26 if (IsUndefinedOrNull(callback)) |
27 return nullptr; | 27 return nullptr; |
28 return new VoidCallbackFunctionModules(scriptState, v8::Local<v8::Function>::C
ast(callback)); | 28 return new VoidCallbackFunctionModules(scriptState, v8::Local<v8::Function>::C
ast(callback)); |
29 } | 29 } |
30 | 30 |
31 VoidCallbackFunctionModules::VoidCallbackFunctionModules(ScriptState* scriptStat
e, v8::Local<v8::Function> callback) | 31 VoidCallbackFunctionModules::VoidCallbackFunctionModules(ScriptState* scriptStat
e, v8::Local<v8::Function> callback) |
32 : m_scriptState(scriptState), | 32 : script_state_(scriptState), |
33 m_callback(scriptState->GetIsolate(), this, callback) { | 33 m_callback(scriptState->GetIsolate(), this, callback) { |
34 DCHECK(!m_callback.IsEmpty()); | 34 DCHECK(!m_callback.IsEmpty()); |
35 } | 35 } |
36 | 36 |
37 DEFINE_TRACE_WRAPPERS(VoidCallbackFunctionModules) { | 37 DEFINE_TRACE_WRAPPERS(VoidCallbackFunctionModules) { |
38 visitor->TraceWrappers(m_callback.Cast<v8::Value>()); | 38 visitor->TraceWrappers(m_callback.Cast<v8::Value>()); |
39 } | 39 } |
40 | 40 |
41 bool VoidCallbackFunctionModules::call(ScriptWrappable* scriptWrappable) { | 41 bool VoidCallbackFunctionModules::call(ScriptWrappable* scriptWrappable) { |
42 if (m_callback.IsEmpty()) | 42 if (m_callback.IsEmpty()) |
43 return false; | 43 return false; |
44 | 44 |
45 if (!m_scriptState->ContextIsValid()) | 45 if (!script_state_->ContextIsValid()) |
46 return false; | 46 return false; |
47 | 47 |
48 ExecutionContext* context = ExecutionContext::From(m_scriptState.Get()); | 48 ExecutionContext* context = ExecutionContext::From(script_state_.Get()); |
49 DCHECK(context); | 49 DCHECK(context); |
50 if (context->IsContextSuspended() || context->IsContextDestroyed()) | 50 if (context->IsContextSuspended() || context->IsContextDestroyed()) |
51 return false; | 51 return false; |
52 | 52 |
53 // TODO(bashi): Make sure that using DummyExceptionStateForTesting is OK. | 53 // TODO(bashi): Make sure that using DummyExceptionStateForTesting is OK. |
54 // crbug.com/653769 | 54 // crbug.com/653769 |
55 DummyExceptionStateForTesting exceptionState; | 55 DummyExceptionStateForTesting exceptionState; |
56 ScriptState::Scope scope(m_scriptState.Get()); | 56 ScriptState::Scope scope(script_state_.Get()); |
57 v8::Isolate* isolate = m_scriptState->GetIsolate(); | 57 v8::Isolate* isolate = script_state_->GetIsolate(); |
58 | 58 |
59 v8::Local<v8::Value> thisValue = ToV8( | 59 v8::Local<v8::Value> thisValue = ToV8( |
60 scriptWrappable, | 60 scriptWrappable, |
61 m_scriptState->GetContext()->Global(), | 61 script_state_->GetContext()->Global(), |
62 isolate); | 62 isolate); |
63 | 63 |
64 v8::Local<v8::Value> *argv = nullptr; | 64 v8::Local<v8::Value> *argv = nullptr; |
65 v8::TryCatch exceptionCatcher(isolate); | 65 v8::TryCatch exceptionCatcher(isolate); |
66 exceptionCatcher.SetVerbose(true); | 66 exceptionCatcher.SetVerbose(true); |
67 | 67 |
68 v8::Local<v8::Value> v8ReturnValue; | 68 v8::Local<v8::Value> v8ReturnValue; |
69 if (!V8ScriptRunner::CallFunction(m_callback.NewLocal(isolate), | 69 if (!V8ScriptRunner::CallFunction(m_callback.NewLocal(isolate), |
70 context, | 70 context, |
71 thisValue, | 71 thisValue, |
72 0, | 72 0, |
73 argv, | 73 argv, |
74 isolate).ToLocal(&v8ReturnValue)) { | 74 isolate).ToLocal(&v8ReturnValue)) { |
75 return false; | 75 return false; |
76 } | 76 } |
77 | 77 |
78 return true; | 78 return true; |
79 } | 79 } |
80 | 80 |
81 VoidCallbackFunctionModules* NativeValueTraits<VoidCallbackFunctionModules>::Nat
iveValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& excep
tionState) { | 81 VoidCallbackFunctionModules* NativeValueTraits<VoidCallbackFunctionModules>::Nat
iveValue(v8::Isolate* isolate, v8::Local<v8::Value> value, ExceptionState& excep
tionState) { |
82 VoidCallbackFunctionModules* nativeValue = VoidCallbackFunctionModules::Create
(ScriptState::Current(isolate), value); | 82 VoidCallbackFunctionModules* nativeValue = VoidCallbackFunctionModules::Create
(ScriptState::Current(isolate), value); |
83 if (!nativeValue) { | 83 if (!nativeValue) { |
84 exceptionState.ThrowTypeError(ExceptionMessages::FailedToConvertJSValue( | 84 exceptionState.ThrowTypeError(ExceptionMessages::FailedToConvertJSValue( |
85 "VoidCallbackFunctionModules")); | 85 "VoidCallbackFunctionModules")); |
86 } | 86 } |
87 return nativeValue; | 87 return nativeValue; |
88 } | 88 } |
89 | 89 |
90 } // namespace blink | 90 } // namespace blink |
OLD | NEW |