Bug 1640105 - Initialize necessary services eariler r=dragana

Initialize http handler, DNS service, and IOService earlier to avoid crash.

Differential Revision: https://phabricator.services.mozilla.com/D77303
This commit is contained in:
Kershaw Chang 2020-06-09 12:19:30 +00:00
Родитель 690f9999cd
Коммит dad33c111e
1 изменённых файлов: 22 добавлений и 25 удалений

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

@ -123,6 +123,26 @@ bool SocketProcessChild::Init(base::ProcessId aParentPid,
// because it's not running a native event loop. See bug 1384336.
CGSShutdownServerConnections();
#endif // XP_MACOSX
nsresult rv;
nsCOMPtr<nsIIOService> ios = do_GetIOService(&rv);
if (NS_FAILED(rv)) {
return false;
}
nsCOMPtr<nsIProtocolHandler> handler;
rv = ios->GetProtocolHandler("http", getter_AddRefs(handler));
if (NS_FAILED(rv)) {
return false;
}
// Initialize DNS Service here, since it needs to be done in main thread.
nsCOMPtr<nsIDNSService> dns =
do_GetService("@mozilla.org/network/dns-service;1", &rv);
if (NS_FAILED(rv)) {
return false;
}
return true;
}
@ -313,31 +333,8 @@ PFileDescriptorSetChild* SocketProcessChild::SendPFileDescriptorSetConstructor(
already_AddRefed<PHttpConnectionMgrChild>
SocketProcessChild::AllocPHttpConnectionMgrChild() {
LOG(("SocketProcessChild::AllocPHttpConnectionMgrChild \n"));
if (!gHttpHandler) {
nsresult rv;
nsCOMPtr<nsIIOService> ios = do_GetIOService(&rv);
if (NS_FAILED(rv)) {
return nullptr;
}
nsCOMPtr<nsIProtocolHandler> handler;
rv = ios->GetProtocolHandler("http", getter_AddRefs(handler));
if (NS_FAILED(rv)) {
return nullptr;
}
// Initialize DNS Service here, since it needs to be done in main thread.
nsCOMPtr<nsIDNSService> dns =
do_GetService("@mozilla.org/network/dns-service;1", &rv);
if (NS_FAILED(rv)) {
return nullptr;
}
RefPtr<HttpConnectionMgrChild> actor = new HttpConnectionMgrChild();
return actor.forget();
}
return nullptr;
RefPtr<HttpConnectionMgrChild> actor = new HttpConnectionMgrChild();
return actor.forget();
}
mozilla::ipc::IPCResult