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

Unified Diff: third_party/WebKit/Source/bindings/scripts/v8_utilities.py

Issue 1531443003: [bindings] Implement an ExperimentEnabled IDL extended attribute. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: More sharing. Created 5 years 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/scripts/v8_utilities.py
diff --git a/third_party/WebKit/Source/bindings/scripts/v8_utilities.py b/third_party/WebKit/Source/bindings/scripts/v8_utilities.py
index cb770bb9492051f5897afb10dd0e83c8c1c585f9..4fbb77c847c23852c231e04d2131dae0bdb4206a 100644
--- a/third_party/WebKit/Source/bindings/scripts/v8_utilities.py
+++ b/third_party/WebKit/Source/bindings/scripts/v8_utilities.py
@@ -380,19 +380,55 @@ def measure_as(definition_or_member, interface):
return None
+def is_api_experiment_enabled(interface):
+ return 'APIExperimentEnabled' in interface.extended_attributes
+
+
+def api_experiment_name(interface):
+ return interface.extended_attributes['APIExperimentEnabled'] if is_api_experiment_enabled(interface) else None
+
+
# [RuntimeEnabled]
def runtime_enabled_function_name(definition_or_member):
+ """Returns a conditional string which defines if a given
+ method/attribute is enabled at runtime. This is based on the RuntimeEnabled
+ and the API Experiment Enabled conditionals.
+ """
+ extended_attributes = definition_or_member.extended_attributes
+ runtime_conditional = runtime_enabled_conditional(extended_attributes)
+ experiment_conditional = api_experiment_enabled_conditional(extended_attributes)
+
+ if runtime_conditional is not None and experiment_conditional is not None:
+ return ('%s && %s' % (runtime_conditional, experiment_conditional))
+ return runtime_conditional if runtime_conditional else experiment_conditional
+
+
+def runtime_enabled_conditional(extended_attributes):
"""Returns the name of the RuntimeEnabledFeatures function.
The returned function checks if a method/attribute is enabled.
Given extended attribute RuntimeEnabled=FeatureName, return:
RuntimeEnabledFeatures::{featureName}Enabled
"""
- extended_attributes = definition_or_member.extended_attributes
if 'RuntimeEnabled' not in extended_attributes:
return None
feature_name = extended_attributes['RuntimeEnabled']
- return 'RuntimeEnabledFeatures::%sEnabled' % uncapitalize(feature_name)
+ runtime_function = 'RuntimeEnabledFeatures::%sEnabled()' % uncapitalize(feature_name)
+ return runtime_function
+
+
+# [APIExperimentEnabled]
+def api_experiment_enabled_conditional(extended_attributes):
+ """Returns the name of the API Experiment Enabled function.
+
+ The returned function checks if a method/attribute is enabled.
+ Given extended attribute APIExperimentEnabled=ExperimentName, return:
+ Experiments::isApiEnabled(currentExecutionContext(isolate),
+ "{ExperimentName}")
+ """
+ if 'APIExperimentEnabled' not in extended_attributes:
+ return None
+ return 'Experiments::isApiEnabled(currentExecutionContext(isolate), "%s")' % extended_attributes['APIExperimentEnabled']
# [Unforgeable]

Powered by Google App Engine
This is Rietveld 408576698