Bug 1501404 - Part 6: Remove the XPCOM registrations for socket provider classes r=valentin

Depends on D9574

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Ehsan Akhgari 2018-10-23 20:07:27 +00:00
parent 229b1144b8
commit f6b7bc0052
6 changed files with 25 additions and 51 deletions

View File

@ -777,16 +777,6 @@
{ 0x89, 0xc3, 0x8d, 0x83, 0xb1, 0x7d, 0x3f, 0xb4 } \
}
#define NS_SSLSOCKETPROVIDER_CONTRACTID \
NS_NETWORK_SOCKET_CONTRACTID_PREFIX "ssl"
/* This code produces a normal socket which can be used to initiate the
* STARTTLS protocol by calling its nsISSLSocketControl->StartTLS()
*/
#define NS_STARTTLSSOCKETPROVIDER_CONTRACTID \
NS_NETWORK_SOCKET_CONTRACTID_PREFIX "starttls"
#define NS_DASHBOARD_CONTRACTID \
"@mozilla.org/network/dashboard;1"
#define NS_DASHBOARD_CID \

View File

@ -86,9 +86,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(TLSServerSocket)
typedef mozilla::net::nsUDPSocket nsUDPSocket;
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUDPSocket)
#include "nsUDPSocketProvider.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUDPSocketProvider)
#include "nsAsyncStreamCopier.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAsyncStreamCopier)
@ -713,9 +710,6 @@ NS_DEFINE_NAMED_CID(NS_NESTEDABOUTURI_CID);
NS_DEFINE_NAMED_CID(NS_NESTEDABOUTURIMUTATOR_CID);
NS_DEFINE_NAMED_CID(NS_ABOUT_CACHE_MODULE_CID);
NS_DEFINE_NAMED_CID(NS_ABOUT_CACHE_ENTRY_MODULE_CID);
NS_DEFINE_NAMED_CID(NS_SOCKSSOCKETPROVIDER_CID);
NS_DEFINE_NAMED_CID(NS_SOCKS4SOCKETPROVIDER_CID);
NS_DEFINE_NAMED_CID(NS_UDPSOCKETPROVIDER_CID);
NS_DEFINE_NAMED_CID(NS_CACHESERVICE_CID);
NS_DEFINE_NAMED_CID(NS_APPLICATIONCACHESERVICE_CID);
#ifdef NECKO_COOKIES
@ -826,9 +820,6 @@ static const mozilla::Module::CIDEntry kNeckoCIDs[] = {
{ &kNS_NESTEDABOUTURIMUTATOR_CID, false, nullptr, nsNestedAboutURIMutatorConstructor },
{ &kNS_ABOUT_CACHE_MODULE_CID, false, nullptr, nsAboutCache::Create },
{ &kNS_ABOUT_CACHE_ENTRY_MODULE_CID, false, nullptr, nsAboutCacheEntryConstructor },
{ &kNS_SOCKSSOCKETPROVIDER_CID, false, nullptr, nsSOCKSSocketProvider::CreateV5 },
{ &kNS_SOCKS4SOCKETPROVIDER_CID, false, nullptr, nsSOCKSSocketProvider::CreateV4 },
{ &kNS_UDPSOCKETPROVIDER_CID, false, nullptr, nsUDPSocketProviderConstructor },
{ &kNS_CACHESERVICE_CID, false, nullptr, nsCacheService::Create },
{ &kNS_APPLICATIONCACHESERVICE_CID, false, nullptr, nsApplicationCacheServiceConstructor },
#ifdef NECKO_COOKIES
@ -942,9 +933,6 @@ static const mozilla::Module::ContractIDEntry kNeckoContracts[] = {
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "blank", &kNS_ABOUT_BLANK_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "cache", &kNS_ABOUT_CACHE_MODULE_CID },
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "cache-entry", &kNS_ABOUT_CACHE_ENTRY_MODULE_CID },
{ NS_NETWORK_SOCKET_CONTRACTID_PREFIX "socks", &kNS_SOCKSSOCKETPROVIDER_CID },
{ NS_NETWORK_SOCKET_CONTRACTID_PREFIX "socks4", &kNS_SOCKS4SOCKETPROVIDER_CID },
{ NS_NETWORK_SOCKET_CONTRACTID_PREFIX "udp", &kNS_UDPSOCKETPROVIDER_CID },
{ NS_CACHESERVICE_CONTRACTID, &kNS_CACHESERVICE_CID },
{ NS_APPLICATIONCACHESERVICE_CONTRACTID, &kNS_APPLICATIONCACHESERVICE_CID },
#ifdef NECKO_COOKIES

View File

@ -119,12 +119,3 @@ interface nsISocketProvider : nsISupports
*/
const unsigned long BE_CONSERVATIVE = 1 << 4;
};
%{C++
/**
* nsISocketProvider implementations should be registered with XPCOM under a
* contract ID of the form: "@mozilla.org/network/socket;2?type=foo"
*/
#define NS_NETWORK_SOCKET_CONTRACTID_PREFIX \
"@mozilla.org/network/socket;2?type="
%}

View File

@ -6,8 +6,10 @@
#include "nsString.h"
#include "nsIServiceManager.h"
#include "nsISocketProvider.h"
#include "nsSocketProviderService.h"
#include "nsError.h"
#include "nsNSSComponent.h"
#include "nsSOCKSSocketProvider.h"
#include "nsSocketProviderService.h"
#include "nsSSLSocketProvider.h"
#include "nsTLSSocketProvider.h"
#include "nsUDPSocketProvider.h"
@ -45,15 +47,26 @@ NS_IMETHODIMP
nsSocketProviderService::GetSocketProvider(const char *type,
nsISocketProvider **result)
{
nsresult rv;
nsAutoCString contractID(
NS_LITERAL_CSTRING(NS_NETWORK_SOCKET_CONTRACTID_PREFIX) +
nsDependentCString(type));
rv = CallGetService(contractID.get(), result);
if (NS_FAILED(rv))
rv = NS_ERROR_UNKNOWN_SOCKET_TYPE;
return rv;
nsCOMPtr<nsISocketProvider> inst;
if (!nsCRT::strcmp(type, "ssl") &&
XRE_IsParentProcess() &&
EnsureNSSInitializedChromeOrContent()) {
inst = new nsSSLSocketProvider();
} else if (!nsCRT::strcmp(type, "starttls") &&
XRE_IsParentProcess() &&
EnsureNSSInitializedChromeOrContent()) {
inst = new nsTLSSocketProvider();
} else if (!nsCRT::strcmp(type, "socks")) {
inst = new nsSOCKSSocketProvider(NS_SOCKS_VERSION_5);
} else if (!nsCRT::strcmp(type, "socks4")) {
inst = new nsSOCKSSocketProvider(NS_SOCKS_VERSION_4);
} else if (!nsCRT::strcmp(type, "udp")) {
inst = new nsUDPSocketProvider();
} else {
return NS_ERROR_UNKNOWN_SOCKET_TYPE;
}
inst.forget(result);
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -68,6 +68,8 @@ EXPORTS += [
'nsRandomGenerator.h',
'nsSecurityHeaderParser.h',
'NSSErrorsService.h',
'nsSSLSocketProvider.h',
'nsTLSSocketProvider.h',
'RootCertificateTelemetryUtils.h',
'ScopedNSSTypes.h',
'SharedCertVerifier.h',

View File

@ -28,10 +28,8 @@
#include "nsPK11TokenDB.h"
#include "nsPKCS11Slot.h"
#include "nsRandomGenerator.h"
#include "nsSSLSocketProvider.h"
#include "nsSecureBrowserUIImpl.h"
#include "nsSiteSecurityService.h"
#include "nsTLSSocketProvider.h"
#include "nsXULAppAPI.h"
#include "OSKeyStore.h"
#include "OSReauthenticator.h"
@ -133,8 +131,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsSecureBrowserUIImpl)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNSSComponent, Init)
NS_DEFINE_NAMED_CID(NS_NSSCOMPONENT_CID);
NS_DEFINE_NAMED_CID(NS_SSLSOCKETPROVIDER_CID);
NS_DEFINE_NAMED_CID(NS_STARTTLSSOCKETPROVIDER_CID);
NS_DEFINE_NAMED_CID(NS_SECRETDECODERRING_CID);
NS_DEFINE_NAMED_CID(NS_PK11TOKENDB_CID);
NS_DEFINE_NAMED_CID(NS_PKCS11MODULEDB_CID);
@ -169,10 +165,6 @@ NS_DEFINE_NAMED_CID(NS_OSREAUTHENTICATOR_CID);
// new component with ThreadRestriction::MainThreadOnly is added.
static const mozilla::Module::CIDEntry kNSSCIDs[] = {
{ &kNS_NSSCOMPONENT_CID, false, nullptr, nsNSSComponentConstructor },
{ &kNS_SSLSOCKETPROVIDER_CID, false, nullptr,
Constructor<nsSSLSocketProvider> },
{ &kNS_STARTTLSSOCKETPROVIDER_CID, false, nullptr,
Constructor<nsTLSSocketProvider> },
{ &kNS_SECRETDECODERRING_CID, false, nullptr,
Constructor<SecretDecoderRing> },
{ &kNS_PK11TOKENDB_CID, false, nullptr, Constructor<nsPK11TokenDB> },
@ -234,8 +226,6 @@ static const mozilla::Module::ContractIDEntry kNSSContracts[] = {
{ PSM_COMPONENT_CONTRACTID, &kNS_NSSCOMPONENT_CID },
{ NS_NSS_ERRORS_SERVICE_CONTRACTID, &kNS_NSSERRORSSERVICE_CID },
{ NS_NSSVERSION_CONTRACTID, &kNS_NSSVERSION_CID },
{ NS_SSLSOCKETPROVIDER_CONTRACTID, &kNS_SSLSOCKETPROVIDER_CID },
{ NS_STARTTLSSOCKETPROVIDER_CONTRACTID, &kNS_STARTTLSSOCKETPROVIDER_CID },
{ NS_SECRETDECODERRING_CONTRACTID, &kNS_SECRETDECODERRING_CID },
{ NS_PK11TOKENDB_CONTRACTID, &kNS_PK11TOKENDB_CID },
{ NS_PKCS11MODULEDB_CONTRACTID, &kNS_PKCS11MODULEDB_CID },