Chromium Code Reviews| Index: content/browser/payments/payment_app_database.cc |
| diff --git a/content/browser/payments/payment_app_database.cc b/content/browser/payments/payment_app_database.cc |
| index 51a4daee25104ff76f197335ea7dddcce7cde045..459ef46465e9ebc46179c17bc476d52be84fa7ea 100644 |
| --- a/content/browser/payments/payment_app_database.cc |
| +++ b/content/browser/payments/payment_app_database.cc |
| @@ -107,6 +107,20 @@ void PaymentAppDatabase::ReadAllManifests( |
| weak_ptr_factory_.GetWeakPtr(), callback)); |
| } |
| +void PaymentAppDatabase::DeletePaymentInstrument( |
| + const GURL& scope, |
| + const std::string& instrumentKey, |
| + DeletePaymentInstrumentCallback callback) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| + |
| + service_worker_context_->FindReadyRegistrationForPattern( |
| + scope, |
| + base::Bind( |
| + &PaymentAppDatabase::DidFindRegistrationToDeletePaymentInstrument, |
| + weak_ptr_factory_.GetWeakPtr(), instrumentKey, |
| + base::Passed(std::move(callback)))); |
|
please use gerrit instead
2017/04/25 15:21:40
Is base::Passed() necessary? I believe std::move()
zino
2017/04/25 21:48:51
The FindReadyRegistrationForPattern requires legac
|
| +} |
| + |
| void PaymentAppDatabase::ReadPaymentInstrument( |
| const GURL& scope, |
| const std::string& instrumentKey, |
| @@ -249,6 +263,52 @@ void PaymentAppDatabase::DidReadAllManifests( |
| callback.Run(std::move(manifests)); |
| } |
| +void PaymentAppDatabase::DidFindRegistrationToDeletePaymentInstrument( |
| + const std::string& instrument_key, |
| + DeletePaymentInstrumentCallback callback, |
| + ServiceWorkerStatusCode status, |
| + scoped_refptr<ServiceWorkerRegistration> registration) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| + if (status != SERVICE_WORKER_OK) { |
| + std::move(callback).Run(PaymentHandlerStatus::NO_ACTIVE_WORKER); |
| + return; |
| + } |
| + |
| + service_worker_context_->GetRegistrationUserData( |
| + registration->id(), {instrument_key}, |
| + base::Bind(&PaymentAppDatabase::DidFindPaymentInstrument, |
| + weak_ptr_factory_.GetWeakPtr(), registration->id(), |
| + instrument_key, base::Passed(std::move(callback)))); |
|
please use gerrit instead
2017/04/25 15:21:40
Same comment about base::Passed().
zino
2017/04/25 21:48:51
I already left a comment in above your comment.
|
| +} |
| + |
| +void PaymentAppDatabase::DidFindPaymentInstrument( |
| + int64_t registration_id, |
| + const std::string& instrument_key, |
| + DeletePaymentInstrumentCallback callback, |
| + const std::vector<std::string>& data, |
| + ServiceWorkerStatusCode status) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| + if (status != SERVICE_WORKER_OK || data.size() != 1) { |
| + std::move(callback).Run(PaymentHandlerStatus::NOT_FOUND); |
| + return; |
| + } |
| + |
| + service_worker_context_->ClearRegistrationUserData( |
| + registration_id, {instrument_key}, |
| + base::Bind(&PaymentAppDatabase::DidDeletePaymentInstrument, |
| + weak_ptr_factory_.GetWeakPtr(), |
| + base::Passed(std::move(callback)))); |
| +} |
| + |
| +void PaymentAppDatabase::DidDeletePaymentInstrument( |
| + DeletePaymentInstrumentCallback callback, |
| + ServiceWorkerStatusCode status) { |
| + DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| + return std::move(callback).Run(status == SERVICE_WORKER_OK |
| + ? PaymentHandlerStatus::SUCCESS |
| + : PaymentHandlerStatus::NOT_FOUND); |
| +} |
| + |
| void PaymentAppDatabase::DidFindRegistrationToReadPaymentInstrument( |
| const std::string& instrumentKey, |
| ReadPaymentInstrumentCallback callback, |