Commit dc1dbf1a authored by Anthony Vallee-Dubois's avatar Anthony Vallee-Dubois Committed by Commit Bot

[Web Payments] User weak ptr in Payment Request's error callback

Bug: 742329
Change-Id: I73b2043c63f814d0394ed745eb6b1e55814db339
Reviewed-on: https://chromium-review.googlesource.com/570982
Commit-Queue: Anthony Vallee-Dubois <anthonyvd@chromium.org>
Reviewed-by: default avatarMathieu Perreault <mathp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#487077}
parent bf700714
......@@ -36,14 +36,15 @@ PaymentRequest::PaymentRequest(
observer_for_testing_(observer_for_testing),
journey_logger_(delegate_->IsIncognito(),
web_contents_->GetLastCommittedURL(),
delegate_->GetUkmRecorder()) {
delegate_->GetUkmRecorder()),
weak_ptr_factory_(this) {
// OnConnectionTerminated will be called when the Mojo pipe is closed. This
// will happen as a result of many renderer-side events (both successful and
// erroneous in nature).
// TODO(crbug.com/683636): Investigate using
// set_connection_error_with_reason_handler with Binding::CloseWithReason.
binding_.set_connection_error_handler(base::Bind(
&PaymentRequest::OnConnectionTerminated, base::Unretained(this)));
&PaymentRequest::OnConnectionTerminated, weak_ptr_factory_.GetWeakPtr()));
}
PaymentRequest::~PaymentRequest() {}
......
......@@ -9,6 +9,7 @@
#include <vector>
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "components/payments/content/payment_request_spec.h"
#include "components/payments/content/payment_request_state.h"
#include "components/payments/core/journey_logger.h"
......@@ -126,6 +127,8 @@ class PaymentRequest : public mojom::PaymentRequest,
// Whether a completion was already recorded for this Payment Request.
bool has_recorded_completion_ = false;
base::WeakPtrFactory<PaymentRequest> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(PaymentRequest);
};
......
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