Bug 1385274 - Don't try to resolve WebAuthnManager::mPBackgroundCreationPromise twice r=jcj

This commit is contained in:
Tim Taubert 2017-07-28 15:53:42 +02:00
parent db40f0ec94
commit 0aee684c17
2 changed files with 25 additions and 8 deletions

View File

@ -239,14 +239,25 @@ WebAuthnManager::~WebAuthnManager()
MaybeClearTransaction();
}
already_AddRefed<MozPromise<nsresult, nsresult, false>>
RefPtr<WebAuthnManager::BackgroundActorPromise>
WebAuthnManager::GetOrCreateBackgroundActor()
{
bool ok = BackgroundChild::GetOrCreateForCurrentThread(this);
if (NS_WARN_IF(!ok)) {
ActorFailed();
MOZ_ASSERT(NS_IsMainThread());
PBackgroundChild *actor = BackgroundChild::GetForCurrentThread();
RefPtr<WebAuthnManager::BackgroundActorPromise> promise =
mPBackgroundCreationPromise.Ensure(__func__);
if (actor) {
ActorCreated(actor);
} else {
bool ok = BackgroundChild::GetOrCreateForCurrentThread(this);
if (NS_WARN_IF(!ok)) {
ActorFailed();
}
}
return mPBackgroundCreationPromise.Ensure(__func__);
return promise;
}
//static
@ -875,8 +886,13 @@ WebAuthnManager::Cancel(const nsresult& aError)
void
WebAuthnManager::ActorCreated(PBackgroundChild* aActor)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(aActor);
if (mChild) {
return;
}
RefPtr<WebAuthnTransactionChild> mgr(new WebAuthnTransactionChild());
PWebAuthnTransactionChild* constructedMgr =
aActor->SendPWebAuthnTransactionConstructor(mgr);

View File

@ -99,8 +99,9 @@ private:
void MaybeClearTransaction();
already_AddRefed<MozPromise<nsresult, nsresult, false>>
GetOrCreateBackgroundActor();
typedef MozPromise<nsresult, nsresult, false> BackgroundActorPromise;
RefPtr<BackgroundActorPromise> GetOrCreateBackgroundActor();
// JS Promise representing transaction status.
RefPtr<Promise> mTransactionPromise;
@ -120,7 +121,7 @@ private:
Maybe<WebAuthnTransactionInfo> mInfo;
// Promise for dealing with PBackground Actor creation.
MozPromiseHolder<MozPromise<nsresult, nsresult, false>> mPBackgroundCreationPromise;
MozPromiseHolder<BackgroundActorPromise> mPBackgroundCreationPromise;
};
} // namespace dom