Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Unified Diff: components/payments/content/payment_request.cc

Issue 2815723002: [Web Payments] Add Spinners and timeout while waiting for UpdateWith (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/payments/content/payment_request.cc
diff --git a/components/payments/content/payment_request.cc b/components/payments/content/payment_request.cc
index 15aee2c679179aa5b8350baa43e647edde7dd14a..cfa5a9f639aa465e9fe77a70fc0f6a176dbd1160 100644
--- a/components/payments/content/payment_request.cc
+++ b/components/payments/content/payment_request.cc
@@ -14,6 +14,10 @@
#include "content/public/browser/web_contents.h"
namespace payments {
+namespace {
+// When waiting for an UpdateWith call, timeout after 60 seconds.
+constexpr int kTimeoutDuration = 60;
+} // namespace
PaymentRequest::PaymentRequest(
content::WebContents* web_contents,
@@ -79,6 +83,7 @@ void PaymentRequest::UpdateWith(mojom::PaymentDetailsPtr details) {
OnConnectionTerminated();
return;
}
+ wait_timer_.Stop();
spec_->UpdateWith(std::move(details));
}
@@ -125,11 +130,21 @@ void PaymentRequest::OnPaymentResponseAvailable(
void PaymentRequest::OnShippingOptionIdSelected(
std::string shipping_option_id) {
+ // TODO(anthonyvd): display an error before terminating the connection.
+ wait_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeoutDuration),
+ this, &PaymentRequest::OnConnectionTerminated);
+ spec_->StartWaitingForUpdateWith(
+ PaymentRequestSpec::UpdateReason::SHIPPING_OPTION);
client_->OnShippingOptionChange(shipping_option_id);
}
void PaymentRequest::OnShippingAddressSelected(
mojom::PaymentAddressPtr address) {
+ // TODO(anthonyvd): display an error before terminating the connection.
+ wait_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(kTimeoutDuration),
+ this, &PaymentRequest::OnConnectionTerminated);
+ spec_->StartWaitingForUpdateWith(
+ PaymentRequestSpec::UpdateReason::SHIPPING_ADDRESS);
client_->OnShippingAddressChange(std::move(address));
}

Powered by Google App Engine
This is Rietveld 408576698