From e6bff0a49c6d66ca67d7a001a72bb09eddedc189 Mon Sep 17 00:00:00 2001 From: Kershaw Chang Date: Thu, 4 Jun 2020 22:56:40 +0000 Subject: [PATCH] Bug 1641496 - P5: Make nsHttpActivityDistributor::AddObserver work if socket process is not ready r=dragana Differential Revision: https://phabricator.services.mozilla.com/D77276 --- .../http/nsHttpActivityDistributor.cpp | 26 ++++++++++--------- 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/netwerk/protocol/http/nsHttpActivityDistributor.cpp b/netwerk/protocol/http/nsHttpActivityDistributor.cpp index da74937ecbca..98f564cb72f6 100644 --- a/netwerk/protocol/http/nsHttpActivityDistributor.cpp +++ b/netwerk/protocol/http/nsHttpActivityDistributor.cpp @@ -152,12 +152,13 @@ nsHttpActivityDistributor::AddObserver(nsIHttpActivityObserver* aObserver) { } if (nsIOService::UseSocketProcess() && wasEmpty) { - SocketProcessParent* parent = SocketProcessParent::GetSingleton(); - if (parent && parent->CanSend()) { - Unused << parent->SendOnHttpActivityDistributorActivated(true); - } else { - return NS_ERROR_FAILURE; - } + auto task = []() { + SocketProcessParent* parent = SocketProcessParent::GetSingleton(); + if (parent && parent->CanSend()) { + Unused << parent->SendOnHttpActivityDistributorActivated(true); + } + }; + gIOService->CallOrWaitForSocketProcess(task); } return NS_OK; } @@ -177,12 +178,13 @@ nsHttpActivityDistributor::RemoveObserver(nsIHttpActivityObserver* aObserver) { } if (nsIOService::UseSocketProcess() && isEmpty) { - SocketProcessParent* parent = SocketProcessParent::GetSingleton(); - if (parent && parent->CanSend()) { - Unused << parent->SendOnHttpActivityDistributorActivated(false); - } else { - return NS_ERROR_FAILURE; - } + auto task = []() { + SocketProcessParent* parent = SocketProcessParent::GetSingleton(); + if (parent && parent->CanSend()) { + Unused << parent->SendOnHttpActivityDistributorActivated(false); + } + }; + gIOService->CallOrWaitForSocketProcess(task); } return NS_OK; }