Bug 1237668 - Remove nsSimpleUnicharStreamFactory r=froydnj

This commit is contained in:
Wilmer Paulino 2016-01-11 19:31:29 -05:00
parent 7ea7ec5572
commit b0a793ef3f
6 changed files with 8 additions and 85 deletions

View File

@ -304,8 +304,7 @@ void mozPersonalDictionary::SyncLoadInternal()
NS_NewLocalFileInputStream(getter_AddRefs(inStream), mFile);
nsCOMPtr<nsIUnicharInputStream> convStream;
rv = nsSimpleUnicharStreamFactory::GetInstance()->
CreateInstanceFromUTF8Stream(inStream, getter_AddRefs(convStream));
rv = NS_NewUnicharInputStream(inStream, getter_AddRefs(convStream));
if (NS_FAILED(rv)) {
return;
}

View File

@ -710,8 +710,7 @@ nsExpatDriver::HandleExternalEntityRef(const char16_t *openEntityNames,
}
nsCOMPtr<nsIUnicharInputStream> uniIn;
rv = nsSimpleUnicharStreamFactory::GetInstance()->
CreateInstanceFromUTF8Stream(in, getter_AddRefs(uniIn));
rv = NS_NewUnicharInputStream(in, getter_AddRefs(uniIn));
NS_ENSURE_SUCCESS(rv, 1);
int result = 1;

View File

@ -278,8 +278,6 @@ char16_t* gGREBinPath = nullptr;
static NS_DEFINE_CID(kComponentManagerCID, NS_COMPONENTMANAGER_CID);
static NS_DEFINE_CID(kINIParserFactoryCID, NS_INIPARSERFACTORY_CID);
static NS_DEFINE_CID(kSimpleUnicharStreamFactoryCID,
NS_SIMPLE_UNICHAR_STREAM_FACTORY_CID);
NS_DEFINE_NAMED_CID(NS_CHROMEREGISTRY_CID);
NS_DEFINE_NAMED_CID(NS_CHROMEPROTOCOLHANDLER_CID);
@ -300,14 +298,6 @@ CreateINIParserFactory(const mozilla::Module& aModule,
return f.forget();
}
static already_AddRefed<nsIFactory>
CreateUnicharStreamFactory(const mozilla::Module& aModule,
const mozilla::Module::CIDEntry& aEntry)
{
return already_AddRefed<nsIFactory>(
nsSimpleUnicharStreamFactory::GetInstance());
}
#define COMPONENT(NAME, Ctor) static NS_DEFINE_CID(kNS_##NAME##_CID, NS_##NAME##_CID);
#include "XPCOMModule.inc"
#undef COMPONENT
@ -316,7 +306,6 @@ CreateUnicharStreamFactory(const mozilla::Module& aModule,
const mozilla::Module::CIDEntry kXPCOMCIDEntries[] = {
{ &kComponentManagerCID, true, nullptr, nsComponentManagerImpl::Create },
{ &kINIParserFactoryCID, false, CreateINIParserFactory },
{ &kSimpleUnicharStreamFactoryCID, false, CreateUnicharStreamFactory },
#include "XPCOMModule.inc"
{ &kNS_CHROMEREGISTRY_CID, false, nullptr, nsChromeRegistryConstructor },
{ &kNS_CHROMEPROTOCOLHANDLER_CID, false, nullptr, nsChromeProtocolHandlerConstructor },

View File

@ -486,8 +486,7 @@ NS_IMPL_ISUPPORTS(nsPersistentProperties, nsIPersistentProperties, nsIProperties
NS_IMETHODIMP
nsPersistentProperties::Load(nsIInputStream* aIn)
{
nsresult rv = nsSimpleUnicharStreamFactory::GetInstance()->
CreateInstanceFromUTF8Stream(aIn, getter_AddRefs(mIn));
nsresult rv = NS_NewUnicharInputStream(aIn, getter_AddRefs(mIn));
if (rv != NS_OK) {
NS_WARNING("Error creating UnicharInputStream");

View File

@ -380,48 +380,9 @@ UTF8InputStream::CountValidUTF8Bytes(const char* aBuffer, uint32_t aMaxBytes,
aValidUTF16CodeUnits = utf16length;
}
NS_IMPL_QUERY_INTERFACE(nsSimpleUnicharStreamFactory,
nsIFactory,
nsISimpleUnicharStreamFactory)
NS_IMETHODIMP_(MozExternalRefCountType)
nsSimpleUnicharStreamFactory::AddRef()
{
return 2;
}
NS_IMETHODIMP_(MozExternalRefCountType)
nsSimpleUnicharStreamFactory::Release()
{
return 1;
}
NS_IMETHODIMP
nsSimpleUnicharStreamFactory::CreateInstance(nsISupports* aOuter, REFNSIID aIID,
void** aResult)
{
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsSimpleUnicharStreamFactory::LockFactory(bool aLock)
{
return NS_OK;
}
NS_IMETHODIMP
nsSimpleUnicharStreamFactory::CreateInstanceFromString(const nsAString& aString,
nsIUnicharInputStream** aResult)
{
RefPtr<StringUnicharInputStream> it = new StringUnicharInputStream(aString);
it.forget(aResult);
return NS_OK;
}
NS_IMETHODIMP
nsSimpleUnicharStreamFactory::CreateInstanceFromUTF8Stream(
nsIInputStream* aStreamToWrap,
nsIUnicharInputStream** aResult)
nsresult
NS_NewUnicharInputStream(nsIInputStream* aStreamToWrap,
nsIUnicharInputStream** aResult)
{
*aResult = nullptr;
@ -435,10 +396,3 @@ nsSimpleUnicharStreamFactory::CreateInstanceFromUTF8Stream(
it.forget(aResult);
return NS_OK;
}
nsSimpleUnicharStreamFactory*
nsSimpleUnicharStreamFactory::GetInstance()
{
static const nsSimpleUnicharStreamFactory kInstance;
return const_cast<nsSimpleUnicharStreamFactory*>(&kInstance);
}

View File

@ -9,25 +9,8 @@
#include "nsISimpleUnicharStreamFactory.h"
#include "nsIUnicharInputStream.h"
#include "nsIFactory.h"
// {428DCA6F-1A0F-4cda-B516-0D5244745A6A}
#define NS_SIMPLE_UNICHAR_STREAM_FACTORY_CID \
{ 0x428dca6f, 0x1a0f, 0x4cda, { 0xb5, 0x16, 0xd, 0x52, 0x44, 0x74, 0x5a, 0x6a } }
class nsSimpleUnicharStreamFactory
: public nsIFactory
, private nsISimpleUnicharStreamFactory
{
public:
nsSimpleUnicharStreamFactory()
{
}
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIFACTORY
NS_DECL_NSISIMPLEUNICHARSTREAMFACTORY
static nsSimpleUnicharStreamFactory* GetInstance();
};
nsresult NS_NewUnicharInputStream(nsIInputStream* aStreamToWrap,
nsIUnicharInputStream** aResult);
#endif // nsUnicharInputStream_h__