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

Remove cosmetic filtering extension version #9995

Merged
merged 2 commits into from
Sep 8, 2021

Conversation

antonok-edm
Copy link
Collaborator

Resolves brave/brave-browser#17918

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:

This change has already been enabled by default using Griffin for quite some time, so we should be fine without any additional testing.

@antonok-edm antonok-edm self-assigned this Sep 7, 2021
@antonok-edm antonok-edm force-pushed the remove-cosmetic-filtering-extension-version branch from bf5dde9 to efd2e4b Compare September 7, 2021 22:01
@antonok-edm antonok-edm force-pushed the remove-cosmetic-filtering-extension-version branch from efd2e4b to ff223a5 Compare September 7, 2021 22:06
Copy link
Collaborator

@atuchin-m atuchin-m left a comment

Choose a reason for hiding this comment

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

I can confirm that this fix performance issues on ParseHTML stage, thx!

if (custom_selectors && custom_selectors->is_list())
hide_selectors->Append(std::move(*custom_selectors));
if (custom_selectors && custom_selectors->is_list()) {
for (auto i = custom_selectors->GetList().begin();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe for (auto i : custom_selectors->GetList()) ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sadly I don't think this is an option because of base::Value - auto i and auto* i aren't allowed, and auto& i prevents me from std::moveing the value inside the loop.

Copy link
Member

@SergeyZhukovsky SergeyZhukovsky left a comment

Choose a reason for hiding this comment

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

++

ExtensionFunction::ResponseAction
BraveShieldsShouldDoCosmeticFilteringFunction::Run() {
#if !defined(OS_ANDROID) && !defined(CHROME_OS)
if (base::FeatureList::IsEnabled(
Copy link
Contributor

Choose a reason for hiding this comment

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

pls double-check unused headers, e.g. #include "base/feature_list.h" or #include "brave/components/brave_shields/common/features.h", maybe anything else

Copy link
Contributor

Choose a reason for hiding this comment

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

#include "brave/browser/brave_browser_process.h"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We still have e.g.

  auto* custom_filters_service =
      g_brave_browser_process->ad_block_custom_filters_service();

so I can't remove brave_browser_process.h, but I removed the others


private:
std::unique_ptr<base::ListValue> GetHiddenClassIdSelectorsOnTaskRunner(
const std::vector<std::string>& classes,
Copy link
Contributor

Choose a reason for hiding this comment

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

vector is no longer used

if (!hide_selectors || !hide_selectors->is_list())
hide_selectors = base::ListValue();

if (custom_selectors && custom_selectors->is_list())
hide_selectors->Append(std::move(*custom_selectors));
Copy link
Contributor

Choose a reason for hiding this comment

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

why did we used to append a list?..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

great question 😅

I don't think it was correct. We had a couple of changes there when adding support for both backends in parallel, and I think something broke in the meantime. I think brave/brave-browser#17013 was caused by this, but I've tried manually and it's fixed with these changes. I'll look into getting test coverage for it.

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.

Remove extension-based cosmetic filtering backend
5 participants