Bug 1034919 - Remove dangerous public destructor of nsTXTToHTMLConv r=mcmanus
authorSteve Workman <sworkman@mozilla.com>
Tue, 08 Jul 2014 11:50:14 -0700
changeset 192965 20479ebf9be80a9d98cdbc4f527b390f59717d20
parent 192964 5be37f43c77be2342506c6684beff522f8829a1c
child 192966 cea3a5af46287dea938e18052305059134263b2d
push id27103
push usercbook@mozilla.com
push dateWed, 09 Jul 2014 13:55:18 +0000
treeherdermozilla-central@f945d50e50fc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus
bugs1034919
milestone33.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 1034919 - Remove dangerous public destructor of nsTXTToHTMLConv r=mcmanus
netwerk/build/nsNetModule.cpp
netwerk/streamconv/converters/nsTXTToHTMLConv.h
--- a/netwerk/build/nsNetModule.cpp
+++ b/netwerk/build/nsNetModule.cpp
@@ -382,26 +382,32 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsAndroid
 nsresult NS_NewFTPDirListingConv(nsFTPDirListingConv** result);
 #endif
 
 #include "nsStreamConverterService.h"
 #include "nsMultiMixedConv.h"
 #include "nsHTTPCompressConv.h"
 #include "mozTXTToHTMLConv.h"
 #include "nsUnknownDecoder.h"
+
 #include "nsTXTToHTMLConv.h"
+namespace mozilla {
+namespace net {
+NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsTXTToHTMLConv, Init)
+} // namespace net
+} // namespace mozilla
+
 #include "nsIndexedToHTML.h"
 #ifdef BUILD_BINHEX_DECODER
 #include "nsBinHexDecoder.h"
 #endif
 
 nsresult NS_NewMultiMixedConv (nsMultiMixedConv** result);
 nsresult MOZ_NewTXTToHTMLConv (mozTXTToHTMLConv** result);
 nsresult NS_NewHTTPCompressConv  (nsHTTPCompressConv ** result);
-nsresult NS_NewNSTXTToHTMLConv(nsTXTToHTMLConv** result);
 nsresult NS_NewStreamConv(nsStreamConverterService **aStreamConv);
 
 #define FTP_TO_INDEX                 "?from=text/ftp-dir&to=application/http-index-format"
 #define INDEX_TO_HTML                "?from=application/http-index-format&to=text/html"
 #define MULTI_MIXED_X                "?from=multipart/x-mixed-replace&to=*/*"
 #define MULTI_MIXED                  "?from=multipart/mixed&to=*/*"
 #define MULTI_BYTERANGES             "?from=multipart/byteranges&to=*/*"
 #define UNKNOWN_CONTENT              "?from=" UNKNOWN_CONTENT_TYPE "&to=*/*"
@@ -609,47 +615,16 @@ CreateNewBinaryDetectorFactory(nsISuppor
   }
   NS_ADDREF(inst);
   rv = inst->QueryInterface(aIID, aResult);
   NS_RELEASE(inst);
 
   return rv;
 }
 
-static nsresult
-CreateNewNSTXTToHTMLConvFactory(nsISupports *aOuter, REFNSIID aIID, void **aResult)
-{
-  nsresult rv;
-
-  if (!aResult) {
-    return NS_ERROR_NULL_POINTER;
-  }
-  *aResult = nullptr;
-
-  if (aOuter) {
-    return NS_ERROR_NO_AGGREGATION;
-  }
-
-  nsTXTToHTMLConv *inst;
-  
-  inst = new nsTXTToHTMLConv();
-  if (!inst) return NS_ERROR_OUT_OF_MEMORY;
-
-  NS_ADDREF(inst);
-  rv = inst->Init();
-  if (NS_FAILED(rv)) {
-    delete inst;
-    return rv;
-  }
-  rv = inst->QueryInterface(aIID, aResult);
-  NS_RELEASE(inst);
-
-  return rv;
-}
-
 ///////////////////////////////////////////////////////////////////////////////
 // Module implementation for the net library
 
 // Net module startup hook
 static nsresult nsNetStartup()
 {
     gNetStrings = new nsNetStrings();
     return gNetStrings ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
@@ -874,17 +849,17 @@ static const mozilla::Module::CIDEntry k
     { &kNS_FTPDIRLISTINGCONVERTER_CID, false, nullptr, CreateNewFTPDirListingConv },
 #endif
     { &kNS_NSINDEXEDTOHTMLCONVERTER_CID, false, nullptr, nsIndexedToHTML::Create },
     { &kNS_DIRINDEXPARSER_CID, false, nullptr, nsDirIndexParserConstructor },
     { &kNS_MULTIMIXEDCONVERTER_CID, false, nullptr, CreateNewMultiMixedConvFactory },
     { &kNS_UNKNOWNDECODER_CID, false, nullptr, CreateNewUnknownDecoderFactory },
     { &kNS_BINARYDETECTOR_CID, false, nullptr, CreateNewBinaryDetectorFactory },
     { &kNS_HTTPCOMPRESSCONVERTER_CID, false, nullptr, CreateNewHTTPCompressConvFactory },
-    { &kNS_NSTXTTOHTMLCONVERTER_CID, false, nullptr, CreateNewNSTXTToHTMLConvFactory },
+    { &kNS_NSTXTTOHTMLCONVERTER_CID, false, nullptr, mozilla::net::nsTXTToHTMLConvConstructor },
 #ifdef BUILD_BINHEX_DECODER
     { &kNS_BINHEXDECODER_CID, false, nullptr, nsBinHexDecoderConstructor },
 #endif
     { &kMOZITXTTOHTMLCONV_CID, false, nullptr, CreateNewTXTToHTMLConvFactory },
     { &kNS_DIRINDEX_CID, false, nullptr, nsDirIndexConstructor },
     { &kNS_MIMEHEADERPARAM_CID, false, nullptr, nsMIMEHeaderParamImplConstructor },
 #ifdef NECKO_PROTOCOL_file
     { &kNS_FILEPROTOCOLHANDLER_CID, false, nullptr, nsFileProtocolHandlerConstructor },
--- a/netwerk/streamconv/converters/nsTXTToHTMLConv.h
+++ b/netwerk/streamconv/converters/nsTXTToHTMLConv.h
@@ -23,26 +23,16 @@
 typedef struct convToken {
     nsString token;     // the actual string (i.e. "http://")
     nsString modText;   // replacement text or href prepend text.
     bool     prepend;   // flag indicating how the modText should be used.
 } convToken;
 
 template<class T> class nsAutoPtr;
 
-class nsTXTToHTMLConv;
-
-namespace mozilla {
-template<>
-struct HasDangerousPublicDestructor<nsTXTToHTMLConv>
-{
-  static const bool value = true;
-};
-}
-
 /**
  * Convert plain text to HTML.
  *
  * OVERVIEW OF HOW THIS CLASS WORKS:
  *
  * This class stores an array of tokens that should be replaced by something,
  * or something that should be prepended.
  * The "token" member of convToken is the text to search for. This is a
@@ -70,42 +60,20 @@ class nsTXTToHTMLConv : public nsITXTToH
 public:
     NS_DECL_ISUPPORTS
     NS_DECL_NSISTREAMCONVERTER
     NS_DECL_NSITXTTOHTMLCONV
     NS_DECL_NSIREQUESTOBSERVER
     NS_DECL_NSISTREAMLISTENER
 
     nsTXTToHTMLConv();
-    virtual ~nsTXTToHTMLConv();
     nsresult Init();
 
-    // For factory creation.
-    static NS_METHOD
-    Create(nsISupports *aOuter, REFNSIID aIID, void **aResult) {
-        nsresult rv;
-        if (aOuter)
-            return NS_ERROR_NO_AGGREGATION;
-
-        nsTXTToHTMLConv* _s = new nsTXTToHTMLConv();
-        if (_s == nullptr)
-            return NS_ERROR_OUT_OF_MEMORY;
-        NS_ADDREF(_s);
-        rv = _s->Init();
-        if (NS_FAILED(rv)) {
-            delete _s;
-            return rv;
-        }
-        rv = _s->QueryInterface(aIID, aResult);
-        NS_RELEASE(_s);
-        return rv;
-    }
-
-
 protected:
+    virtual ~nsTXTToHTMLConv();
 
     // return the token and it's location in the underlying buffer.
     int32_t FindToken(int32_t cursor, convToken* *_retval);
 
     // return the cursor location after munging HTML into the 
     // underlying buffer, according to mToken
     int32_t CatHTML(int32_t front, int32_t back);