From 123240353cf8ac3ef16d2cb5c14f153920cba441 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Sun, 22 Sep 2013 23:34:09 -0400 Subject: [PATCH] Bug 919292 - Minimize the #includes in netwerk/streamconv; r=mcmanus --- .../streamconv/converters/ParseFTPList.cpp | 4 +- netwerk/streamconv/converters/ParseFTPList.h | 5 ++- .../converters/mozTXTToHTMLConv.cpp | 4 +- .../streamconv/converters/mozTXTToHTMLConv.h | 2 +- netwerk/streamconv/converters/nsDirIndex.cpp | 2 - .../converters/nsDirIndexParser.cpp | 8 ++-- .../streamconv/converters/nsDirIndexParser.h | 5 ++- .../converters/nsFTPDirListingConv.cpp | 8 +--- .../converters/nsFTPDirListingConv.h | 4 +- .../converters/nsHTTPCompressConv.cpp | 3 -- .../converters/nsHTTPCompressConv.h | 3 +- .../streamconv/converters/nsIndexedToHTML.cpp | 7 +++- .../streamconv/converters/nsIndexedToHTML.h | 11 ++---- .../converters/nsMultiMixedConv.cpp | 3 -- .../streamconv/converters/nsMultiMixedConv.h | 2 - .../streamconv/converters/nsTXTToHTMLConv.cpp | 2 +- .../streamconv/converters/nsTXTToHTMLConv.h | 6 +-- .../converters/nsUnknownDecoder.cpp | 7 ---- .../streamconv/converters/nsUnknownDecoder.h | 1 - .../src/nsStreamConverterService.cpp | 37 ++++++++++++++++--- .../streamconv/src/nsStreamConverterService.h | 36 ++---------------- netwerk/streamconv/test/TestStreamConv.cpp | 9 +++-- 22 files changed, 72 insertions(+), 97 deletions(-) diff --git a/netwerk/streamconv/converters/ParseFTPList.cpp b/netwerk/streamconv/converters/ParseFTPList.cpp index dc4c1680bb8d..20bd00163890 100644 --- a/netwerk/streamconv/converters/ParseFTPList.cpp +++ b/netwerk/streamconv/converters/ParseFTPList.cpp @@ -3,13 +3,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/. */ +#include "ParseFTPList.h" #include #include #include #include "plstr.h" #include "nsDebug.h" - -#include "ParseFTPList.h" +#include "prprf.h" /* ==================================================================== */ diff --git a/netwerk/streamconv/converters/ParseFTPList.h b/netwerk/streamconv/converters/ParseFTPList.h index f3f440b2109a..85a83d4b19f2 100644 --- a/netwerk/streamconv/converters/ParseFTPList.h +++ b/netwerk/streamconv/converters/ParseFTPList.h @@ -2,7 +2,10 @@ /* This Source Code Form is subject to the terms of the Mozilla Public * 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/. */ -#include "nspr.h" + +#include +#include +#include "prtime.h" /* ParseFTPList() parses lines from an FTP LIST command. ** diff --git a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp index 5cec266a289c..0dd0f961e26b 100644 --- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp +++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp @@ -4,13 +4,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozTXTToHTMLConv.h" -#include "nsIServiceManager.h" -#include "nsNetCID.h" #include "nsNetUtil.h" -#include "nsReadableUtils.h" #include "nsUnicharUtils.h" #include "nsCRT.h" #include "nsIExternalProtocolHandler.h" +#include "nsIIOService.h" #ifdef DEBUG_BenB_Perf #include "prtime.h" diff --git a/netwerk/streamconv/converters/mozTXTToHTMLConv.h b/netwerk/streamconv/converters/mozTXTToHTMLConv.h index 8145bcaa9cc3..4eda494efbda 100644 --- a/netwerk/streamconv/converters/mozTXTToHTMLConv.h +++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.h @@ -11,10 +11,10 @@ #define _mozTXTToHTMLConv_h__ #include "mozITXTToHTMLConv.h" -#include "nsIIOService.h" #include "nsString.h" #include "nsCOMPtr.h" +class nsIIOService; class mozTXTToHTMLConv : public mozITXTToHTMLConv { diff --git a/netwerk/streamconv/converters/nsDirIndex.cpp b/netwerk/streamconv/converters/nsDirIndex.cpp index 6cb0ef06fa07..213c60be7fe8 100644 --- a/netwerk/streamconv/converters/nsDirIndex.cpp +++ b/netwerk/streamconv/converters/nsDirIndex.cpp @@ -4,8 +4,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsDirIndex.h" -#include "nsReadableUtils.h" -#include "nsCRT.h" #include "nsISupportsObsolete.h" NS_IMPL_ISUPPORTS1(nsDirIndex, diff --git a/netwerk/streamconv/converters/nsDirIndexParser.cpp b/netwerk/streamconv/converters/nsDirIndexParser.cpp index c3e4f6ea273a..ea115ee8723a 100644 --- a/netwerk/streamconv/converters/nsDirIndexParser.cpp +++ b/netwerk/streamconv/converters/nsDirIndexParser.cpp @@ -10,17 +10,15 @@ #include "prprf.h" #include "nsDirIndexParser.h" -#include "nsReadableUtils.h" -#include "nsDirIndex.h" #include "nsEscape.h" -#include "nsIServiceManager.h" #include "nsIInputStream.h" -#include "nsIChannel.h" -#include "nsIURI.h" #include "nsCRT.h" #include "nsIPrefService.h" #include "nsIPrefBranch.h" #include "nsIPrefLocalizedString.h" +#include "nsITextToSubURI.h" +#include "nsIDirIndex.h" +#include "nsServiceManagerUtils.h" using namespace mozilla; diff --git a/netwerk/streamconv/converters/nsDirIndexParser.h b/netwerk/streamconv/converters/nsDirIndexParser.h index e563ce65ded5..48cd07e5d3f3 100644 --- a/netwerk/streamconv/converters/nsDirIndexParser.h +++ b/netwerk/streamconv/converters/nsDirIndexParser.h @@ -6,11 +6,12 @@ #ifndef __NSDIRINDEX_H_ #define __NSDIRINDEX_H_ -#include "nsIDirIndex.h" #include "nsString.h" #include "nsCOMPtr.h" #include "nsIDirIndexListener.h" -#include "nsITextToSubURI.h" + +class nsIDirIndex; +class nsITextToSubURI; /* CID: {a0d6ad32-1dd1-11b2-aa55-a40187b54036} */ diff --git a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp index cd3d82c8c0fa..ef9be19b81f5 100644 --- a/netwerk/streamconv/converters/nsFTPDirListingConv.cpp +++ b/netwerk/streamconv/converters/nsFTPDirListingConv.cpp @@ -7,19 +7,13 @@ #include "nsMemory.h" #include "plstr.h" #include "prlog.h" -#include "nsIServiceManager.h" -#include "nsXPIDLString.h" -#include "nsReadableUtils.h" #include "nsCOMPtr.h" #include "nsEscape.h" -#include "nsNetUtil.h" #include "nsStringStream.h" -#include "nsIComponentManager.h" -#include "nsDateTimeFormatCID.h" #include "nsIStreamListener.h" #include "nsCRT.h" -#include "nsMimeTypes.h" #include "nsAutoPtr.h" +#include "nsIChannel.h" #include "ParseFTPList.h" #include diff --git a/netwerk/streamconv/converters/nsFTPDirListingConv.h b/netwerk/streamconv/converters/nsFTPDirListingConv.h index d64956662a2b..005bdd71a88b 100644 --- a/netwerk/streamconv/converters/nsFTPDirListingConv.h +++ b/netwerk/streamconv/converters/nsFTPDirListingConv.h @@ -6,11 +6,9 @@ #define __nsftpdirlistingdconv__h__ #include "nsIStreamConverter.h" -#include "nsIChannel.h" -#include "nsIURI.h" #include "nsString.h" -#include "nsIFactory.h" +class nsIURI; #define NS_FTPDIRLISTINGCONVERTER_CID \ { /* 14C0E880-623E-11d3-A178-0050041CAF44 */ \ diff --git a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp index 78002799ed5d..0dc5a259d4c3 100644 --- a/netwerk/streamconv/converters/nsHTTPCompressConv.cpp +++ b/netwerk/streamconv/converters/nsHTTPCompressConv.cpp @@ -7,10 +7,7 @@ #include "nsHTTPCompressConv.h" #include "nsMemory.h" #include "plstr.h" -#include "prlog.h" -#include "nsIChannel.h" #include "nsCOMPtr.h" -#include "nsReadableUtils.h" #include "nsError.h" #include "nsStreamUtils.h" #include "nsStringStream.h" diff --git a/netwerk/streamconv/converters/nsHTTPCompressConv.h b/netwerk/streamconv/converters/nsHTTPCompressConv.h index a64e3c1479d0..7ebb2e066a1e 100644 --- a/netwerk/streamconv/converters/nsHTTPCompressConv.h +++ b/netwerk/streamconv/converters/nsHTTPCompressConv.h @@ -7,11 +7,12 @@ #define __nsHTTPCompressConv__h__ 1 #include "nsIStreamConverter.h" -#include "nsIStringStream.h" #include "nsCOMPtr.h" #include "zlib.h" +class nsIStringInputStream; + #define NS_HTTPCOMPRESSCONVERTER_CID \ { \ /* 66230b2b-17fa-4bd3-abf4-07986151022d */ \ diff --git a/netwerk/streamconv/converters/nsIndexedToHTML.cpp b/netwerk/streamconv/converters/nsIndexedToHTML.cpp index 6a8a60e922bf..845976f3545e 100644 --- a/netwerk/streamconv/converters/nsIndexedToHTML.cpp +++ b/netwerk/streamconv/converters/nsIndexedToHTML.cpp @@ -10,15 +10,18 @@ #include "nsIFileURL.h" #include "nsEscape.h" #include "nsIDirIndex.h" -#include "prtime.h" #include "nsDateTimeFormatCID.h" #include "nsURLHelper.h" -#include "nsCRT.h" #include "nsIPlatformCharset.h" #include "nsIPrefService.h" #include "nsIPrefBranch.h" #include "nsIPrefLocalizedString.h" #include "nsIChromeRegistry.h" +#include "nsICharsetConverterManager.h" +#include "nsIDateTimeFormat.h" +#include "nsIStringBundle.h" +#include "nsITextToSubURI.h" +#include "nsXPIDLString.h" #include NS_IMPL_ISUPPORTS4(nsIndexedToHTML, diff --git a/netwerk/streamconv/converters/nsIndexedToHTML.h b/netwerk/streamconv/converters/nsIndexedToHTML.h index 0da1d9cf2da6..8dcfd2ce7bdc 100644 --- a/netwerk/streamconv/converters/nsIndexedToHTML.h +++ b/netwerk/streamconv/converters/nsIndexedToHTML.h @@ -7,20 +7,17 @@ #define ____nsindexedtohtml___h___ #include "nsCOMPtr.h" -#include "nsIFactory.h" #include "nsString.h" #include "nsIStreamConverter.h" -#include "nsXPIDLString.h" #include "nsIDirIndexListener.h" -#include "nsIDateTimeFormat.h" -#include "nsIStringBundle.h" -#include "nsIStringStream.h" -#include "nsITextToSubURI.h" -#include "nsICharsetConverterManager.h" #define NS_NSINDEXEDTOHTMLCONVERTER_CID \ { 0xcf0f71fd, 0xfafd, 0x4e2b, {0x9f, 0xdc, 0x13, 0x4d, 0x97, 0x2e, 0x16, 0xe2} } +class nsIDateTimeFormat; +class nsIStringBundle; +class nsITextToSubURI; +class nsIUnicodeEncoder; class nsIndexedToHTML : public nsIStreamConverter, public nsIDirIndexListener diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.cpp b/netwerk/streamconv/converters/nsMultiMixedConv.cpp index c77435b697e6..9d5f39ef6cf2 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.cpp +++ b/netwerk/streamconv/converters/nsMultiMixedConv.cpp @@ -4,14 +4,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsMultiMixedConv.h" -#include "nsMemory.h" #include "plstr.h" #include "nsIHttpChannel.h" -#include "nsIServiceManager.h" #include "nsNetUtil.h" #include "nsMimeTypes.h" #include "nsIStringStream.h" -#include "nsReadableUtils.h" #include "nsCRT.h" #include "nsIHttpChannelInternal.h" #include "nsURLHelper.h" diff --git a/netwerk/streamconv/converters/nsMultiMixedConv.h b/netwerk/streamconv/converters/nsMultiMixedConv.h index a832611b3cc1..90f3801c3a66 100644 --- a/netwerk/streamconv/converters/nsMultiMixedConv.h +++ b/netwerk/streamconv/converters/nsMultiMixedConv.h @@ -7,9 +7,7 @@ #include "nsIStreamConverter.h" #include "nsIChannel.h" -#include "nsIURI.h" #include "nsString.h" -#include "nsXPIDLString.h" #include "nsCOMPtr.h" #include "nsIByteRangeRequest.h" #include "nsIMultiPartChannel.h" diff --git a/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp b/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp index 1540c381ada2..32be9d7a6e7e 100644 --- a/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp +++ b/netwerk/streamconv/converters/nsTXTToHTMLConv.cpp @@ -4,10 +4,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsTXTToHTMLConv.h" -#include "nsNetUtil.h" #include "nsEscape.h" #include "nsStringStream.h" #include "nsAutoPtr.h" +#include "nsIChannel.h" #include #define TOKEN_DELIMITERS NS_LITERAL_STRING("\t\r\n ").get() diff --git a/netwerk/streamconv/converters/nsTXTToHTMLConv.h b/netwerk/streamconv/converters/nsTXTToHTMLConv.h index 7de9f2bb6b52..faf4b03f332a 100644 --- a/netwerk/streamconv/converters/nsTXTToHTMLConv.h +++ b/netwerk/streamconv/converters/nsTXTToHTMLConv.h @@ -9,8 +9,6 @@ #include "nsITXTToHTMLConv.h" #include "nsCOMPtr.h" #include "nsTArray.h" -#include "nsAutoPtr.h" -#include "nsIFactory.h" #include "nsString.h" #define NS_NSTXTTOHTMLCONVERTER_CID \ @@ -27,7 +25,9 @@ typedef struct convToken { nsString modText; // replacement text or href prepend text. bool prepend; // flag indicating how the modText should be used. } convToken; - + +template class nsAutoPtr; + /** * Convert plain text to HTML. * diff --git a/netwerk/streamconv/converters/nsUnknownDecoder.cpp b/netwerk/streamconv/converters/nsUnknownDecoder.cpp index 0e74dc88cdbd..a7ca92ae3398 100644 --- a/netwerk/streamconv/converters/nsUnknownDecoder.cpp +++ b/netwerk/streamconv/converters/nsUnknownDecoder.cpp @@ -4,19 +4,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsUnknownDecoder.h" -#include "nsIServiceManager.h" -#include "nsIStreamConverterService.h" - #include "nsIPipe.h" #include "nsIInputStream.h" #include "nsIOutputStream.h" #include "nsMimeTypes.h" -#include "netCore.h" -#include "nsXPIDLString.h" #include "nsIPrefService.h" #include "nsIPrefBranch.h" -#include "nsICategoryManager.h" -#include "nsISupportsPrimitives.h" #include "nsCRT.h" diff --git a/netwerk/streamconv/converters/nsUnknownDecoder.h b/netwerk/streamconv/converters/nsUnknownDecoder.h index faff947a6d5b..f785a8cb7d7e 100644 --- a/netwerk/streamconv/converters/nsUnknownDecoder.h +++ b/netwerk/streamconv/converters/nsUnknownDecoder.h @@ -7,7 +7,6 @@ #define nsUnknownDecoder_h__ #include "nsIStreamConverter.h" -#include "nsIChannel.h" #include "nsIContentSniffer.h" #include "nsCOMPtr.h" diff --git a/netwerk/streamconv/src/nsStreamConverterService.cpp b/netwerk/streamconv/src/nsStreamConverterService.cpp index d49b626288a3..b28b2e71355d 100644 --- a/netwerk/streamconv/src/nsStreamConverterService.cpp +++ b/netwerk/streamconv/src/nsStreamConverterService.cpp @@ -19,20 +19,47 @@ */ #include "nsStreamConverterService.h" -#include "nsIServiceManager.h" -#include "nsIComponentManager.h" #include "nsIComponentRegistrar.h" #include "nsString.h" -#include "nsReadableUtils.h" #include "nsIAtom.h" #include "nsDeque.h" #include "nsIInputStream.h" -#include "nsIOutputStream.h" #include "nsIStreamConverter.h" #include "nsICategoryManager.h" #include "nsXPCOM.h" #include "nsISupportsPrimitives.h" -#include "nsXPIDLString.h" +#include "nsCOMArray.h" +#include "nsTArray.h" +#include "nsServiceManagerUtils.h" +#include "nsHashtable.h" + +/////////////////////////////////////////////////////////////////// +// Breadth-First-Search (BFS) algorithm state classes and types. + +// used to establish discovered vertecies. +enum BFScolors {white, gray, black}; + +struct BFSState { + BFScolors color; + int32_t distance; + nsCStringKey *predecessor; + ~BFSState() { + delete predecessor; + } +}; + +// adjacency list and BFS hashtable data class. +struct SCTableData { + nsCStringKey *key; + union _data { + BFSState *state; + nsCOMArray *edges; + } data; + + SCTableData(nsCStringKey* aKey) : key(aKey) { + data.state = nullptr; + } +}; //////////////////////////////////////////////////////////// // nsISupports methods diff --git a/netwerk/streamconv/src/nsStreamConverterService.h b/netwerk/streamconv/src/nsStreamConverterService.h index 7cd907c1c346..a0e0396b60f5 100644 --- a/netwerk/streamconv/src/nsStreamConverterService.h +++ b/netwerk/streamconv/src/nsStreamConverterService.h @@ -7,11 +7,10 @@ #define __nsstreamconverterservice__h___ #include "nsIStreamConverterService.h" -#include "nsIStreamListener.h" -#include "nsHashtable.h" -#include "nsCOMArray.h" -#include "nsTArray.h" -#include "nsIAtom.h" + +template class nsTArray; +class nsObjectHashtable; +class nsCString; class nsStreamConverterService : public nsIStreamConverterService { public: @@ -43,31 +42,4 @@ private: nsObjectHashtable *mAdjacencyList; }; -/////////////////////////////////////////////////////////////////// -// Breadth-First-Search (BFS) algorithm state classes and types. - -// used to establish discovered vertecies. -enum BFScolors {white, gray, black}; - -struct BFSState { - BFScolors color; - int32_t distance; - nsCStringKey *predecessor; - ~BFSState() { - delete predecessor; - } -}; - -// adjacency list and BFS hashtable data class. -struct SCTableData { - nsCStringKey *key; - union _data { - BFSState *state; - nsCOMArray *edges; - } data; - - SCTableData(nsCStringKey* aKey) : key(aKey) { - data.state = nullptr; - } -}; #endif // __nsstreamconverterservice__h___ diff --git a/netwerk/streamconv/test/TestStreamConv.cpp b/netwerk/streamconv/test/TestStreamConv.cpp index cb1cf2cee8c4..58e1cb1c5fec 100644 --- a/netwerk/streamconv/test/TestStreamConv.cpp +++ b/netwerk/streamconv/test/TestStreamConv.cpp @@ -4,8 +4,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "nsIServiceManager.h" -#include "nsIComponentManager.h" -#include "nsIComponentRegistrar.h" #include "nsIStreamConverterService.h" #include "nsIStreamConverter.h" #include "nsICategoryManager.h" @@ -13,11 +11,14 @@ #include "nsXULAppAPI.h" #include "nsIStringStream.h" #include "nsCOMPtr.h" -#include "nsNetUtil.h" #include "nsThreadUtils.h" #include "mozilla/Attributes.h" +#include "nsMemory.h" +#include "nsServiceManagerUtils.h" +#include "nsComponentManagerUtils.h" +#include "nsIRequest.h" +#include "nsNetCID.h" -#include "nspr.h" #include #define ASYNC_TEST // undefine this if you want to test sycnronous conversion.