/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* 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/. */
// static void ProxyAutoConfigChild::BindProxyAutoConfigChild(
RefPtr<ProxyAutoConfigChild>&& aActor,
Endpoint<PProxyAutoConfigChild>&& aEndpoint) { // We only allow one ProxyAutoConfigChild at a time, so we need to // wait until the old one to be destroyed. if (sActor) {
NS_DispatchToCurrentThread(NS_NewRunnableFunction( "BindProxyAutoConfigChild",
[actor = std::move(aActor), endpoint = std::move(aEndpoint)]() mutable {
ProxyAutoConfigChild::BindProxyAutoConfigChild(std::move(actor),
std::move(endpoint));
})); return;
}
if (aEndpoint.Bind(aActor)) {
sActor = aActor;
}
}
// static bool ProxyAutoConfigChild::Create(Endpoint<PProxyAutoConfigChild>&& aEndpoint) { if (!sPACThread && !CreatePACThread()) {
NS_WARNING("Failed to create pac thread!"); returnfalse;
}
if (!sShutdownObserverRegistered) {
nsCOMPtr<nsIObserverService> obs = services::GetObserverService(); if (NS_WARN_IF(!obs)) { returnfalse;
}
nsCOMPtr<nsIObserver> observer = new ShutdownObserver();
nsresult rv = obs->AddObserver(observer, "xpcom-shutdown-threads", false); if (NS_WARN_IF(NS_FAILED(rv))) { returnfalse;
}
sShutdownObserverRegistered = true;
}
RefPtr<ProxyAutoConfigChild> actor = new ProxyAutoConfigChild(); if (NS_FAILED(sPACThread->Dispatch(NS_NewRunnableFunction( "ProxyAutoConfigChild::ProxyAutoConfigChild",
[actor = std::move(actor),
endpoint = std::move(aEndpoint)]() mutable {
MOZ_ASSERT(endpoint.IsValid());
ProxyAutoConfigChild::BindProxyAutoConfigChild(std::move(actor),
std::move(endpoint));
})))) {
NS_WARNING("Failed to dispatch runnable!"); returnfalse;
}
if (SocketProcessChild::GetSingleton()->IsShuttingDown()) {
NS_WARNING("Trying to create pac thread after shutdown has already begun!"); returnfalse;
}
nsCOMPtr<nsIThread> thread; if (NS_FAILED(NS_NewNamedThread("ProxyResolution", getter_AddRefs(thread)))) {
NS_WARNING("NS_NewNamedThread failed!"); returnfalse;
}
// To avoid racing with the main thread, we need to dispatch // ProxyAutoConfigChild::Destroy again.
MOZ_ALWAYS_SUCCEEDS(NS_DispatchToCurrentThread(NewNonOwningRunnableMethod( "ProxyAutoConfigChild::Destroy", this, &ProxyAutoConfigChild::Destroy)));
}
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.