0

RuntimeEnabledFeatures: Generate base::Feature by default

This CL changes the interpretation of base_feature field:

Before this CL:
  <not specified> => No base::Feature generation
  base_feature: "Foo" => Generates a base::Feature with the name "Foo"

After this CL:
  <not specified> => Generates a base::Feature with the name as the
                     "name" field value
  base_feature: "Foo" => Generates a base::Feature with the name "Foo"
  base_feature: "none" => No base::Feature generation

runtime_enabled_features.json5 is updated so that:
 - Remove `base_feature` if its value is same as "name" field value
 - Add `base_feature: "none"` if the entry has no `base_feature`.

This CL should have no user-visible behavior changes.

Bug: 1416399
Change-Id: Ibab124033c511f0707b6a4654cc653c306614392
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4259085
Auto-Submit: Kent Tamura <tkent@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: Rick Byers <rbyers@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1106623}
This commit is contained in:
Kent Tamura
2023-02-17 04:18:38 +00:00
committed by Chromium LUCI CQ
parent 897a00b596
commit 0bc0a453bd
4 changed files with 548 additions and 160 deletions

@ -36,8 +36,9 @@ The following fields of an entry are relevant:
trial to be enabled. The list values are case-insensitive, but must match one
of the defined `OS_<platform>` macros (see [build_config.h]).
- `base_feature`: Generates a `base::Feature` in the `blink::features`
namespace. It helps to control the Origin Trial remotely. See also
[Generate a `base::Feature` instance from a Blink Feature][from blink].
namespace if the value is not `"none"`. It helps to control the Origin Trial
remotely. See also [Generate a `base::Feature` instance from a Blink Feature]
[from blink].
Not specific to Origin Trial:
@ -63,18 +64,19 @@ same:
{
name: "MyFeature", // Generates `RuntimeEnabledFeatures::MyFeatureEnabled()`
origin_trial_feature_name: "MyFeature",
base_feature: "MyFeature", // Generates blink::features::kMyFeature
status: "experimental",
// No need to specify base_feature.
},
```
RuntimeEnabledFeature flag name and trial name are different:
RuntimeEnabledFeature flag name, trial name, and `base::Feature` name are
different:
```json
{
name: "MyFeature",
origin_trial_feature_name: "MyFeatureTrial",
base_feature: "MyFeature", // Generates blink::features::kMyFeature
base_feature: "MyBaseFeature", // Generates blink::features::kMyBaseFeature
status: "experimental",
},
```

@ -73,6 +73,10 @@ class BaseRuntimeFeatureWriter(json5_generator.Writer):
# Specify the type of status
feature['status_type'] = "dict" if isinstance(
feature['status'], dict) else "str"
if feature['base_feature'] == 'none':
feature['base_feature'] = ''
elif feature['base_feature'] == '':
feature['base_feature'] = feature['name']
self._origin_trial_features = [
feature for feature in self._features if feature['in_origin_trial']

@ -78,9 +78,10 @@ If a feature is not stable and no longer under active development, remove `statu
In some cases, e.g. for finch experiment, you may need to define a Chromium
feature for a blink feature. If you need a Chromium feature just for finch
experiment for a blink feature, see the next section. Otherwise,
their relationship is defined in [content/child/runtime_features.cc]. See the
[initialize blink features] doc for more details.
experiment for a blink feature, see the next section. Otherwise, you should
specify `base_feature: "none"`, and their relationship is defined in
[content/child/runtime_features.cc]. See the [initialize blink features] doc
for more details.
**Note:** If a feature is implemented at both Chromium side and blink side, as the blink feature doesn't fully work by itself, we normally don't set the blink feature's status so that the Chromium feature can fully control the blink feature ([example][controlled by chromium feature]).
@ -90,16 +91,16 @@ the feature entry in `runtime_enabled_features.json5`.
### Generate a `base::Feature` instance from a Blink Feature
If your feature is guarded only by a blink feature and you need to prepare
Finch experiment for the feature, including a kill switch, you can
generate a `base::Feature` instance for the blink feature entry by adding:
A Blink feature entry generates a corresponding `base::Feature` instance with
the same name in `blink::features` namespace by default. It's helpful for a
Finch experiment for the feature, including a kill switch.
```js
base_feature: "AmazingNewFeature",
```
Specify `base_feature: "AnotherFlagName"` if you'd like to generate a
`base::Feature` with a different name.
It generates a `base::Feature` instance as `kAmazingNewFeature` in
`blink::features` namespace. The `base_feature` value is used for the feature
Specify `base_feature: "none"` to disable `base::Feature` generation.
The name specified by `base_feature` or `name` is used for the feature
name which is referred in `--enable-features=` flag and Finch configurations.
The generated `base::Feature` is enabled by default if the status of the blink

File diff suppressed because it is too large Load Diff