-
Notifications
You must be signed in to change notification settings - Fork 965
Use AdBlockDefaultResourceUpdateInterval
for all adblock-related components
#21868
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
Conversation
components/brave_shields/browser/ad_block_component_installer.cc
Outdated
Show resolved
Hide resolved
void AdBlockComponentServiceManager::CheckAdBlockComponentsUpdate() { | ||
auto runner = base::SequencedTaskRunner::GetCurrentDefault(); | ||
|
||
runner->PostDelayedTask(FROM_HERE, base::BindOnce([]() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @atuchin-m noted at https://github.com/brave/brave-core/pull/20557/files#r1365810455,
It would be great if we could update in a bunch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed... I don't think we have any API exposed for this though.
The best thing I've found so far is this UpdateClient::Update
method that takes multiple component IDs, but we can't call it directly (would have to plumb multiple levels of patching). There's also CrxUpdateService::CheckForUpdates
, although we don't have the ability to customize the list of components checked. Maybe that's ok?
@atuchin-m do you have any recommendations?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- My point is we'd better optimize the number of requests to the backend to check the update. If we want to update the set of components, ideally we should done the one request.
UpdateClient::Update
looks like an internal thing.CheckForUpdates
looks better, maybe it's okay to check the update of all the brave components.- Anyway, scheduling a number of task with random delays doesn't looks reasonable to me. 10 sec usually is not enough to process an update. Do you sure that the next PostTasks don't cancel the previous ones?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also BraveOnDemandUpdater
uses priority FOREGROUND
, that means there is no chance to combine the requests together. CheckForUpdates
uses the same priority internally.
I believe the first thing to do is to understand the right priority to use. if it's BACKGROUND
then it's look okay to use CheckForUpdates
. Otherwise I believe we need to add CrxUpdateService::OnDemandUpdateMultipleIds
via chromium_src here
@iefremov do we have someone who is familiar with component_updater internals?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm somewhat familiar with component_updater internals.
@@ -251,6 +262,35 @@ void AdBlockComponentServiceManager::EnableFilterList(const std::string& uuid, | |||
UpdateFilterListPrefs(uuid, enabled); | |||
} | |||
|
|||
void AdBlockComponentServiceManager::CheckAdBlockComponentsUpdate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For brave/brave-browser#35216, the UI will want to know when this process completes (so that it can show a spinner and updated text, and also an indication if the process fails).
Could this method accept a callback that gets executed when all component updates are done? Or is there some other approach we want to take?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now OnDemandUpdate
has a hardcoded no-op callback. I suppose this could be changed, but let's see if @atuchin-m has any thoughts on the API we should use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we could add on demand callback in BraveOnDemandUpdate
. Also no problem to use chromium OnDemandUpdater
directly (a chromium example)
Also installing or updating a components has a several stages.
- Updating the component (including downloading .crx)
- Unpacking .crx and registering the new version
- Processing the content by a client code (=the adblock code here).
The callback is about 2 (maybe 1), but definitely not about 3.
Please be sure that you're waiting for the right things.
b0b67b8
to
4861d72
Compare
update_check_timer_.Start( | ||
FROM_HERE, base::Minutes(kComponentUpdateCheckIntervalMins.Get()), | ||
base::BindRepeating( | ||
[](base::WeakPtr<AdBlockComponentServiceManager> component_manager) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: what about base::BindRepeating(AdBlockComponentServiceManager::CheckAdBlockComponentsUpdate, weak_factory_.GetWeakPtr())
?
}), | ||
base::Seconds(base::RandInt(0, 10))); | ||
|
||
runner->PostDelayedTask(FROM_HERE, base::BindOnce([]() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please optimize identical blocks here?
There is 3 about the same runner->PostDelayedTask
in the method. I hope we could merge it in the one.
void AdBlockComponentServiceManager::CheckAdBlockComponentsUpdate() { | ||
auto runner = base::SequencedTaskRunner::GetCurrentDefault(); | ||
|
||
runner->PostDelayedTask(FROM_HERE, base::BindOnce([]() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- My point is we'd better optimize the number of requests to the backend to check the update. If we want to update the set of components, ideally we should done the one request.
UpdateClient::Update
looks like an internal thing.CheckForUpdates
looks better, maybe it's okay to check the update of all the brave components.- Anyway, scheduling a number of task with random delays doesn't looks reasonable to me. 10 sec usually is not enough to process an update. Do you sure that the next PostTasks don't cancel the previous ones?
void AdBlockComponentServiceManager::CheckAdBlockComponentsUpdate() { | ||
auto runner = base::SequencedTaskRunner::GetCurrentDefault(); | ||
|
||
runner->PostDelayedTask(FROM_HERE, base::BindOnce([]() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also BraveOnDemandUpdater
uses priority FOREGROUND
, that means there is no chance to combine the requests together. CheckForUpdates
uses the same priority internally.
I believe the first thing to do is to understand the right priority to use. if it's BACKGROUND
then it's look okay to use CheckForUpdates
. Otherwise I believe we need to add CrxUpdateService::OnDemandUpdateMultipleIds
via chromium_src here
@iefremov do we have someone who is familiar with component_updater internals?
@@ -251,6 +262,35 @@ void AdBlockComponentServiceManager::EnableFilterList(const std::string& uuid, | |||
UpdateFilterListPrefs(uuid, enabled); | |||
} | |||
|
|||
void AdBlockComponentServiceManager::CheckAdBlockComponentsUpdate() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe we could add on demand callback in BraveOnDemandUpdate
. Also no problem to use chromium OnDemandUpdater
directly (a chromium example)
Also installing or updating a components has a several stages.
- Updating the component (including downloading .crx)
- Unpacking .crx and registering the new version
- Processing the content by a client code (=the adblock code here).
The callback is about 2 (maybe 1), but definitely not about 3.
Please be sure that you're waiting for the right things.
4861d72
to
43dcdf1
Compare
43dcdf1
to
706d9f7
Compare
components/brave_shields/core/browser/ad_block_component_service_manager.cc
Outdated
Show resolved
Hide resolved
components/brave_shields/core/browser/ad_block_component_service_manager.cc
Outdated
Show resolved
Hide resolved
components/brave_shields/core/browser/ad_block_component_service_manager.cc
Outdated
Show resolved
Hide resolved
3262d17
to
a7996b7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with few more nits.
"UwNavFnj8gQDGVvCf+dse8HRMJn00QH0MOypsZSWFZRmF08ybOu/jTiUo/TuIaHL" | ||
"1H8y9SR970LqsUMozu3ioSHtFh/IVgq7Nqy4TljaKsTE+3AdtjiOyHpW9ZaOkA7j" | ||
"2QIDAQAB"; | ||
|
||
const char kCookieListEnabledHistogram[] = "Brave.Shields.CookieListEnabled"; | ||
const char kCookieListPromptHistogram[] = "Brave.Shields.CookieListPrompt"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expected you to make all strings here to be inline constexpr
. What you have right now is wrong.
45654a4
to
1eba796
Compare
1eba796
to
835551c
Compare
Resolves brave/brave-browser#35164
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run lint
,npm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: