Index: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp |
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp |
index 66ff5e9878de7af7e6908e3d3e8172891bd9e37a..dbbdd31c7338485e01adca84981790b2bc81b001 100644 |
--- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp |
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp |
@@ -201,7 +201,7 @@ const AtomicString& PaymentRequest::interfaceName() const |
ExecutionContext* PaymentRequest::getExecutionContext() const |
{ |
- return m_scriptState->getExecutionContext(); |
+ return ContextLifecycleObserver::getExecutionContext(); |
} |
ScriptPromise PaymentRequest::complete(ScriptState* scriptState, bool success) |
@@ -223,10 +223,11 @@ DEFINE_TRACE(PaymentRequest) |
visitor->trace(m_showResolver); |
visitor->trace(m_completeResolver); |
EventTargetWithInlineData::trace(visitor); |
+ ContextLifecycleObserver::trace(visitor); |
} |
PaymentRequest::PaymentRequest(ScriptState* scriptState, const Vector<String>& supportedMethods, const PaymentDetails& details, const PaymentOptions& options, const ScriptValue& data, ExceptionState& exceptionState) |
- : m_scriptState(scriptState) |
+ : ContextLifecycleObserver(scriptState->getExecutionContext()) |
, m_supportedMethods(supportedMethods) |
, m_details(details) |
, m_options(options) |
@@ -297,6 +298,11 @@ PaymentRequest::PaymentRequest(ScriptState* scriptState, const Vector<String>& s |
m_shippingOption = details.shippingOptions().begin()->id(); |
} |
+void PaymentRequest::contextDestroyed() |
+{ |
+ cleanUp(); |
+} |
+ |
void PaymentRequest::OnShippingAddressChange(mojom::wtf::ShippingAddressPtr address) |
{ |
DCHECK(m_showResolver); |
@@ -360,7 +366,8 @@ void PaymentRequest::cleanUp() |
{ |
m_completeResolver.clear(); |
m_showResolver.clear(); |
- m_clientBinding.Close(); |
+ if (m_clientBinding.is_bound()) |
+ m_clientBinding.Close(); |
m_paymentProvider.reset(); |
} |