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

Unified Diff: third_party/WebKit/Source/bindings/templates/snapshot.cpp.tmpl

Issue 2841443005: [Bindings] Create and use V8 context snapshots (Closed)
Patch Set: Work for some comments 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/bindings/templates/snapshot.cpp.tmpl
diff --git a/third_party/WebKit/Source/bindings/templates/snapshot.cpp.tmpl b/third_party/WebKit/Source/bindings/templates/snapshot.cpp.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..8b8b819bf41ba43a2e1d6eaf62fb5ec0ef72ef34
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/templates/snapshot.cpp.tmpl
@@ -0,0 +1,120 @@
+{% filter format_blink_cpp_source_code %}
+
+{% include 'copyright_block.txt' %}
+
+#include "bindings/modules/v8/V8SnapshotReference.h"
+
+#include <cstdint>
+
+{% for include_file in include_files %}
+#include "{{include_file}}"
+{% endfor %}
+
+namespace blink {
+
+intptr_t* V8SnapshotReference::GetReferenceTable() {
+ static intptr_t reference_table[] = {
+ {% for interface in interfaces %}
+ {% if not interface.is_array_buffer_or_view %}
+ {% set namespace = interface.v8_name %}
+
+ {# Attributes #}
+ {%- for attribute in interface.attributes %}
+ {%- for world_suffix in attribute.world_suffixes %}
+ {% if not attribute.constructor_type %}
+ reinterpret_cast<intptr_t>({{namespace}}::{{attribute.name}}AttributeGetterCallback{{world_suffix}}),
+ {% elif attribute.needs_constructor_getter_callback %}
+ reinterpret_cast<intptr_t>({{namespace}}::{{attribute.name}}ConstructorGetterCallback{{world_suffix}}),
+ {% elif attribute.is_named_constructor %}
+ reinterpret_cast<intptr_t>(V8{{attribute.constructor_type}}::NamedConstructorAttributeGetter{{world_suffix}}),
+ {% endif %}
+ {% if attribute.has_setter %}
+ reinterpret_cast<intptr_t>({{namespace}}::{{attribute.name}}AttributeSetterCallback{{world_suffix}}),
+ {% endif %}
+ {%- endfor %}{# world_suffix #}
+ {%- endfor %}{# attributes #}
+
+ {# Methods / Operations #}
+ {% for method in interface.methods %}
+ {%- for world_suffix in method.world_suffixes %}
+ {% if not method.overload_index or method.overloads %}
+ {% if (method.overloads and method.overloads.visible and
+ (not method.overloads.has_partial_overloads or not interface.is_partial)) or
+ (not method.overloads and method.visible) %}
+ {# TODO(bashi): Remove this 'if' condition when crbug.com/630986 is fixed. #}
+ {% if not interface.is_callback %}
+ reinterpret_cast<intptr_t>({{namespace}}::{{method.name}}MethodCallback{{world_suffix}}),
+ {% endif %}
+ {% endif %}
+ {% endif %}{# overload(_index) #}
+ {% if method.is_cross_origin and method.visible %}
+ reinterpret_cast<intptr_t>({{namespace}}::{{method.name}}OriginSafeMethodGetterCallback{{world_suffix}}),
+ {% endif%}
+ {% endfor %}
+ {% endfor %}{# method #}
+ {% if interface.has_origin_safe_method_setter %}
+ reinterpret_cast<intptr_t>({{namespace}}::{{interface.name}}OriginSafeMethodSetterCallback),
+ {% endif %}
+ {% if interface.has_cross_origin_named_getter %}
+ reinterpret_cast<intptr_t>({{namespace}}::crossOriginNamedGetter),
+ {% endif %}
+ {% if interface.has_cross_origin_named_setter %}
+ reinterpret_cast<intptr_t>({{namespace}}::crossOriginNamedSetter),
+ {% endif %}
+ {% if interface.has_cross_origin_named_enumerator %}
+ reinterpret_cast<intptr_t>({{namespace}}::crossOriginNamedEnumerator),
+ {% endif %}
+ {% if interface.has_cross_origin_indexed_getter %}
+ reinterpret_cast<intptr_t>({{namespace}}::crossOriginIndexedGetter),
+ {% endif %}
+ {% if interface.has_security_check %}
+ reinterpret_cast<intptr_t>({{namespace}}::securityCheck),
+ {% endif %}
+
+ {# Other properties #}
+ {% if interface.named_property_getter %}
+ reinterpret_cast<intptr_t>({{namespace}}::namedPropertyGetterCallback),
+ {% endif %}
+ {%- if interface.named_property_setter %}
+ reinterpret_cast<intptr_t>({{namespace}}::namedPropertySetterCallback),
+ {% endif %}
+ {%- if interface.named_property_deleter %}
+ reinterpret_cast<intptr_t>({{namespace}}::namedPropertyDeleterCallback),
+ {% endif %}
+ {%- if interface.named_property_getter and interface.named_property_getter.is_enumerable %}
+ reinterpret_cast<intptr_t>({{namespace}}::namedPropertyQueryCallback),
+ reinterpret_cast<intptr_t>({{namespace}}::namedPropertyEnumeratorCallback),
+ {% endif %}
+ {%- if interface.indexed_property_getter %}
+ reinterpret_cast<intptr_t>({{namespace}}::indexedPropertyGetterCallback),
+ {% endif %}
+ {%- if interface.indexed_property_setter %}
+ reinterpret_cast<intptr_t>({{namespace}}::indexedPropertySetterCallback),
+ {% endif %}
+ {%- if interface.indexed_property_deleter %}
+ reinterpret_cast<intptr_t>({{namespace}}::indexedPropertyDeleterCallback),
+ {% endif %}
+ {% if interface.has_security_check_function %}
+ reinterpret_cast<intptr_t>({{namespace}}::securityCheck),
+ {%- endif %}
+ {% endif %}{# not is_array_buffer_or_view #}
+
+ {% if not interface.is_partial %}
+ reinterpret_cast<intptr_t>(&{{interface.v8_name}}::wrapperTypeInfo),
+ {% endif %}
+ {% if interface.named_constructor %}
+ reinterpret_cast<intptr_t>(&{{interface.v8_name}}Constructor::wrapperTypeInfo),
+ {% endif %}
+ {% endfor %}{# interfaces #}
+
+ reinterpret_cast<intptr_t>(V8ObjectConstructor::IsValidConstructorMode),
haraken 2017/05/20 19:10:03 Why do we need this?
peria 2017/05/30 08:25:44 it is referred from V8Window class
+ reinterpret_cast<intptr_t>(V8ConstructorAttributeGetter),
haraken 2017/05/20 19:10:03 Why do we need this?
peria 2017/05/30 08:25:44 ditto.
+ 0 // terminate with a null
haraken 2017/05/20 19:10:02 What happens if we forget to add some C++ referenc
peria 2017/05/30 08:25:44 v8::SnapshotCreator crashes if it hits unkown exte
+ };
+
+ return reference_table;
+}
+
+} // namespace blink
+
+{% endfilter %}{# format_blink_cpp_source_code #}

Powered by Google App Engine
This is Rietveld 408576698