Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for default feature state overrides using static map #10878

Merged
merged 4 commits into from
Nov 11, 2021

Conversation

goodov
Copy link
Member

@goodov goodov commented Nov 4, 2021

Resolves brave/brave-browser#18829

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@@ -210,76 +188,13 @@ bool BraveMainDelegate::BasicStartupComplete(int* exit_code) {
command_line.AppendSwitchASCII(variations::switches::kVariationsServerURL,
kVariationsServerURL.c_str());

// Enabled features.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JFTR: I've checked all enabled features one by one to confirm all were properly migrated and that seems to be the case 👍


// Disabled features.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JFTR: I've checked all disabled features one by one to confirm all were properly migrated and that seems to be the case 👍

Copy link
Contributor

@iefremov iefremov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@goodov
Copy link
Member Author

goodov commented Nov 10, 2021

Sorry reviewers, I decided to went with a single macro which should be used to bulk-override all .cc-local features. This way the base::flat_map::sort_and_unique on insert will be called only once for each macro instantiation instead of for each feature override. And now only one macro instantiation is allowed in a .cc file.

Feel free to review once more. Sorry again :) I added this change as a new commit on top.

constexpr Feature kTestConstexprDisabledButOverridenFeature{
"TestConstexprDisabledButOverridenFeature", FEATURE_ENABLED_BY_DEFAULT};

OVERRIDE_FEATURE_DEFAULT_STATES({{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the way this macro should be used is intentional. If we put { or {{ inside the macro, then clang-format wouldn't be able to properly format lines which are #if defined(...). Example:

OVERRIDE_FEATURE_DEFAULT_STATES({
  {kReadLater, base::FEATURE_DISABLED_BY_DEFAULT},
#if defined(OS_ANDROID)
      {kReadLater2, base::FEATURE_DISABLED_BY_DEFAULT},
#endif
      {kReadLater3, base::FEATURE_DISABLED_BY_DEFAULT},
});

@goodov goodov force-pushed the issues/18829-static-map branch from f8e96a9 to a035be5 Compare November 10, 2021 10:29
Copy link
Contributor

@mariospr mariospr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (also liked the latest changes 👍 )


namespace internal {

FeatureDefaultStateOverride::FeatureDefaultStateOverride(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am probably missing something obvious here, but why do this via a class and construct all those global objects instead of using a global function to populate the map?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The question is at what point you have to populate the map and how to make sure it will happen in all processes. The global construction approach make it so in each process (utility, renderer, etc), the map is populated at the very start regardless of what Chromium/Brave delegate is called or not.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see, yep, that totally makes sense. 👍

Copy link
Collaborator

@mkarolin mkarolin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++

@goodov goodov force-pushed the issues/18829-static-map branch from a035be5 to a1b29ca Compare November 11, 2021 07:23
@goodov goodov merged commit ad2ce27 into master Nov 11, 2021
@goodov goodov deleted the issues/18829-static-map branch November 11, 2021 10:57
@goodov goodov added this to the 1.34.x - Nightly milestone Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support upstream features override (in code) with ability to Griffin-override on top
4 participants