Bug 1442453 - Pass objects around instead of string IDs in the child. r=baku

The existing code only passed strings around to identify PaymentRequest
objects. That meant that we were constantly having to do hashtable lookups to
find the corresponding object. This patch just uses the single map that IPDL
maintains for us and passes objects around, obviating the need for more
hashtable lookups.

MozReview-Commit-ID: 6BBonrc6q4x
This commit is contained in:
Blake Kaplan
2018-05-31 16:20:51 -07:00
parent 6b5fbee0d9
commit 4d7ad7575b
6 changed files with 74 additions and 140 deletions

View File

@@ -666,7 +666,7 @@ PaymentRequest::CanMakePayment(ErrorResult& aRv)
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
nsresult rv = manager->CanMakePayment(mInternalId);
nsresult rv = manager->CanMakePayment(this);
if (NS_WARN_IF(NS_FAILED(rv))) {
promise->MaybeReject(NS_ERROR_FAILURE);
return promise.forget();
@@ -719,7 +719,7 @@ PaymentRequest::Show(const Optional<OwningNonNull<Promise>>& aDetailsPromise,
mDeferredShow = true;
}
nsresult rv = manager->ShowPayment(mInternalId);
nsresult rv = manager->ShowPayment(this);
if (NS_WARN_IF(NS_FAILED(rv))) {
if (rv == NS_ERROR_ABORT) {
promise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
@@ -768,7 +768,7 @@ PaymentRequest::RespondShowPayment(const nsAString& aMethodName,
mFullShippingAddress = nullptr;
RefPtr<PaymentResponse> paymentResponse =
new PaymentResponse(GetOwner(), mInternalId, mId, aMethodName,
new PaymentResponse(GetOwner(), this, mId, aMethodName,
mShippingOption, mShippingAddress, aDetails,
aPayerName, aPayerEmail, aPayerPhone);
mResponse = paymentResponse;