mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-12 04:45:45 +00:00
Bug 1512456 - P7. Chain promises so they can be exclusive. r=gerald
Differential Revision: https://phabricator.services.mozilla.com/D14031 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
dc9ee1f6ee
commit
b61cc66043
@ -48,7 +48,7 @@ void ClientSourceOpChild::DoSourceOp(Method aMethod, const Args& aArgs) {
|
||||
MOZ_DIAGNOSTIC_ASSERT(promise);
|
||||
|
||||
// Capture 'this' is safe here because we disconnect the promise
|
||||
// ActorDestroy() which ensures nethier lambda is called if the
|
||||
// ActorDestroy() which ensures neither lambda is called if the
|
||||
// actor is destroyed before the source operation completes.
|
||||
//
|
||||
// Also capture the promise to ensure it lives until we get a reaction
|
||||
|
@ -357,16 +357,17 @@ RefPtr<GenericPromise> ServiceWorkerManager::StartControllingClient(
|
||||
|
||||
// Always check to see if we failed to actually control the client. In
|
||||
// that case removed the client from our list of controlled clients.
|
||||
promise->Then(SystemGroup::EventTargetFor(TaskCategory::Other), __func__,
|
||||
[](bool) {
|
||||
// do nothing on success
|
||||
},
|
||||
[self, aClientInfo](nsresult aRv) {
|
||||
// failed to control, forget about this client
|
||||
self->StopControllingClient(aClientInfo);
|
||||
});
|
||||
|
||||
return promise;
|
||||
return promise->Then(
|
||||
SystemGroup::EventTargetFor(TaskCategory::Other), __func__,
|
||||
[](bool) {
|
||||
// do nothing on success
|
||||
return GenericPromise::CreateAndResolve(true, __func__);
|
||||
},
|
||||
[self, aClientInfo](nsresult aRv) {
|
||||
// failed to control, forget about this client
|
||||
self->StopControllingClient(aClientInfo);
|
||||
return GenericPromise::CreateAndReject(aRv, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
RefPtr<ClientHandle> clientHandle = ClientManager::CreateHandle(
|
||||
@ -392,16 +393,17 @@ RefPtr<GenericPromise> ServiceWorkerManager::StartControllingClient(
|
||||
|
||||
// Always check to see if we failed to actually control the client. In
|
||||
// that case removed the client from our list of controlled clients.
|
||||
promise->Then(SystemGroup::EventTargetFor(TaskCategory::Other), __func__,
|
||||
[](bool) {
|
||||
// do nothing on success
|
||||
},
|
||||
[self, aClientInfo](nsresult aRv) {
|
||||
// failed to control, forget about this client
|
||||
self->StopControllingClient(aClientInfo);
|
||||
});
|
||||
|
||||
return promise.forget();
|
||||
return promise->Then(
|
||||
SystemGroup::EventTargetFor(TaskCategory::Other), __func__,
|
||||
[](bool) {
|
||||
// do nothing on success
|
||||
return GenericPromise::CreateAndResolve(true, __func__);
|
||||
},
|
||||
[self, aClientInfo](nsresult aRv) {
|
||||
// failed to control, forget about this client
|
||||
self->StopControllingClient(aClientInfo);
|
||||
return GenericPromise::CreateAndReject(aRv, __func__);
|
||||
});
|
||||
}
|
||||
|
||||
void ServiceWorkerManager::StopControllingClient(
|
||||
|
Loading…
Reference in New Issue
Block a user