-
Notifications
You must be signed in to change notification settings - Fork 868
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
Move away from using base::{Bind,Callback,Closure}() #8811
Conversation
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.
Rewards changes look good.
virtual void GetPublisherMinVisitTime( | ||
const GetPublisherMinVisitTimeCallback& callback) = 0; | ||
GetPublisherMinVisitTimeCallback callback) = 0; |
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.
Thanks for these fixes!
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 pleasure!
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 for wallet, ipfs, decentralized DNS changes.
base::Bind( | ||
&BraveRewardsNativeWorker::OnBalance, | ||
weak_factory_.GetWeakPtr())); | ||
rewards_service->FetchBalance(base::BindRepeating( |
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.
@mariospr can you check this file also? I found that all methods from RewardsService
receives once callback type?
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.
Oops! Another instance of this, sorry. Fixed now too (+ reviewed again the PR and couldn't find more problems)
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 for not-owned files except browser/brave_rewards/android/brave_rewards_native_worker.cc
This patch migrates from base::Bind() to base::BindRepeating(), and from base::{Callback,Closure} to base::Repeating{Callback,Closure} just to unblock the Cr92 rebase while the right fix is not yet, merged to master (see #8811). Chromium changes: https://chromium.googlesource.com/chromium/src/+/6cc94b53393c1275843e43d3bbd6eda1f40fdd78 commit 6cc94b53393c1275843e43d3bbd6eda1f40fdd78 Author: Colin Blundell <blundell@chromium.org> Date: Wed May 5 11:13:38 2021 +0000 [base::Bind conversion] Remove deprecated APIs This CL removes the following deprecated APIs: - base::Bind() - base::Callback - base::Closure - base::CancelableCallback - base::CancelableClosure It also converts the remaining simple usages of these APIs that the removal shook out. The behavior that these APIs provided is still available the *Repeating* variants. However, consider strongly whether using these variants is actually necessary in your case or whether the *Once* variants will suffice: unless your callback *objects* (note: not variables!) need to be called multiple times, they most likely can and should be the Once variants. Bug: 714018
browser/net lgtm |
@@ -636,6 +642,10 @@ void BraveRewardsAttestPromotionFunction::OnAttestPromotion( | |||
Respond(TwoArguments(base::Value(static_cast<int>(result)), std::move(data))); | |||
} | |||
|
|||
BraveRewardsGetPendingContributionsTotalFunction:: | |||
BraveRewardsGetPendingContributionsTotalFunction() | |||
: weak_factory_(this) {} |
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.
functions are refcounted, so I gather we don't need weak pointers for them
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.
Good point. I'll remove this and also update the other pre-existing cases in that file.
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
rewards_service->GetAnonWalletStatus(base::Bind( | ||
&BraveRewardsGetAnonWalletStatusFunction::OnGetAnonWalletStatus, | ||
this)); | ||
rewards_service->GetAnonWalletStatus(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.
@mariospr this is not valid as is, just pass this
as it was before. Bind
will accept a refcounted pointer
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.
Oops! true... fixed now, sorry for the second overlook
base::{Bind,Callback,Closure}() have been deprecatedfor a while now, are finally gone on Chromium 92, so it would be good to migrate all current instances in the code (and stop introducing new ones) to the Once/Repeating variants instead to easy further rebases. This patch changes ALL instances of those old definitions and move to using the Once variants whenever possible (as they are preferred) and Repeating variants in every other case. Last, this patch also makes some changes in brave_rewards_api.{h,cc} to use weak pointers instead of base::Unretained() when binding callbacks, for extra safety (and consistency with existing code). [1] https://chromium-review.googlesource.com/c/chromium/src/+/2867526 Resolves brave/brave-browser#15855
Thanks for the reviews everyone. Android and Mac bots failed with unrelated failures so merging |
base::{Bind,Callback,Closure}() have been deprecatedfor a while now,
are finally gone on Chromium 92, so it would be good to migrate all
current instances in the code (and stop introducing new ones) to the
Once/Repeating variants instead to easy further rebases.
This patch changes ALL instances of those old definitions and move
to using the Once variants whenever possible (as they are preferred)
and Repeating variants in every other case.
Last, this patch also makes some changes in brave_rewards_api.{h,cc}
to use weak pointers instead of base::Unretained() when binding
callbacks, for extra safety (and consistency with existing code).
[1] https://chromium-review.googlesource.com/c/chromium/src/+/2867526
Resolves brave/brave-browser#15855
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
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on