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

Unified Diff: third_party/WebKit/Source/bindings/templates/callback_function.h

Issue 2312093003: Generated bindings for IDL callback functions (Closed)
Patch Set: Addressed comments Created 4 years, 3 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.h
diff --git a/third_party/WebKit/Source/bindings/templates/callback_function.h b/third_party/WebKit/Source/bindings/templates/callback_function.h
new file mode 100644
index 0000000000000000000000000000000000000000..8658d35fac7c5c539788cff347f7acdfbc5476f8
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/templates/callback_function.h
@@ -0,0 +1,50 @@
+{% filter format_blink_cpp_source_code %}
+
+{% include 'copyright_block.txt' %}
+
+#ifndef {{v8_class}}_h
+#define {{v8_class}}_h
+
+{% for filename in header_includes %}
+#include "{{filename}}"
+{% endfor %}
+
+namespace blink {
+
+class ScriptState;
+
+class {{exported}}{{v8_class}} final : public GarbageCollectedFinalized<{{v8_class}}> {
+
+public:
+ static {{v8_class}}* create(v8::Isolate* isolate, v8::Local<v8::Function> callback)
+ {
+ return new {{v8_class}}(isolate, callback);
+ }
+
+ ~{{v8_class}}() = default;
+
+ DECLARE_TRACE();
+
+ bool call({{argument_declarations | join(', ')}});
+
+ v8::Local<v8::Function> v8Value(v8::Isolate* isolate)
+ {
+ return m_callback.newLocal(isolate);
+ }
+
+ void setWrapperReference(v8::Isolate* isolate, const v8::Persistent<v8::Object>& wrapper)
+ {
+ DCHECK(!m_callback.isEmpty());
+ m_callback.setReference(wrapper, isolate);
+ }
+
+private:
+ {{v8_class}}(v8::Isolate* isolate, v8::Local<v8::Function>);
+ ScopedPersistent<v8::Function> m_callback;
+};
+
+} // namespace blink
+
+#endif // {{v8_class}}_h
+
+{% endfilter %}{# format_blink_cpp_source_code #}

Powered by Google App Engine
This is Rietveld 408576698