Commit 7ae1af52 authored by Jun Cai's avatar Jun Cai Committed by Commit Bot

Convert base::bind in //components/payments to Once or Repeating

This CL converts base::bind in //components/payments to Once or
Repeating. The choice of using BindOnce or BindRepeating is
based on the existing parameter types in the calling functions,
which is either OnceCallback or RepeatingCallback, and it can be
directly mapped to using BindOnce or BindRepeating.

Bug: 1007715
Change-Id: Ifa18e05b3715d10916a7760eb2ed156e92e5a5e4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2099234Reviewed-by: default avatarLiquan (Max) Gu <maxlg@chromium.org>
Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Commit-Queue: Jun Cai <juncai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#749717}
parent 55f1ff72
......@@ -90,8 +90,8 @@ class PaymentAppTest : public testing::TestWithParam<RequiredPaymentOptions>,
GURL("https://testmerchant.com/bobpay"), spec_.get(),
std::move(stored_app), &delegate_,
/*identity_callback=*/
base::Bind([](const url::Origin&,
int64_t) { /* Intentionally left blank. */ }));
base::BindRepeating([](const url::Origin&,
int64_t) { /* Intentionally left blank. */ }));
}
std::unique_ptr<ServiceWorkerPaymentApp>
......@@ -121,8 +121,8 @@ class PaymentAppTest : public testing::TestWithParam<RequiredPaymentOptions>,
GURL("https://merchant.example/iframe"), spec_.get(),
std::move(installable_app), "https://pay.example", &delegate_,
/*identity_callback=*/
base::Bind([](const url::Origin&,
int64_t) { /* Intentionally left blank. */ }));
base::BindRepeating([](const url::Origin&,
int64_t) { /* Intentionally left blank. */ }));
}
static void PopulateIcon(SkBitmap* icon) {
......
......@@ -24,8 +24,9 @@ void PaymentManifestWebDataService::AddPaymentWebAppManifest(
std::vector<WebAppManifestSection> manifest) {
wdbs_->ScheduleDBTask(
FROM_HERE,
base::Bind(&PaymentManifestWebDataService::AddPaymentWebAppManifestImpl,
this, std::move(manifest)));
base::BindOnce(
&PaymentManifestWebDataService::AddPaymentWebAppManifestImpl, this,
std::move(manifest)));
}
WebDatabase::State PaymentManifestWebDataService::AddPaymentWebAppManifestImpl(
......@@ -44,8 +45,9 @@ void PaymentManifestWebDataService::AddPaymentMethodManifest(
std::vector<std::string> app_package_names) {
wdbs_->ScheduleDBTask(
FROM_HERE,
base::Bind(&PaymentManifestWebDataService::AddPaymentMethodManifestImpl,
this, payment_method, std::move(app_package_names)));
base::BindOnce(
&PaymentManifestWebDataService::AddPaymentMethodManifestImpl, this,
payment_method, std::move(app_package_names)));
}
WebDatabase::State PaymentManifestWebDataService::AddPaymentMethodManifestImpl(
......@@ -66,8 +68,9 @@ PaymentManifestWebDataService::GetPaymentWebAppManifest(
WebDataServiceConsumer* consumer) {
return wdbs_->ScheduleDBTaskWithResult(
FROM_HERE,
base::Bind(&PaymentManifestWebDataService::GetPaymentWebAppManifestImpl,
this, web_app),
base::BindOnce(
&PaymentManifestWebDataService::GetPaymentWebAppManifestImpl, this,
web_app),
consumer);
}
......@@ -88,8 +91,9 @@ PaymentManifestWebDataService::GetPaymentMethodManifest(
WebDataServiceConsumer* consumer) {
return wdbs_->ScheduleDBTaskWithResult(
FROM_HERE,
base::Bind(&PaymentManifestWebDataService::GetPaymentMethodManifestImpl,
this, payment_method),
base::BindOnce(
&PaymentManifestWebDataService::GetPaymentMethodManifestImpl, this,
payment_method),
consumer);
}
......
......@@ -85,7 +85,7 @@ class PaymentRequestStateTest : public testing::Test,
GURL("https://example.com/pay"),
url::Origin::Create(GURL("https://example.com")), spec_.get(), this,
"en-US", &test_personal_data_manager_, &test_payment_request_delegate_,
base::Bind(
base::BindRepeating(
[](const url::Origin& origin,
int64_t registration_id) { /* Intentionally left blank. */ }),
&journey_logger_);
......
......@@ -51,8 +51,8 @@ class ServiceWorkerPaymentAppCreator {
delegate_->GetTopOrigin(), delegate_->GetFrameOrigin(),
delegate_->GetSpec(), std::move(installed_app.second),
delegate_->GetPaymentRequestDelegate(),
base::Bind(&PaymentAppFactory::Delegate::OnPaymentAppInstalled,
delegate_));
base::BindRepeating(
&PaymentAppFactory::Delegate::OnPaymentAppInstalled, delegate_));
app->ValidateCanMakePayment(base::BindOnce(
&ServiceWorkerPaymentAppCreator::OnSWPaymentAppValidated,
weak_ptr_factory_.GetWeakPtr()));
......@@ -66,8 +66,8 @@ class ServiceWorkerPaymentAppCreator {
delegate_->GetFrameOrigin(), delegate_->GetSpec(),
std::move(installable_app.second), installable_app.first.spec(),
delegate_->GetPaymentRequestDelegate(),
base::Bind(&PaymentAppFactory::Delegate::OnPaymentAppInstalled,
delegate_));
base::BindRepeating(
&PaymentAppFactory::Delegate::OnPaymentAppInstalled, delegate_));
app->ValidateCanMakePayment(base::BindOnce(
&ServiceWorkerPaymentAppCreator::OnSWPaymentAppValidated,
weak_ptr_factory_.GetWeakPtr()));
......@@ -131,8 +131,8 @@ void ServiceWorkerPaymentAppFactory::Create(base::WeakPtr<Delegate> delegate) {
delegate->GetPaymentRequestDelegate()->GetPaymentManifestWebDataService(),
delegate->GetSpec()->method_data(),
delegate->MayCrawlForInstallablePaymentApps(),
base::Bind(&ServiceWorkerPaymentAppCreator::CreatePaymentApps,
creator_raw_pointer->GetWeakPtr()),
base::BindOnce(&ServiceWorkerPaymentAppCreator::CreatePaymentApps,
creator_raw_pointer->GetWeakPtr()),
base::BindOnce([]() {
// Nothing needs to be done after writing cache. This callback is used
// only in tests.
......
......@@ -116,7 +116,7 @@ class ServiceWorkerPaymentAppTest : public testing::Test,
&browser_context_, GURL("https://testmerchant.com"),
GURL("https://testmerchant.com/bobpay"), spec_.get(),
std::move(stored_app), &delegate_,
base::Bind(
base::BindRepeating(
[](const url::Origin& origin,
int64_t registration_id) { /* Intentionally left blank. */ }));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment