Bug 1237668 - Remove nsSimpleUnicharStreamFactory r=froydnj
authorWilmer Paulino <wilmer.paulino@mozilla.com>
Mon, 11 Jan 2016 19:31:29 -0500
changeset 279665 2b91c5f6f820af986ab65f03c0a0c7a94812e909
parent 279664 e2dc6422362c60c021a7aa5bb38b9e4fb8d8326a
child 279666 c7d85d6d0026a536c4f3e4a16a86018e7779be42
push id29885
push usercbook@mozilla.com
push dateWed, 13 Jan 2016 10:57:28 +0000
treeherdermozilla-central@531d1f6d1cde [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1237668
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1237668 - Remove nsSimpleUnicharStreamFactory r=froydnj
extensions/spellcheck/src/mozPersonalDictionary.cpp
parser/htmlparser/nsExpatDriver.cpp
xpcom/build/XPCOMInit.cpp
xpcom/ds/nsPersistentProperties.cpp
xpcom/io/nsUnicharInputStream.cpp
xpcom/io/nsUnicharInputStream.h
--- a/extensions/spellcheck/src/mozPersonalDictionary.cpp
+++ b/extensions/spellcheck/src/mozPersonalDictionary.cpp
@@ -299,18 +299,17 @@ void mozPersonalDictionary::SyncLoadInte
     // Nothing is really wrong...
     return;
   }
 
   nsCOMPtr<nsIInputStream> inStream;
   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;
   }
 
   // we're rereading to get rid of the old data  -- we shouldn't have any, but...
   mDictionaryTable.Clear();
 
   char16_t c;
--- a/parser/htmlparser/nsExpatDriver.cpp
+++ b/parser/htmlparser/nsExpatDriver.cpp
@@ -705,18 +705,17 @@ nsExpatDriver::HandleExternalEntityRef(c
     AppendUTF16toUTF8(absURL, message);
     message += "\"";
     NS_WARNING(message.get());
 #endif
     return 1;
   }
 
   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;
   if (uniIn) {
     XML_Parser entParser = XML_ExternalEntityParserCreate(mExpatParser, 0,
                                                           kUTF16);
     if (entParser) {
       XML_SetBase(entParser, absURL.get());
--- a/xpcom/build/XPCOMInit.cpp
+++ b/xpcom/build/XPCOMInit.cpp
@@ -273,18 +273,16 @@ nsXPTIInterfaceInfoManagerGetSingleton(n
 
 nsComponentManagerImpl* nsComponentManagerImpl::gComponentManager = nullptr;
 bool gXPCOMShuttingDown = false;
 bool gXPCOMThreadsShutDown = false;
 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);
 
 NS_DEFINE_NAMED_CID(NS_SECURITY_CONSOLE_MESSAGE_CID);
 
 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsChromeRegistry,
                                          nsChromeRegistry::GetSingleton)
@@ -295,33 +293,24 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsChromeP
 static already_AddRefed<nsIFactory>
 CreateINIParserFactory(const mozilla::Module& aModule,
                        const mozilla::Module::CIDEntry& aEntry)
 {
   nsCOMPtr<nsIFactory> f = new nsINIParserFactory();
   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
 
 #define COMPONENT(NAME, Ctor) { &kNS_##NAME##_CID, false, nullptr, Ctor },
 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 },
   { &kNS_SECURITY_CONSOLE_MESSAGE_CID, false, nullptr, nsSecurityConsoleMessageConstructor },
   { nullptr }
 };
 #undef COMPONENT
 
--- a/xpcom/ds/nsPersistentProperties.cpp
+++ b/xpcom/ds/nsPersistentProperties.cpp
@@ -481,18 +481,17 @@ nsPersistentProperties::Create(nsISuppor
   return props->QueryInterface(aIID, aResult);
 }
 
 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");
     return NS_ERROR_FAILURE;
   }
 
   nsPropertiesParser parser(this);
 
--- a/xpcom/io/nsUnicharInputStream.cpp
+++ b/xpcom/io/nsUnicharInputStream.cpp
@@ -375,70 +375,24 @@ UTF8InputStream::CountValidUTF8Bytes(con
     c = lastchar;
     utf16length--;
   }
 
   aValidUTF8bytes = c - aBuffer;
   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;
 
   // Create converter input stream
   RefPtr<UTF8InputStream> it = new UTF8InputStream();
   nsresult rv = it->Init(aStreamToWrap);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   it.forget(aResult);
   return NS_OK;
 }
-
-nsSimpleUnicharStreamFactory*
-nsSimpleUnicharStreamFactory::GetInstance()
-{
-  static const nsSimpleUnicharStreamFactory kInstance;
-  return const_cast<nsSimpleUnicharStreamFactory*>(&kInstance);
-}
--- a/xpcom/io/nsUnicharInputStream.h
+++ b/xpcom/io/nsUnicharInputStream.h
@@ -4,30 +4,13 @@
  * 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/. */
 
 #ifndef nsUnicharInputStream_h__
 #define nsUnicharInputStream_h__
 
 #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__