Bug 1563821 - Check if content child is shuttingdown before create SocketProcessBridgeChild r=jld

Differential Revision: https://phabricator.services.mozilla.com/D37776

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kershaw Chang 2019-07-11 22:42:05 +00:00
Родитель bea6491430
Коммит ba0fa23495
1 изменённых файлов: 14 добавлений и 0 удалений

Просмотреть файл

@ -6,6 +6,7 @@
#include "SocketProcessBridgeChild.h" #include "SocketProcessBridgeChild.h"
#include "SocketProcessLogging.h" #include "SocketProcessLogging.h"
#include "mozilla/dom/ContentChild.h"
#include "mozilla/net/NeckoChild.h" #include "mozilla/net/NeckoChild.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
@ -13,6 +14,9 @@
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
namespace mozilla { namespace mozilla {
using dom::ContentChild;
namespace net { namespace net {
StaticRefPtr<SocketProcessBridgeChild> StaticRefPtr<SocketProcessBridgeChild>
@ -77,10 +81,20 @@ SocketProcessBridgeChild::GetSocketProcessBridge() {
return GetPromise::CreateAndResolve(sSocketProcessBridgeChild, __func__); return GetPromise::CreateAndResolve(sSocketProcessBridgeChild, __func__);
} }
ContentChild* content = ContentChild::GetSingleton();
if (!content || content->IsShuttingDown()) {
return nullptr;
}
return gNeckoChild->SendInitSocketProcessBridge()->Then( return gNeckoChild->SendInitSocketProcessBridge()->Then(
GetMainThreadSerialEventTarget(), __func__, GetMainThreadSerialEventTarget(), __func__,
[](NeckoChild::InitSocketProcessBridgePromise::ResolveOrRejectValue&& [](NeckoChild::InitSocketProcessBridgePromise::ResolveOrRejectValue&&
aResult) { aResult) {
ContentChild* content = ContentChild::GetSingleton();
if (!content || content->IsShuttingDown()) {
return GetPromise::CreateAndReject(
nsCString("ContentChild is shutting down."), __func__);
}
if (!sSocketProcessBridgeChild) { if (!sSocketProcessBridgeChild) {
if (aResult.IsReject()) { if (aResult.IsReject()) {
return GetPromise::CreateAndReject( return GetPromise::CreateAndReject(