/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
if (!StaticPrefs::network_process_enabled()) { return GetPromise::CreateAndReject(nsCString("Socket process disabled!"),
__func__);
}
if (!gNeckoChild) { return GetPromise::CreateAndReject(nsCString("No NeckoChild!"), __func__);
}
// ContentChild is shutting down, we should not try to create // SocketProcessBridgeChild.
ContentChild* content = ContentChild::GetSingleton(); if (!content || content->IsShuttingDown()) { return GetPromise::CreateAndReject(
nsCString("ContentChild is shutting down."), __func__);
}
if (sSocketProcessBridgeChild) { return GetPromise::CreateAndResolve(sSocketProcessBridgeChild, __func__);
}
return gNeckoChild->SendInitSocketProcessBridge()->Then(
GetMainThreadSerialEventTarget(), __func__,
[](NeckoChild::InitSocketProcessBridgePromise::ResolveOrRejectValue&&
aResult) {
ContentChild* content = ContentChild::GetSingleton(); if (!content || content->IsShuttingDown()) { return GetPromise::CreateAndReject(
nsCString("ContentChild is shutting down."), __func__);
} if (!sSocketProcessBridgeChild) { if (aResult.IsReject()) { return GetPromise::CreateAndReject(
nsCString("SendInitSocketProcessBridge failed"), __func__);
}
if (!aResult.ResolveValue().IsValid()) { return GetPromise::CreateAndReject(
nsCString( "SendInitSocketProcessBridge resolved with an invalid " "endpoint!"),
__func__);
}
if (!SocketProcessBridgeChild::Create(
std::move(aResult.ResolveValue()))) { return GetPromise::CreateAndReject(
nsCString("SendInitSocketProcessBridge resolved with a valid " "endpoint, " "but SocketProcessBridgeChild::Create failed!"),
__func__);
}
}
void SocketProcessBridgeChild::ActorDestroy(ActorDestroyReason aWhy) {
LOG(("SocketProcessBridgeChild::ActorDestroy\n")); if (AbnormalShutdown == aWhy) { if (gNeckoChild &&
!AppShutdown::IsInOrBeyond(ShutdownPhase::AppShutdownConfirmed)) { // Let NeckoParent know that the socket process connections must be // rebuilt.
gNeckoChild->SendResetSocketProcessBridge();
}
nsresult res;
nsCOMPtr<nsISerialEventTarget> mSTSThread;
mSTSThread = mozilla::components::SocketTransport::Service(&res); if (NS_SUCCEEDED(res) && mSTSThread) { // This must be called off the main thread. If we don't make this call // ipc::BackgroundChild::GetOrCreateSocketActorForCurrentThread() will // return the previous actor that is no longer able to send. This causes // rebuilding the socket process connections to fail.
MOZ_ALWAYS_SUCCEEDS(mSTSThread->Dispatch(NS_NewRunnableFunction( "net::SocketProcessBridgeChild::ActorDestroy",
[]() { ipc::BackgroundChild::CloseForCurrentThread(); })));
}
}
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); if (os) {
os->RemoveObserver(this, "content-child-shutdown");
}
GetCurrentSerialEventTarget()->Dispatch(
NewRunnableMethod("net::SocketProcessBridgeChild::DeferredDestroy", this,
&SocketProcessBridgeChild::DeferredDestroy));
mShuttingDown = true;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.