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

Side by Side Diff: third_party/WebKit/Source/bindings/tests/results/modules/VoidCallbackFunctionModules.cpp

Issue 2755603003: [Refactor] Update template files for callback functions (Closed)
Patch Set: work for comments Created 3 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/bindings/tests/results/modules/VoidCallbackFunctionModules.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 // clang-format off 11 // clang-format off
12 12
13 #include "VoidCallbackFunctionModules.h" 13 #include "VoidCallbackFunctionModules.h"
14 14
15 #include "bindings/core/v8/ExceptionState.h" 15 #include "bindings/core/v8/ExceptionState.h"
16 #include "bindings/core/v8/ScriptState.h" 16 #include "bindings/core/v8/ScriptState.h"
17 #include "bindings/core/v8/ToV8.h" 17 #include "bindings/core/v8/ToV8.h"
18 #include "bindings/core/v8/V8Binding.h" 18 #include "bindings/core/v8/V8Binding.h"
19 #include "core/dom/ExecutionContext.h" 19 #include "core/dom/ExecutionContext.h"
20 #include "wtf/Assertions.h" 20 #include "wtf/Assertions.h"
21 21
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 : m_scriptState(scriptState),
33 m_callback(scriptState->isolate(), this, callback) { 33 m_callback(scriptState->isolate(), this, callback) {
34 DCHECK(!m_callback.isEmpty()); 34 DCHECK(!m_callback.isEmpty());
35 } 35 }
36 36
37 DEFINE_TRACE(VoidCallbackFunctionModules) {}
38
39 DEFINE_TRACE_WRAPPERS(VoidCallbackFunctionModules) { 37 DEFINE_TRACE_WRAPPERS(VoidCallbackFunctionModules) {
40 visitor->traceWrappers(m_callback.cast<v8::Value>()); 38 visitor->traceWrappers(m_callback.cast<v8::Value>());
41 } 39 }
42 40
43 bool VoidCallbackFunctionModules::call(ScriptWrappable* scriptWrappable) { 41 bool VoidCallbackFunctionModules::call(ScriptWrappable* scriptWrappable) {
42 if (m_callback.isEmpty())
43 return false;
44
44 if (!m_scriptState->contextIsValid()) 45 if (!m_scriptState->contextIsValid())
45 return false; 46 return false;
46 47
47 ExecutionContext* context = m_scriptState->getExecutionContext(); 48 ExecutionContext* context = m_scriptState->getExecutionContext();
48 DCHECK(context); 49 DCHECK(context);
49 if (context->isContextSuspended() || context->isContextDestroyed()) 50 if (context->isContextSuspended() || context->isContextDestroyed())
50 return false; 51 return false;
51 52
52 if (m_callback.isEmpty())
53 return false;
54
55 // TODO(bashi): Make sure that using DummyExceptionStateForTesting is OK. 53 // TODO(bashi): Make sure that using DummyExceptionStateForTesting is OK.
56 // crbug.com/653769 54 // crbug.com/653769
57 DummyExceptionStateForTesting exceptionState; 55 DummyExceptionStateForTesting exceptionState;
58 ScriptState::Scope scope(m_scriptState.get()); 56 ScriptState::Scope scope(m_scriptState.get());
57 v8::Isolate* isolate = m_scriptState->isolate();
59 58
60 v8::Local<v8::Value> thisValue = ToV8(scriptWrappable, m_scriptState->context( )->Global(), m_scriptState->isolate()); 59 v8::Local<v8::Value> thisValue = ToV8(
60 scriptWrappable,
61 m_scriptState->context()->Global(),
62 isolate);
61 63
62 v8::Local<v8::Value> *argv = nullptr; 64 v8::Local<v8::Value> *argv = nullptr;
65 v8::TryCatch exceptionCatcher(isolate);
66 exceptionCatcher.SetVerbose(true);
63 67
64 v8::Local<v8::Value> v8ReturnValue; 68 v8::Local<v8::Value> v8ReturnValue;
65 v8::TryCatch exceptionCatcher(m_scriptState->isolate()); 69 if (!V8ScriptRunner::callFunction(m_callback.newLocal(isolate),
66 exceptionCatcher.SetVerbose(true); 70 context,
71 thisValue,
72 0,
73 argv,
74 isolate).ToLocal(&v8ReturnValue)) {
75 return false;
76 }
67 77
68 if (V8ScriptRunner::callFunction(m_callback.newLocal(m_scriptState->isolate()) , m_scriptState->getExecutionContext(), thisValue, 0, argv, m_scriptState->isola te()).ToLocal(&v8ReturnValue)) { 78 return true;
69 return true;
70 }
71 return false;
72 } 79 }
73 80
74 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) {
75 return VoidCallbackFunctionModules::create(ScriptState::current(isolate), valu e); 82 return VoidCallbackFunctionModules::create(ScriptState::current(isolate), valu e);
76 } 83 }
77 84
78 } // namespace blink 85 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/tests/results/modules/VoidCallbackFunctionModules.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698