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

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp

Issue 1863053005: PaymentRequest should be a ContextLifecycleObserver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@frame-service
Patch Set: Created 4 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
« no previous file with comments | « third_party/WebKit/Source/modules/payments/PaymentRequest.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 b69172abecbece10bd8898535c21a88f15900245..762d772fc721eeb552e84a302d4f4b7051671425 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
@@ -201,18 +201,7 @@ const AtomicString& PaymentRequest::interfaceName() const
ExecutionContext* PaymentRequest::getExecutionContext() const
{
- return m_scriptState->getExecutionContext();
-}
-
-ScriptPromise PaymentRequest::complete(ScriptState* scriptState, bool success)
-{
- if (m_completeResolver)
- return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "Already called complete() once"));
-
- m_completeResolver = ScriptPromiseResolver::create(scriptState);
- m_paymentProvider->Complete(success);
-
- return m_completeResolver->promise();
+ return ContextLifecycleObserver::getExecutionContext();
}
DEFINE_TRACE(PaymentRequest)
@@ -223,10 +212,11 @@ DEFINE_TRACE(PaymentRequest)
visitor->trace(m_showResolver);
visitor->trace(m_completeResolver);
RefCountedGarbageCollectedEventTargetWithInlineData<PaymentRequest>::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 +287,22 @@ PaymentRequest::PaymentRequest(ScriptState* scriptState, const Vector<String>& s
m_shippingOption = details.shippingOptions().begin()->id();
}
+ScriptPromise PaymentRequest::complete(ScriptState* scriptState, bool success)
+{
+ if (m_completeResolver)
+ return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "Already called complete() once"));
+
+ m_completeResolver = ScriptPromiseResolver::create(scriptState);
+ m_paymentProvider->Complete(success);
+
+ return m_completeResolver->promise();
+}
+
+void PaymentRequest::contextDestroyed()
+{
+ cleanUp();
+}
+
void PaymentRequest::OnShippingAddressChange(mojom::wtf::ShippingAddressPtr address)
{
DCHECK(m_showResolver);
« no previous file with comments | « third_party/WebKit/Source/modules/payments/PaymentRequest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698