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
import json5_generator
import name_utilities
from name_utilities import class_member_name
from name_utilities import lower_first
import template_expander
......@@ -48,14 +49,15 @@ class RuntimeFeatureWriter(json5_generator.Writer):
# Make sure the resulting dictionaries have all the keys we expect.
for feature in self._features:
feature['first_lowered_name'] = lower_first(feature['name'])
feature['class_member_name'] = class_member_name(feature['name'])
# Most features just check their isFooEnabled bool
# 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'
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']:
enabled_condition += ' && is%sEnabled' % dependant_name
enabled_condition += ' && is_%senabled_' % class_member_name(dependant_name)
feature['enabled_condition'] = enabled_condition
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']]
......
......@@ -32,21 +32,41 @@ import re
# Acronyms are kept as all caps.
ACRONYMS = [
'2D',
'2G',
'3D',
'CSSOM',
'3G',
'API',
'CORS',
'CSP',
'CSS',
'CSSOM',
'DNS',
'DOM',
'FE',
'FTP',
'GL',
'HTML',
'IDB',
'IFrame',
'JS',
'NFC',
'NG',
'OM',
'RFC',
'RTCRtp',
'SMIL',
'SVG',
'UI',
'URL',
'USB',
'VR',
'VTT',
'WOFF',
'XML',
'XSLT',
'XSS',
'YUV',
]
......
......@@ -12,14 +12,14 @@ namespace blink {
RuntimeEnabledFeatures::Backup::Backup()
: {% 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 %},
{%+ endif -%}
{% endfor %} {}
void RuntimeEnabledFeatures::Backup::Restore() {
{% for feature in standard_features %}
RuntimeEnabledFeatures::Set{{feature.name}}Enabled({{feature.first_lowered_name}}_);
RuntimeEnabledFeatures::Set{{feature.name}}Enabled({{feature.class_member_name}});
{% endfor %}
}
......@@ -45,7 +45,7 @@ void RuntimeEnabledFeatures::SetFeatureEnabledFromString(
bool* setting;
} kFeatures[] = {
{% for feature in standard_features %}
{"{{feature.name}}", &is{{feature.name}}Enabled},
{"{{feature.name}}", &is_{{feature.class_member_name}}enabled_},
{% endfor %}
};
for (const auto& feature : kFeatures) {
......@@ -58,7 +58,7 @@ void RuntimeEnabledFeatures::SetFeatureEnabledFromString(
}
{% 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 %}
} // namespace blink
......@@ -26,7 +26,7 @@ class PLATFORM_EXPORT RuntimeEnabledFeatures {
private:
{% for feature in standard_features %}
bool {{feature.first_lowered_name}}_;
bool {{feature.class_member_name}};
{% endfor %}
};
......@@ -35,13 +35,13 @@ class PLATFORM_EXPORT RuntimeEnabledFeatures {
{% endfor %}
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 %}
{% if feature.custom %}
static bool {{feature.name}}Enabled();
{% 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}}; }
{% endif %}
......@@ -49,7 +49,7 @@ class PLATFORM_EXPORT RuntimeEnabledFeatures {
private:
{% for feature in standard_features %}
static bool is{{feature.name}}Enabled;
static bool is_{{feature.class_member_name}}enabled_;
{% 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