Commit 928b9963 authored by Hyungwook Lee's avatar Hyungwook Lee Committed by Commit Bot

Apply chromium coding style in RuntimeEnabledFeatures.{h,cpp}

Bug: 710276
Change-Id: Iccfad531196cd9789e0cc21d52b06e4205249cd4
Reviewed-on: https://chromium-review.googlesource.com/657998Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Cr-Commit-Position: refs/heads/master@{#501522}
parent 916a6ce1
...@@ -31,6 +31,7 @@ import sys ...@@ -31,6 +31,7 @@ import sys
import json5_generator import json5_generator
import name_utilities import name_utilities
from name_utilities import class_member_name
from name_utilities import lower_first from name_utilities import lower_first
import template_expander import template_expander
...@@ -48,14 +49,15 @@ class RuntimeFeatureWriter(json5_generator.Writer): ...@@ -48,14 +49,15 @@ class RuntimeFeatureWriter(json5_generator.Writer):
# Make sure the resulting dictionaries have all the keys we expect. # Make sure the resulting dictionaries have all the keys we expect.
for feature in self._features: for feature in self._features:
feature['first_lowered_name'] = lower_first(feature['name']) feature['first_lowered_name'] = lower_first(feature['name'])
feature['class_member_name'] = class_member_name(feature['name'])
# Most features just check their isFooEnabled bool # Most features just check their isFooEnabled bool
# but some depend on or are implied by other bools. # but some depend on or are implied by other bools.
enabled_condition = 'is%sEnabled' % feature['name'] enabled_condition = 'is_%senabled_' % feature['class_member_name']
assert not feature['implied_by'] or not feature['depends_on'], 'Only one of implied_by and depends_on is allowed' assert not feature['implied_by'] or not feature['depends_on'], 'Only one of implied_by and depends_on is allowed'
for implied_by_name in feature['implied_by']: for implied_by_name in feature['implied_by']:
enabled_condition += ' || is%sEnabled' % implied_by_name enabled_condition += ' || is_%senabled_' % class_member_name(implied_by_name)
for dependant_name in feature['depends_on']: for dependant_name in feature['depends_on']:
enabled_condition += ' && is%sEnabled' % dependant_name enabled_condition += ' && is_%senabled_' % class_member_name(dependant_name)
feature['enabled_condition'] = enabled_condition feature['enabled_condition'] = enabled_condition
self._standard_features = [feature for feature in self._features if not feature['custom']] self._standard_features = [feature for feature in self._features if not feature['custom']]
self._origin_trial_features = [feature for feature in self._features if feature['origin_trial_feature_name']] self._origin_trial_features = [feature for feature in self._features if feature['origin_trial_feature_name']]
......
...@@ -32,21 +32,41 @@ import re ...@@ -32,21 +32,41 @@ import re
# Acronyms are kept as all caps. # Acronyms are kept as all caps.
ACRONYMS = [ ACRONYMS = [
'2D',
'2G',
'3D', '3D',
'CSSOM', '3G',
'API',
'CORS',
'CSP',
'CSS', 'CSS',
'CSSOM',
'DNS', 'DNS',
'DOM',
'FE', 'FE',
'FTP', 'FTP',
'GL',
'HTML', 'HTML',
'IDB',
'IFrame',
'JS', 'JS',
'NFC',
'NG',
'OM',
'RFC',
'RTCRtp',
'SMIL', 'SMIL',
'SVG', 'SVG',
'UI',
'URL', 'URL',
'USB',
'VR',
'VTT',
'WOFF', 'WOFF',
'XML', 'XML',
'XSLT', 'XSLT',
'XSS', 'XSS',
'YUV',
] ]
......
...@@ -12,14 +12,14 @@ namespace blink { ...@@ -12,14 +12,14 @@ namespace blink {
RuntimeEnabledFeatures::Backup::Backup() RuntimeEnabledFeatures::Backup::Backup()
: {% for feature in standard_features -%} : {% for feature in standard_features -%}
{{feature.first_lowered_name}}_(RuntimeEnabledFeatures::{{feature.name}}Enabled()) {{feature.class_member_name}}(RuntimeEnabledFeatures::{{feature.name}}Enabled())
{%- if not loop.last %}, {%- if not loop.last %},
{%+ endif -%} {%+ endif -%}
{% endfor %} {} {% endfor %} {}
void RuntimeEnabledFeatures::Backup::Restore() { void RuntimeEnabledFeatures::Backup::Restore() {
{% for feature in standard_features %} {% for feature in standard_features %}
RuntimeEnabledFeatures::Set{{feature.name}}Enabled({{feature.first_lowered_name}}_); RuntimeEnabledFeatures::Set{{feature.name}}Enabled({{feature.class_member_name}});
{% endfor %} {% endfor %}
} }
...@@ -45,7 +45,7 @@ void RuntimeEnabledFeatures::SetFeatureEnabledFromString( ...@@ -45,7 +45,7 @@ void RuntimeEnabledFeatures::SetFeatureEnabledFromString(
bool* setting; bool* setting;
} kFeatures[] = { } kFeatures[] = {
{% for feature in standard_features %} {% for feature in standard_features %}
{"{{feature.name}}", &is{{feature.name}}Enabled}, {"{{feature.name}}", &is_{{feature.class_member_name}}enabled_},
{% endfor %} {% endfor %}
}; };
for (const auto& feature : kFeatures) { for (const auto& feature : kFeatures) {
...@@ -58,7 +58,7 @@ void RuntimeEnabledFeatures::SetFeatureEnabledFromString( ...@@ -58,7 +58,7 @@ void RuntimeEnabledFeatures::SetFeatureEnabledFromString(
} }
{% for feature in standard_features %} {% for feature in standard_features %}
bool RuntimeEnabledFeatures::is{{feature.name}}Enabled = {{'true' if feature.status == 'stable' else 'false'}}; bool RuntimeEnabledFeatures::is_{{feature.class_member_name}}enabled_ = {{'true' if feature.status == 'stable' else 'false'}};
{% endfor %} {% endfor %}
} // namespace blink } // namespace blink
...@@ -26,7 +26,7 @@ class PLATFORM_EXPORT RuntimeEnabledFeatures { ...@@ -26,7 +26,7 @@ class PLATFORM_EXPORT RuntimeEnabledFeatures {
private: private:
{% for feature in standard_features %} {% for feature in standard_features %}
bool {{feature.first_lowered_name}}_; bool {{feature.class_member_name}};
{% endfor %} {% endfor %}
}; };
...@@ -35,13 +35,13 @@ class PLATFORM_EXPORT RuntimeEnabledFeatures { ...@@ -35,13 +35,13 @@ class PLATFORM_EXPORT RuntimeEnabledFeatures {
{% endfor %} {% endfor %}
static void SetOriginTrialControlledFeaturesEnabled(bool); static void SetOriginTrialControlledFeaturesEnabled(bool);
static void SetFeatureEnabledFromString(const std::string& name, bool isEnabled); static void SetFeatureEnabledFromString(const std::string& name, bool enabled);
{% for feature in features %} {% for feature in features %}
{% if feature.custom %} {% if feature.custom %}
static bool {{feature.name}}Enabled(); static bool {{feature.name}}Enabled();
{% else %} {% else %}
static void Set{{feature.name}}Enabled(bool isEnabled) { is{{feature.name}}Enabled = isEnabled; } static void Set{{feature.name}}Enabled(bool enabled) { is_{{feature.class_member_name}}enabled_ = enabled; }
static bool {{feature.name}}Enabled() { return {{feature.enabled_condition}}; } static bool {{feature.name}}Enabled() { return {{feature.enabled_condition}}; }
{% endif %} {% endif %}
...@@ -49,7 +49,7 @@ class PLATFORM_EXPORT RuntimeEnabledFeatures { ...@@ -49,7 +49,7 @@ class PLATFORM_EXPORT RuntimeEnabledFeatures {
private: private:
{% for feature in standard_features %} {% for feature in standard_features %}
static bool is{{feature.name}}Enabled; static bool is_{{feature.class_member_name}}enabled_;
{% endfor %} {% endfor %}
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment