Skip to content

Commit

Permalink
bindings: Rename ConditionalFeature to OriginTrialFeature
Browse files Browse the repository at this point in the history
Files introduced in https://crrev.com/487917 are still focusing on
only origin trials. It is confusing until it introduces other
conditional features.
Beside it, this name "ConditionalFeatures" is easy to conflict with
other methods in bindings code generation.

So this CL renames them to use OriginTrial.


TBR=dpranke

Bug: 615060
Change-Id: I4ae8bd559fe3c1af09b5313a03bc009f05b79b6f
Reviewed-on: https://chromium-review.googlesource.com/770517
Commit-Queue: Hitoshi Yoshida <peria@chromium.org>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Ian Clelland <iclelland@chromium.org>
Cr-Commit-Position: refs/heads/master@{#516949}
  • Loading branch information
peria authored and Commit Bot committed Nov 16, 2017
1 parent dfc102e commit 1ee1fb8
Show file tree
Hide file tree
Showing 33 changed files with 406 additions and 406 deletions.
2 changes: 1 addition & 1 deletion WATCHLISTS
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@
},
'feature_policy': {
'filepath': 'third_party/WebKit/Source/platform/feature_policy/|' \
'third_party/WebKit/Source/bindings/core/v8/ConditionalFeatures',
'third_party/WebKit/Source/bindings/core/v8/OriginTrialFeatures',
},
'fileapi': {
'filepath': 'file_system/|' \
Expand Down
6 changes: 3 additions & 3 deletions third_party/WebKit/Source/bindings/core/v8/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ generated_core_callback_function_files = [
"$bindings_core_v8_output_dir/v8_resize_observer_callback.h",
]

generate_conditional_features("bindings_core_conditional_features") {
generate_origin_trial_features("bindings_core_origin_trial_features") {
sources = core_idl_files + core_idl_with_modules_dependency_files +
core_global_constructors_generated_idl_files
component = "Core"
Expand Down Expand Up @@ -232,10 +232,10 @@ blink_core_sources("bindings_core_impl") {
generated_core_testing_dictionary_files -
generated_core_testing_callback_function_files
sources = _non_testing_sources + bindings_core_generated_interface_files +
get_target_outputs(":bindings_core_conditional_features")
get_target_outputs(":bindings_core_origin_trial_features")

deps = [
":bindings_core_conditional_features",
":bindings_core_origin_trial_features",
":bindings_core_v8_generated",
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
#include "core/inspector/MainThreadDebugger.h"
#include "core/loader/FrameLoader.h"
#include "platform/Histogram.h"
#include "platform/bindings/ConditionalFeatures.h"
#include "platform/bindings/DOMWrapperWorld.h"
#include "platform/bindings/OriginTrialFeatures.h"
#include "platform/bindings/ScriptForbiddenScope.h"
#include "platform/bindings/V8DOMActivityLogger.h"
#include "platform/bindings/V8DOMWrapper.h"
Expand Down Expand Up @@ -174,15 +174,15 @@ void LocalWindowProxy::Initialize() {
GetFrame(), origin);
GetFrame()->Client()->DidCreateScriptContext(context, world_->GetWorldId());

InstallConditionalFeaturesOnGlobal(&V8Window::wrapperTypeInfo,
InstallOriginTrialFeaturesOnGlobal(&V8Window::wrapperTypeInfo,
script_state_.get());

if (world_->IsMainWorld()) {
// For the main world, install any remaining conditional bindings (i.e.
// for origin trials, which do not apply to extensions). Some conditional
// bindings cannot be enabled until the execution context is available
// (e.g. parsing the document, inspecting HTTP headers).
InstallConditionalFeatures(&V8Window::wrapperTypeInfo,
InstallOriginTrialFeatures(&V8Window::wrapperTypeInfo,
script_state_.get(), v8::Local<v8::Object>(),
v8::Local<v8::Function>());
GetFrame()->Loader().DispatchDidClearWindowObjectInMainWorld();
Expand Down
12 changes: 6 additions & 6 deletions third_party/WebKit/Source/bindings/core/v8/V8ContextSnapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#include "bindings/core/v8/V8Initializer.h"
#include "bindings/core/v8/V8Node.h"
#include "bindings/core/v8/V8Window.h"
#include "platform/bindings/ConditionalFeatures.h"
#include "platform/bindings/DOMWrapperWorld.h"
#include "platform/bindings/OriginTrialFeatures.h"
#include "platform/bindings/V8ObjectConstructor.h"
#include "platform/bindings/V8PerIsolateData.h"
#include "platform/bindings/V8PrivateProperty.h"
Expand Down Expand Up @@ -209,7 +209,7 @@ void V8ContextSnapshot::InstallRuntimeEnabledFeatures(
.As<v8::Object>();
V8Window::install_runtime_enabled_features_function_(
isolate, world, window_wrapper, prototype, interface);
InstallConditionalFeatures(type, script_state, prototype, interface);
InstallOriginTrialFeatures(type, script_state, prototype, interface);
}
{
const WrapperTypeInfo* type = &V8EventTarget::wrapperTypeInfo;
Expand All @@ -219,7 +219,7 @@ void V8ContextSnapshot::InstallRuntimeEnabledFeatures(
.As<v8::Object>();
V8EventTarget::InstallRuntimeEnabledFeatures(
isolate, world, v8::Local<v8::Object>(), prototype, interface);
InstallConditionalFeatures(type, script_state, prototype, interface);
InstallOriginTrialFeatures(type, script_state, prototype, interface);
}

if (!world.IsMainWorld()) {
Expand All @@ -240,7 +240,7 @@ void V8ContextSnapshot::InstallRuntimeEnabledFeatures(
.As<v8::Object>();
V8HTMLDocument::InstallRuntimeEnabledFeatures(
isolate, world, document_wrapper, prototype, interface);
InstallConditionalFeatures(type, script_state, prototype, interface);
InstallOriginTrialFeatures(type, script_state, prototype, interface);
}
{
const WrapperTypeInfo* type = &V8Document::wrapperTypeInfo;
Expand All @@ -250,7 +250,7 @@ void V8ContextSnapshot::InstallRuntimeEnabledFeatures(
.As<v8::Object>();
V8Document::InstallRuntimeEnabledFeatures(
isolate, world, v8::Local<v8::Object>(), prototype, interface);
InstallConditionalFeatures(type, script_state, prototype, interface);
InstallOriginTrialFeatures(type, script_state, prototype, interface);
}
{
const WrapperTypeInfo* type = &V8Node::wrapperTypeInfo;
Expand All @@ -260,7 +260,7 @@ void V8ContextSnapshot::InstallRuntimeEnabledFeatures(
.As<v8::Object>();
V8Node::InstallRuntimeEnabledFeatures(
isolate, world, v8::Local<v8::Object>(), prototype, interface);
InstallConditionalFeatures(type, script_state, prototype, interface);
InstallOriginTrialFeatures(type, script_state, prototype, interface);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "core/workers/WorkerGlobalScope.h"
#include "core/workers/WorkerOrWorkletGlobalScope.h"
#include "core/workers/WorkerThread.h"
#include "platform/bindings/ConditionalFeatures.h"
#include "platform/bindings/OriginTrialFeatures.h"
#include "platform/bindings/V8DOMWrapper.h"
#include "platform/bindings/V8ObjectConstructor.h"
#include "platform/bindings/WrapperTypeInfo.h"
Expand Down Expand Up @@ -238,7 +238,7 @@ bool WorkerOrWorkletScriptController::InitializeContextIfNeeded(
human_readable_name);
}

InstallConditionalFeaturesOnGlobal(wrapper_type_info, script_state_.get());
InstallOriginTrialFeaturesOnGlobal(wrapper_type_info, script_state_.get());

return true;
}
Expand Down
6 changes: 3 additions & 3 deletions third_party/WebKit/Source/bindings/modules/v8/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ idl_compiler("generate_bindings_modules_v8_partial_interfaces_for_testing") {
target_component = "modules"
}

generate_conditional_features("bindings_modules_conditional_features") {
generate_origin_trial_features("bindings_modules_origin_trial_features") {
sources =
modules_idl_files + modules_global_constructors_generated_idl_files +
modules_dependency_idl_files
Expand Down Expand Up @@ -104,10 +104,10 @@ blink_modules_sources("bindings_modules_impl") {
get_target_outputs(":bindings_modules_impl_generated") +
get_target_outputs(":generate_bindings_modules_v8_partial_interfaces") +
get_target_outputs(":bindings_modules_v8_generated_init_partial") +
get_target_outputs(":bindings_modules_conditional_features")
get_target_outputs(":bindings_modules_origin_trial_features")

deps = [
":bindings_modules_conditional_features",
":bindings_modules_origin_trial_features",
":bindings_modules_v8_generated",
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "bindings/modules/v8/ModuleBindingsInitializer.h"

#include "bindings/modules/v8/ConditionalFeaturesForModules.h"
#include "bindings/modules/v8/OriginTrialFeaturesForModules.h"
#include "bindings/modules/v8/serialization/SerializedScriptValueForModulesFactory.h"
#include "bindings/modules/v8/wasm/WasmResponseExtensions.h"
#include "platform/bindings/V8PerIsolateData.h"
Expand All @@ -16,7 +16,7 @@ namespace blink {
void InitPartialInterfacesInModules();

void ModuleBindingsInitializer::Init() {
RegisterInstallConditionalFeaturesForModules();
RegisterInstallOriginTrialFeaturesForModules();
InitPartialInterfacesInModules();
SerializedScriptValueFactory::Initialize(
new SerializedScriptValueForModulesFactory);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
MODULE_PYNAME = os.path.splitext(os.path.basename(__file__))[0] + '.py'


ConditionalInterfaceInfo = namedtuple('ConditionalInterfaceInfo', [
OriginTrialInterfaceInfo = namedtuple('OriginTrialInterfaceInfo', [
'name', 'v8_class', 'v8_class_or_partial', 'is_global'])


def get_install_functions(interfaces, feature_names):
"""Construct a list of V8 bindings installation functions for each feature
on each interface.
interfaces is a list of ConditionalInterfaceInfo tuples
interfaces is a list of OriginTrialInterfaceInfo tuples
feature_names is a list of strings, containing names of features which can
be installed on those interfaces.
"""
Expand All @@ -49,7 +49,7 @@ def get_install_functions(interfaces, feature_names):
for interface_info in interfaces]


def get_conditional_feature_names_from_interface(interface):
def get_origin_trial_feature_names_from_interface(interface):
feature_names = set()
if ('OriginTrialEnabled' in interface.extended_attributes and
interface.is_partial):
Expand Down Expand Up @@ -79,7 +79,7 @@ def interface_is_global(interface):
'PrimaryGlobal' in interface.extended_attributes)


def conditional_features_info(info_provider, reader, idl_filenames, target_component, snake_case):
def origin_trial_features_info(info_provider, reader, idl_filenames, target_component, snake_case):
"""Read a set of IDL files and compile the mapping between interfaces and
the conditional features defined on them.
Expand All @@ -95,7 +95,7 @@ def conditional_features_info(info_provider, reader, idl_filenames, target_compo

for idl_filename in idl_filenames:
interface, implements = read_idl_file(reader, idl_filename)
feature_names = get_conditional_feature_names_from_interface(interface)
feature_names = get_origin_trial_feature_names_from_interface(interface)

# If this interface implements another one,
# it inherits any conditional features from it.
Expand All @@ -104,7 +104,7 @@ def conditional_features_info(info_provider, reader, idl_filenames, target_compo
implemented_interface, _ = read_idl_file(
reader,
info_provider.interfaces_info[implement.right_interface].get('full_path'))
feature_names |= get_conditional_feature_names_from_interface(implemented_interface)
feature_names |= get_origin_trial_feature_names_from_interface(implemented_interface)

feature_names = list(feature_names)
if feature_names:
Expand All @@ -130,7 +130,7 @@ def conditional_features_info(info_provider, reader, idl_filenames, target_compo
# If this is a partial interface in the same component as
# its parent, then treat it as a non-partial interface.
interface.is_partial = False
interface_info = ConditionalInterfaceInfo(interface.name,
interface_info = OriginTrialInterfaceInfo(interface.name,
v8_class_name(interface),
v8_class_name_or_partial(
interface),
Expand All @@ -142,7 +142,7 @@ def conditional_features_info(info_provider, reader, idl_filenames, target_compo
return features_for_type, types_for_feature, includes


def conditional_features_context(generator_name, feature_info, snake_case):
def origin_trial_features_context(generator_name, feature_info, snake_case):
context = {'code_generator': generator_name}

# Unpack the feature info tuple.
Expand All @@ -154,7 +154,7 @@ def conditional_features_context(generator_name, feature_info, snake_case):
'core/dom/ExecutionContext.h',
'core/frame/Frame.h',
'core/origin_trials/origin_trials.h',
'platform/bindings/ConditionalFeatures.h',
'platform/bindings/OriginTrialFeatures.h',
'platform/bindings/ScriptState.h',
# TODO(iclelland): Remove the need to explicitly include this; it is
# here because the ContextFeatureSettings code needs it.
Expand Down Expand Up @@ -205,33 +205,33 @@ def parse_options():
return options


def generate_conditional_features(info_provider, options, idl_filenames):
def generate_origin_trial_features(info_provider, options, idl_filenames):
reader = IdlReader(info_provider.interfaces_info, options.cache_directory)
jinja_env = initialize_jinja_env(options.cache_directory)

# Extract the bidirectional mapping of conditional features <-> interfaces
# from the global info provider and the supplied list of IDL files.
feature_info = conditional_features_info(info_provider,
reader, idl_filenames,
options.target_component.lower(),
options.snake_case_generated_files)
feature_info = origin_trial_features_info(info_provider,
reader, idl_filenames,
options.target_component.lower(),
options.snake_case_generated_files)

# Convert that mapping into the context required for the Jinja2 templates.
template_context = conditional_features_context(
template_context = origin_trial_features_context(
MODULE_PYNAME, feature_info, options.snake_case_generated_files)

# Generate and write out the header file
header_text = render_template(jinja_env.get_template(
'ConditionalFeaturesFor%s.h.tmpl' % options.target_component.title()), template_context)
'OriginTrialFeaturesFor%s.h.tmpl' % options.target_component.title()), template_context)
header_path = posixpath.join(options.output_directory,
'ConditionalFeaturesFor%s.h' % options.target_component.title())
'OriginTrialFeaturesFor%s.h' % options.target_component.title())
write_file(header_text, header_path)

# Generate and write out the implementation file
cpp_text = render_template(jinja_env.get_template(
'ConditionalFeaturesFor%s.cpp.tmpl' % options.target_component.title()), template_context)
'OriginTrialFeaturesFor%s.cpp.tmpl' % options.target_component.title()), template_context)
cpp_path = posixpath.join(options.output_directory,
'ConditionalFeaturesFor%s.cpp' % options.target_component.title())
'OriginTrialFeaturesFor%s.cpp' % options.target_component.title())
write_file(cpp_text, cpp_path)


Expand All @@ -242,7 +242,7 @@ def main():
os.path.normpath(options.info_dir), options.target_component.lower())
idl_filenames = map(str.strip, open(options.idl_files_list))

generate_conditional_features(info_provider, options, idl_filenames)
generate_origin_trial_features(info_provider, options, idl_filenames)
return 0


Expand Down
16 changes: 8 additions & 8 deletions third_party/WebKit/Source/bindings/scripts/scripts.gni
Original file line number Diff line number Diff line change
Expand Up @@ -485,18 +485,18 @@ template("generate_global_constructors") {
}
}

# Calls the generate_conditional_features script.
# Calls the generate_origin_trial_features script.
#
# Parameters:
# sources = a list of source IDL files.
# component = component for which to generate conditional feature bindings
# component = component for which to generate origin trial feature bindings
# ("Core" or "Modules")
# output_dir = output directory to generate cpp file and header file.
# deps = dependencies
#
template("generate_conditional_features") {
template("generate_origin_trial_features") {
action(target_name) {
script = "//third_party/WebKit/Source/bindings/scripts/generate_conditional_features.py"
script = "//third_party/WebKit/Source/bindings/scripts/generate_origin_trial_features.py"

# Write the file list to a unique temp file to avoid blowing out the
# command line length limit.
Expand All @@ -505,8 +505,8 @@ template("generate_conditional_features") {

inputs = [
"//third_party/WebKit/Source/bindings/scripts/utilities.py",
"//third_party/WebKit/Source/bindings/templates/ConditionalFeaturesFor${invoker.component}.cpp.tmpl",
"//third_party/WebKit/Source/bindings/templates/ConditionalFeaturesFor${invoker.component}.h.tmpl",
"//third_party/WebKit/Source/bindings/templates/OriginTrialFeaturesFor${invoker.component}.cpp.tmpl",
"//third_party/WebKit/Source/bindings/templates/OriginTrialFeaturesFor${invoker.component}.h.tmpl",
idl_files_list,
] + invoker.sources

Expand All @@ -528,8 +528,8 @@ template("generate_conditional_features") {
]

outputs = [
"${invoker.output_dir}/ConditionalFeaturesFor${invoker.component}.cpp",
"${invoker.output_dir}/ConditionalFeaturesFor${invoker.component}.h",
"${invoker.output_dir}/OriginTrialFeaturesFor${invoker.component}.cpp",
"${invoker.output_dir}/OriginTrialFeaturesFor${invoker.component}.h",
]

# TODO: This should not always require modules; For core features, this
Expand Down
3 changes: 1 addition & 2 deletions third_party/WebKit/Source/bindings/scripts/v8_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,11 +459,10 @@ def interface_context(interface, interfaces):
prepare_prototype_and_interface_object_func = None # pylint: disable=invalid-name
if unscopables or conditionally_enabled_attributes_on_prototype_or_interface or conditionally_enabled_methods:
prepare_prototype_and_interface_object_func = '%s::preparePrototypeAndInterfaceObject' % v8_class_name_or_partial # pylint: disable=invalid-name
has_install_conditional_features_on_global_func = bool(conditionally_enabled_constructors) # pylint: disable=invalid-name

context.update({
'prepare_prototype_and_interface_object_func': prepare_prototype_and_interface_object_func,
'has_install_conditional_features_on_global_func': has_install_conditional_features_on_global_func,
'has_install_conditional_features_on_global_func': bool(conditionally_enabled_constructors),
})

context.update({
Expand Down

This file was deleted.

Loading

0 comments on commit 1ee1fb8

Please sign in to comment.