Adding tests
[mozilla-central.git] / netwerk / build / nsNetModule.cpp
blob6c573c6d6b77ebc988da7811c7e342e4366bfd6a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 #include "necko-config.h"
40 #include "nsCOMPtr.h"
41 #include "nsIModule.h"
42 #include "nsIClassInfoImpl.h"
43 #include "nsIGenericFactory.h"
44 #include "nsIComponentManager.h"
45 #include "nsIServiceManager.h"
46 #include "nsICategoryManager.h"
47 #include "nsSocketProviderService.h"
48 #include "nscore.h"
49 #include "nsSimpleURI.h"
50 #include "nsSimpleNestedURI.h"
51 #include "nsLoadGroup.h"
52 #include "nsStreamLoader.h"
53 #include "nsUnicharStreamLoader.h"
54 #include "nsFileStreams.h"
55 #include "nsBufferedStreams.h"
56 #include "nsMIMEInputStream.h"
57 #include "nsSOCKSSocketProvider.h"
58 #include "nsCacheService.h"
59 #include "nsDiskCacheDeviceSQL.h"
60 #include "nsMimeTypes.h"
61 #include "nsNetStrings.h"
62 #include "nsDNSPrefetch.h"
64 #include "nsNetCID.h"
66 #if defined(XP_MACOSX)
67 #define BUILD_APPLEFILE_DECODER 1
68 #else
69 #define BUILD_BINHEX_DECODER 1
70 #endif
72 ///////////////////////////////////////////////////////////////////////////////
74 #include "nsIOService.h"
75 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsIOService, nsIOService::GetInstance)
77 #include "nsDNSService2.h"
78 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDNSService, Init)
80 #include "nsProtocolProxyService.h"
81 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsProtocolProxyService, Init)
82 NS_DECL_CLASSINFO(nsProtocolProxyService)
84 #include "nsStreamTransportService.h"
85 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsStreamTransportService, Init)
87 #include "nsSocketTransportService2.h"
88 #undef LOG
89 #undef LOG_ENABLED
90 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSocketTransportService, Init)
92 #include "nsServerSocket.h"
93 NS_GENERIC_FACTORY_CONSTRUCTOR(nsServerSocket)
95 #include "nsUDPSocketProvider.h"
96 NS_GENERIC_FACTORY_CONSTRUCTOR(nsUDPSocketProvider)
98 #include "nsAsyncStreamCopier.h"
99 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAsyncStreamCopier)
101 #include "nsInputStreamPump.h"
102 NS_GENERIC_FACTORY_CONSTRUCTOR(nsInputStreamPump)
104 #include "nsInputStreamChannel.h"
105 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsInputStreamChannel, Init)
107 #include "nsDownloader.h"
108 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDownloader)
110 #include "nsSyncStreamListener.h"
111 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsSyncStreamListener, Init)
113 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSafeFileOutputStream)
115 NS_GENERIC_AGGREGATED_CONSTRUCTOR_INIT(nsLoadGroup, Init)
117 #include "nsEffectiveTLDService.h"
118 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsEffectiveTLDService, Init)
120 ///////////////////////////////////////////////////////////////////////////////
122 extern NS_METHOD
123 net_NewIncrementalDownload(nsISupports *, const nsIID &, void **);
125 #define NS_INCREMENTALDOWNLOAD_CLASSNAME \
126 "nsIncrementalDownload"
127 #define NS_INCREMENTALDOWNLOAD_CID \
128 { /* a62af1ba-79b3-4896-8aaf-b148bfce4280 */ \
129 0xa62af1ba, \
130 0x79b3, \
131 0x4896, \
132 {0x8a, 0xaf, 0xb1, 0x48, 0xbf, 0xce, 0x42, 0x80} \
135 ///////////////////////////////////////////////////////////////////////////////
137 #include "nsStreamConverterService.h"
139 #ifdef BUILD_APPLEFILE_DECODER
140 #include "nsAppleFileDecoder.h"
141 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAppleFileDecoder)
142 #endif
144 ///////////////////////////////////////////////////////////////////////////////
146 #include "nsMIMEHeaderParamImpl.h"
148 NS_GENERIC_FACTORY_CONSTRUCTOR(nsMIMEHeaderParamImpl)
149 ///////////////////////////////////////////////////////////////////////////////
151 #include "nsRequestObserverProxy.h"
152 #include "nsSimpleStreamListener.h"
153 #include "nsDirIndexParser.h"
154 #include "nsDirIndex.h"
156 NS_GENERIC_FACTORY_CONSTRUCTOR(nsRequestObserverProxy)
157 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimpleStreamListener)
158 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsDirIndexParser, Init)
159 NS_GENERIC_FACTORY_CONSTRUCTOR(nsDirIndex)
161 ///////////////////////////////////////////////////////////////////////////////
163 #include "nsStreamListenerTee.h"
164 NS_GENERIC_FACTORY_CONSTRUCTOR(nsStreamListenerTee)
166 ///////////////////////////////////////////////////////////////////////////////
168 #ifdef NECKO_COOKIES
169 #include "nsCookieService.h"
170 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsCookieService, nsCookieService::GetSingleton)
171 #endif
173 ///////////////////////////////////////////////////////////////////////////////
174 // protocols
175 ///////////////////////////////////////////////////////////////////////////////
177 // about:blank is mandatory
178 #include "nsAboutProtocolHandler.h"
179 #include "nsAboutBlank.h"
180 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAboutProtocolHandler)
181 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSafeAboutProtocolHandler)
183 #ifdef NECKO_PROTOCOL_about
184 // about
185 #ifdef NS_BUILD_REFCNT_LOGGING
186 #include "nsAboutBloat.h"
187 #endif
188 #include "nsAboutCache.h"
189 #include "nsAboutCacheEntry.h"
190 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAboutCacheEntry)
191 #endif
193 #ifdef NECKO_OFFLINE_CACHE
194 NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsOfflineCacheDevice, nsOfflineCacheDevice::GetInstance)
195 NS_GENERIC_FACTORY_CONSTRUCTOR(nsApplicationCacheNamespace)
196 #endif
198 #ifdef NECKO_PROTOCOL_file
199 // file
200 #include "nsFileProtocolHandler.h"
201 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsFileProtocolHandler, Init)
202 #endif
204 #ifdef NECKO_PROTOCOL_ftp
205 // ftp
206 #include "nsFtpProtocolHandler.h"
207 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsFtpProtocolHandler, Init)
208 #endif
210 #ifdef NECKO_PROTOCOL_http
211 // http/https
212 #include "nsHttpHandler.h"
213 #include "nsHttpAuthManager.h"
214 #include "nsHttpBasicAuth.h"
215 #include "nsHttpDigestAuth.h"
216 #include "nsHttpNTLMAuth.h"
217 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHttpNTLMAuth)
218 #undef LOG
219 #undef LOG_ENABLED
220 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHttpHandler, Init)
221 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHttpsHandler, Init)
222 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsHttpAuthManager, Init)
223 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHttpBasicAuth)
224 NS_GENERIC_FACTORY_CONSTRUCTOR(nsHttpDigestAuth)
225 #endif // !NECKO_PROTOCOL_http
227 #ifdef NECKO_PROTOCOL_res
228 // resource
229 #include "nsResProtocolHandler.h"
230 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsResProtocolHandler, Init)
231 NS_GENERIC_FACTORY_CONSTRUCTOR(nsResURL)
232 #endif
234 #ifdef NECKO_PROTOCOL_gopher
235 #include "nsGopherHandler.h"
236 NS_GENERIC_FACTORY_CONSTRUCTOR(nsGopherHandler)
237 #endif
239 #ifdef NECKO_PROTOCOL_viewsource
240 #include "nsViewSourceHandler.h"
241 NS_GENERIC_FACTORY_CONSTRUCTOR(nsViewSourceHandler)
242 #endif
244 #ifdef NECKO_PROTOCOL_data
245 #include "nsDataHandler.h"
246 #endif
248 ///////////////////////////////////////////////////////////////////////////////
250 #include "nsURIChecker.h"
251 NS_GENERIC_FACTORY_CONSTRUCTOR(nsURIChecker)
253 ///////////////////////////////////////////////////////////////////////////////
255 #include "nsURLParsers.h"
256 NS_GENERIC_FACTORY_CONSTRUCTOR(nsNoAuthURLParser)
257 NS_GENERIC_FACTORY_CONSTRUCTOR(nsAuthURLParser)
258 NS_GENERIC_FACTORY_CONSTRUCTOR(nsStdURLParser)
260 #include "nsStandardURL.h"
261 NS_GENERIC_FACTORY_CONSTRUCTOR(nsStandardURL)
263 NS_GENERIC_AGGREGATED_CONSTRUCTOR(nsSimpleURI)
265 NS_GENERIC_FACTORY_CONSTRUCTOR(nsSimpleNestedURI)
267 ///////////////////////////////////////////////////////////////////////////////
269 #include "nsIDNService.h"
270 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsIDNService, Init)
272 ///////////////////////////////////////////////////////////////////////////////
273 #if defined(XP_WIN) && !defined(WINCE)
274 #include "nsNotifyAddrListener.h"
275 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNotifyAddrListener, Init)
276 #elif defined(MOZ_WIDGET_COCOA)
277 #include "nsNetworkLinkService.h"
278 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsNetworkLinkService, Init)
279 #endif
281 ///////////////////////////////////////////////////////////////////////////////
283 #ifdef NECKO_PROTOCOL_ftp
284 #include "nsFTPDirListingConv.h"
285 nsresult NS_NewFTPDirListingConv(nsFTPDirListingConv** result);
286 #endif
288 #ifdef NECKO_PROTOCOL_gopher
289 #include "nsGopherDirListingConv.h"
290 NS_GENERIC_FACTORY_CONSTRUCTOR(nsGopherDirListingConv)
291 #endif
293 #include "nsMultiMixedConv.h"
294 #include "nsHTTPCompressConv.h"
295 #include "mozTXTToHTMLConv.h"
296 #include "nsUnknownDecoder.h"
297 #include "nsTXTToHTMLConv.h"
298 #include "nsIndexedToHTML.h"
299 #ifdef BUILD_BINHEX_DECODER
300 #include "nsBinHexDecoder.h"
301 #endif
303 nsresult NS_NewMultiMixedConv (nsMultiMixedConv** result);
304 nsresult MOZ_NewTXTToHTMLConv (mozTXTToHTMLConv** result);
305 nsresult NS_NewHTTPCompressConv (nsHTTPCompressConv ** result);
306 nsresult NS_NewNSTXTToHTMLConv(nsTXTToHTMLConv** result);
307 nsresult NS_NewStreamConv(nsStreamConverterService **aStreamConv);
309 #define FTP_TO_INDEX "?from=text/ftp-dir&to=application/http-index-format"
310 #define GOPHER_TO_INDEX "?from=text/gopher-dir&to=application/http-index-format"
311 #define INDEX_TO_HTML "?from=application/http-index-format&to=text/html"
312 #define MULTI_MIXED_X "?from=multipart/x-mixed-replace&to=*/*"
313 #define MULTI_MIXED "?from=multipart/mixed&to=*/*"
314 #define MULTI_BYTERANGES "?from=multipart/byteranges&to=*/*"
315 #define UNKNOWN_CONTENT "?from=" UNKNOWN_CONTENT_TYPE "&to=*/*"
316 #define GZIP_TO_UNCOMPRESSED "?from=gzip&to=uncompressed"
317 #define XGZIP_TO_UNCOMPRESSED "?from=x-gzip&to=uncompressed"
318 #define COMPRESS_TO_UNCOMPRESSED "?from=compress&to=uncompressed"
319 #define XCOMPRESS_TO_UNCOMPRESSED "?from=x-compress&to=uncompressed"
320 #define DEFLATE_TO_UNCOMPRESSED "?from=deflate&to=uncompressed"
321 #define PLAIN_TO_HTML "?from=text/plain&to=text/html"
323 #ifdef BUILD_BINHEX_DECODER
324 #define BINHEX_TO_WILD "?from=application/mac-binhex40&to=*/*"
325 #endif
327 static const char *const sStreamConverterArray[] = {
328 FTP_TO_INDEX,
329 GOPHER_TO_INDEX,
330 INDEX_TO_HTML,
331 MULTI_MIXED_X,
332 MULTI_MIXED,
333 MULTI_BYTERANGES,
334 UNKNOWN_CONTENT,
335 GZIP_TO_UNCOMPRESSED,
336 XGZIP_TO_UNCOMPRESSED,
337 COMPRESS_TO_UNCOMPRESSED,
338 XCOMPRESS_TO_UNCOMPRESSED,
339 DEFLATE_TO_UNCOMPRESSED,
340 #ifdef BUILD_BINHEX_DECODER
341 BINHEX_TO_WILD,
342 #endif
343 PLAIN_TO_HTML
346 static const PRUint32 sStreamConverterCount =
347 NS_ARRAY_LENGTH(sStreamConverterArray);
349 // each stream converter must add its from/to key to the category manager
350 // in RegisterStreamConverters(). This provides a string representation
351 // of each registered converter, rooted in the NS_ISTREAMCONVERTER_KEY
352 // category. These keys are then (when the stream converter service
353 // needs to chain converters together) enumerated and parsed to build
354 // a graph of converters for potential chaining.
355 static NS_METHOD
356 RegisterStreamConverters(nsIComponentManager *aCompMgr, nsIFile *aPath,
357 const char *registryLocation,
358 const char *componentType,
359 const nsModuleComponentInfo *info) {
360 nsCOMPtr<nsICategoryManager> catmgr =
361 do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
362 NS_ENSURE_STATE(catmgr);
364 for (PRUint32 count = 0; count < sStreamConverterCount; ++count) {
365 catmgr->AddCategoryEntry(NS_ISTREAMCONVERTER_KEY,
366 sStreamConverterArray[count], "",
367 PR_TRUE, PR_TRUE, nsnull);
369 return NS_OK;
372 // same as RegisterStreamConverters except the reverse.
373 static NS_METHOD
374 UnregisterStreamConverters(nsIComponentManager *aCompMgr, nsIFile *aPath,
375 const char *registryLocation,
376 const nsModuleComponentInfo *info) {
377 nsCOMPtr<nsICategoryManager> catmgr =
378 do_GetService(NS_CATEGORYMANAGER_CONTRACTID);
379 NS_ENSURE_STATE(catmgr);
381 for (PRUint32 count = 0; count < sStreamConverterCount; ++count) {
382 catmgr->DeleteCategoryEntry(NS_ISTREAMCONVERTER_KEY,
383 sStreamConverterArray[count],
384 PR_TRUE);
386 return NS_OK;
389 #ifdef BUILD_BINHEX_DECODER
390 NS_GENERIC_FACTORY_CONSTRUCTOR(nsBinHexDecoder)
391 #endif
393 static NS_IMETHODIMP
394 CreateNewStreamConvServiceFactory(nsISupports* aOuter, REFNSIID aIID, void **aResult)
396 if (!aResult) {
397 return NS_ERROR_INVALID_POINTER;
399 if (aOuter) {
400 *aResult = nsnull;
401 return NS_ERROR_NO_AGGREGATION;
403 nsStreamConverterService* inst = nsnull;
404 nsresult rv = NS_NewStreamConv(&inst);
405 if (NS_FAILED(rv)) {
406 *aResult = nsnull;
407 return rv;
409 rv = inst->QueryInterface(aIID, aResult);
410 if (NS_FAILED(rv)) {
411 *aResult = nsnull;
413 NS_RELEASE(inst); /* get rid of extra refcnt */
414 return rv;
417 #ifdef NECKO_PROTOCOL_ftp
418 static NS_IMETHODIMP
419 CreateNewFTPDirListingConv(nsISupports* aOuter, REFNSIID aIID, void **aResult)
421 if (!aResult) {
422 return NS_ERROR_INVALID_POINTER;
424 if (aOuter) {
425 *aResult = nsnull;
426 return NS_ERROR_NO_AGGREGATION;
428 nsFTPDirListingConv* inst = nsnull;
429 nsresult rv = NS_NewFTPDirListingConv(&inst);
430 if (NS_FAILED(rv)) {
431 *aResult = nsnull;
432 return rv;
434 rv = inst->QueryInterface(aIID, aResult);
435 if (NS_FAILED(rv)) {
436 *aResult = nsnull;
438 NS_RELEASE(inst); /* get rid of extra refcnt */
439 return rv;
441 #endif
443 static NS_IMETHODIMP
444 CreateNewMultiMixedConvFactory(nsISupports* aOuter, REFNSIID aIID, void **aResult)
446 if (!aResult) {
447 return NS_ERROR_INVALID_POINTER;
449 if (aOuter) {
450 *aResult = nsnull;
451 return NS_ERROR_NO_AGGREGATION;
453 nsMultiMixedConv* inst = nsnull;
454 nsresult rv = NS_NewMultiMixedConv(&inst);
455 if (NS_FAILED(rv)) {
456 *aResult = nsnull;
457 return rv;
459 rv = inst->QueryInterface(aIID, aResult);
460 if (NS_FAILED(rv)) {
461 *aResult = nsnull;
463 NS_RELEASE(inst); /* get rid of extra refcnt */
464 return rv;
467 static NS_IMETHODIMP
468 CreateNewTXTToHTMLConvFactory(nsISupports* aOuter, REFNSIID aIID, void **aResult)
470 if (!aResult) {
471 return NS_ERROR_INVALID_POINTER;
473 if (aOuter) {
474 *aResult = nsnull;
475 return NS_ERROR_NO_AGGREGATION;
477 mozTXTToHTMLConv* inst = nsnull;
478 nsresult rv = MOZ_NewTXTToHTMLConv(&inst);
479 if (NS_FAILED(rv)) {
480 *aResult = nsnull;
481 return rv;
483 rv = inst->QueryInterface(aIID, aResult);
484 if (NS_FAILED(rv)) {
485 *aResult = nsnull;
487 NS_RELEASE(inst); /* get rid of extra refcnt */
488 return rv;
491 static NS_IMETHODIMP
492 CreateNewHTTPCompressConvFactory (nsISupports* aOuter, REFNSIID aIID, void **aResult)
494 if (!aResult) {
495 return NS_ERROR_INVALID_POINTER;
497 if (aOuter) {
498 *aResult = nsnull;
499 return NS_ERROR_NO_AGGREGATION;
501 nsHTTPCompressConv* inst = nsnull;
502 nsresult rv = NS_NewHTTPCompressConv (&inst);
503 if (NS_FAILED(rv)) {
504 *aResult = nsnull;
505 return rv;
507 rv = inst->QueryInterface(aIID, aResult);
508 if (NS_FAILED(rv)) {
509 *aResult = nsnull;
511 NS_RELEASE(inst); /* get rid of extra refcnt */
512 return rv;
515 static NS_IMETHODIMP
516 CreateNewUnknownDecoderFactory(nsISupports *aOuter, REFNSIID aIID, void **aResult)
518 nsresult rv;
520 if (!aResult) {
521 return NS_ERROR_NULL_POINTER;
523 *aResult = nsnull;
525 if (aOuter) {
526 return NS_ERROR_NO_AGGREGATION;
529 nsUnknownDecoder *inst;
531 inst = new nsUnknownDecoder();
532 if (!inst) {
533 return NS_ERROR_OUT_OF_MEMORY;
535 NS_ADDREF(inst);
536 rv = inst->QueryInterface(aIID, aResult);
537 NS_RELEASE(inst);
539 return rv;
542 static NS_IMETHODIMP
543 CreateNewBinaryDetectorFactory(nsISupports *aOuter, REFNSIID aIID, void **aResult)
545 nsresult rv;
547 if (!aResult) {
548 return NS_ERROR_NULL_POINTER;
550 *aResult = nsnull;
552 if (aOuter) {
553 return NS_ERROR_NO_AGGREGATION;
556 nsBinaryDetector* inst = new nsBinaryDetector();
557 if (!inst) {
558 return NS_ERROR_OUT_OF_MEMORY;
560 NS_ADDREF(inst);
561 rv = inst->QueryInterface(aIID, aResult);
562 NS_RELEASE(inst);
564 return rv;
567 static NS_IMETHODIMP
568 CreateNewNSTXTToHTMLConvFactory(nsISupports *aOuter, REFNSIID aIID, void **aResult)
570 nsresult rv;
572 if (!aResult) {
573 return NS_ERROR_NULL_POINTER;
575 *aResult = nsnull;
577 if (aOuter) {
578 return NS_ERROR_NO_AGGREGATION;
581 nsTXTToHTMLConv *inst;
583 inst = new nsTXTToHTMLConv();
584 if (!inst) return NS_ERROR_OUT_OF_MEMORY;
586 NS_ADDREF(inst);
587 rv = inst->Init();
588 if (NS_FAILED(rv)) {
589 delete inst;
590 return rv;
592 rv = inst->QueryInterface(aIID, aResult);
593 NS_RELEASE(inst);
595 return rv;
598 ///////////////////////////////////////////////////////////////////////////////
599 // Module implementation for the net library
601 // Net module startup hook
602 static nsresult nsNetStartup(nsIModule *neckoModule)
604 gNetStrings = new nsNetStrings();
605 return gNetStrings ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
609 // Net module shutdown hook
610 static void nsNetShutdown(nsIModule *neckoModule)
612 // Release the url parser that the stdurl is holding.
613 nsStandardURL::ShutdownGlobalObjects();
615 // Release buffer cache
616 NS_IF_RELEASE(nsIOService::gBufferCache);
618 // Release global state used by the URL helper module.
619 net_ShutdownURLHelper();
620 #ifdef XP_MACOSX
621 net_ShutdownURLHelperOSX();
622 #endif
624 // Release necko strings
625 delete gNetStrings;
626 gNetStrings = nsnull;
628 // Release DNS service reference.
629 nsDNSPrefetch::Shutdown();
632 static const nsModuleComponentInfo gNetModuleInfo[] = {
633 { NS_IOSERVICE_CLASSNAME,
634 NS_IOSERVICE_CID,
635 NS_IOSERVICE_CONTRACTID,
636 nsIOServiceConstructor },
637 { NS_IOSERVICE_CLASSNAME,
638 NS_IOSERVICE_CID,
639 NS_NETUTIL_CONTRACTID,
640 nsIOServiceConstructor },
641 { NS_STREAMTRANSPORTSERVICE_CLASSNAME,
642 NS_STREAMTRANSPORTSERVICE_CID,
643 NS_STREAMTRANSPORTSERVICE_CONTRACTID,
644 nsStreamTransportServiceConstructor },
645 { NS_SOCKETTRANSPORTSERVICE_CLASSNAME,
646 NS_SOCKETTRANSPORTSERVICE_CID,
647 NS_SOCKETTRANSPORTSERVICE_CONTRACTID,
648 nsSocketTransportServiceConstructor },
649 { NS_SERVERSOCKET_CLASSNAME,
650 NS_SERVERSOCKET_CID,
651 NS_SERVERSOCKET_CONTRACTID,
652 nsServerSocketConstructor },
653 { NS_SOCKETPROVIDERSERVICE_CLASSNAME,
654 NS_SOCKETPROVIDERSERVICE_CID,
655 NS_SOCKETPROVIDERSERVICE_CONTRACTID,
656 nsSocketProviderService::Create },
657 { NS_DNSSERVICE_CLASSNAME,
658 NS_DNSSERVICE_CID,
659 NS_DNSSERVICE_CONTRACTID,
660 nsDNSServiceConstructor },
661 { NS_IDNSERVICE_CLASSNAME,
662 NS_IDNSERVICE_CID,
663 NS_IDNSERVICE_CONTRACTID,
664 nsIDNServiceConstructor },
665 { NS_EFFECTIVETLDSERVICE_CLASSNAME,
666 NS_EFFECTIVETLDSERVICE_CID,
667 NS_EFFECTIVETLDSERVICE_CONTRACTID,
668 nsEffectiveTLDServiceConstructor },
669 { NS_SIMPLEURI_CLASSNAME,
670 NS_SIMPLEURI_CID,
671 NS_SIMPLEURI_CONTRACTID,
672 nsSimpleURIConstructor },
673 { "Simple Nested URI",
674 NS_SIMPLENESTEDURI_CID,
675 nsnull,
676 nsSimpleNestedURIConstructor },
677 { NS_ASYNCSTREAMCOPIER_CLASSNAME,
678 NS_ASYNCSTREAMCOPIER_CID,
679 NS_ASYNCSTREAMCOPIER_CONTRACTID,
680 nsAsyncStreamCopierConstructor },
681 { NS_INPUTSTREAMPUMP_CLASSNAME,
682 NS_INPUTSTREAMPUMP_CID,
683 NS_INPUTSTREAMPUMP_CONTRACTID,
684 nsInputStreamPumpConstructor },
685 { NS_INPUTSTREAMCHANNEL_CLASSNAME,
686 NS_INPUTSTREAMCHANNEL_CID,
687 NS_INPUTSTREAMCHANNEL_CONTRACTID,
688 nsInputStreamChannelConstructor },
689 { NS_STREAMLOADER_CLASSNAME,
690 NS_STREAMLOADER_CID,
691 NS_STREAMLOADER_CONTRACTID,
692 nsStreamLoader::Create },
693 { NS_UNICHARSTREAMLOADER_CLASSNAME,
694 NS_UNICHARSTREAMLOADER_CID,
695 NS_UNICHARSTREAMLOADER_CONTRACTID,
696 nsUnicharStreamLoader::Create },
697 { NS_DOWNLOADER_CLASSNAME,
698 NS_DOWNLOADER_CID,
699 NS_DOWNLOADER_CONTRACTID,
700 nsDownloaderConstructor },
701 { NS_SYNCSTREAMLISTENER_CLASSNAME,
702 NS_SYNCSTREAMLISTENER_CID,
703 NS_SYNCSTREAMLISTENER_CONTRACTID,
704 nsSyncStreamListenerConstructor },
705 { NS_REQUESTOBSERVERPROXY_CLASSNAME,
706 NS_REQUESTOBSERVERPROXY_CID,
707 NS_REQUESTOBSERVERPROXY_CONTRACTID,
708 nsRequestObserverProxyConstructor },
709 { NS_SIMPLESTREAMLISTENER_CLASSNAME,
710 NS_SIMPLESTREAMLISTENER_CID,
711 NS_SIMPLESTREAMLISTENER_CONTRACTID,
712 nsSimpleStreamListenerConstructor },
713 { NS_STREAMLISTENERTEE_CLASSNAME,
714 NS_STREAMLISTENERTEE_CID,
715 NS_STREAMLISTENERTEE_CONTRACTID,
716 nsStreamListenerTeeConstructor },
717 { NS_LOADGROUP_CLASSNAME,
718 NS_LOADGROUP_CID,
719 NS_LOADGROUP_CONTRACTID,
720 nsLoadGroupConstructor },
721 { NS_LOCALFILEINPUTSTREAM_CLASSNAME,
722 NS_LOCALFILEINPUTSTREAM_CID,
723 NS_LOCALFILEINPUTSTREAM_CONTRACTID,
724 nsFileInputStream::Create },
725 { NS_LOCALFILEOUTPUTSTREAM_CLASSNAME,
726 NS_LOCALFILEOUTPUTSTREAM_CID,
727 NS_LOCALFILEOUTPUTSTREAM_CONTRACTID,
728 nsFileOutputStream::Create },
729 { NS_SAFELOCALFILEOUTPUTSTREAM_CLASSNAME,
730 NS_SAFELOCALFILEOUTPUTSTREAM_CID,
731 NS_SAFELOCALFILEOUTPUTSTREAM_CONTRACTID,
732 nsSafeFileOutputStreamConstructor
735 { "URIChecker",
736 NS_URICHECKER_CID,
737 NS_URICHECKER_CONTRACT_ID,
738 nsURICheckerConstructor
741 { NS_INCREMENTALDOWNLOAD_CLASSNAME,
742 NS_INCREMENTALDOWNLOAD_CID,
743 NS_INCREMENTALDOWNLOAD_CONTRACTID,
744 net_NewIncrementalDownload
747 // The register functions for the built-in
748 // parsers just need to be called once.
749 { NS_STDURLPARSER_CLASSNAME,
750 NS_STDURLPARSER_CID,
751 NS_STDURLPARSER_CONTRACTID,
752 nsStdURLParserConstructor},
753 { NS_NOAUTHURLPARSER_CLASSNAME,
754 NS_NOAUTHURLPARSER_CID,
755 NS_NOAUTHURLPARSER_CONTRACTID,
756 nsNoAuthURLParserConstructor },
757 { NS_AUTHURLPARSER_CLASSNAME,
758 NS_AUTHURLPARSER_CID,
759 NS_AUTHURLPARSER_CONTRACTID,
760 nsAuthURLParserConstructor },
762 { NS_STANDARDURL_CLASSNAME,
763 NS_STANDARDURL_CID,
764 NS_STANDARDURL_CONTRACTID,
765 nsStandardURLConstructor },
767 { NS_BUFFEREDINPUTSTREAM_CLASSNAME,
768 NS_BUFFEREDINPUTSTREAM_CID,
769 NS_BUFFEREDINPUTSTREAM_CONTRACTID,
770 nsBufferedInputStream::Create },
771 { NS_BUFFEREDOUTPUTSTREAM_CLASSNAME,
772 NS_BUFFEREDOUTPUTSTREAM_CID,
773 NS_BUFFEREDOUTPUTSTREAM_CONTRACTID,
774 nsBufferedOutputStream::Create },
775 { NS_MIMEINPUTSTREAM_CLASSNAME,
776 NS_MIMEINPUTSTREAM_CID,
777 NS_MIMEINPUTSTREAM_CONTRACTID,
778 nsMIMEInputStreamConstructor },
779 { NS_PROTOCOLPROXYSERVICE_CLASSNAME,
780 NS_PROTOCOLPROXYSERVICE_CID,
781 NS_PROTOCOLPROXYSERVICE_CONTRACTID,
782 nsProtocolProxyServiceConstructor,
783 nsnull, nsnull, nsnull,
784 NS_CI_INTERFACE_GETTER_NAME(nsProtocolProxyService),
785 nsnull,
786 &NS_CLASSINFO_NAME(nsProtocolProxyService),
787 nsIClassInfo::SINGLETON },
789 // from netwerk/streamconv:
791 // this converter is "always" built.
792 // HACK-ALERT, register *all* converters
793 // in this converter's component manager
794 // registration. just piggy backing here until
795 // you can add registration functions to
796 // the generic module macro.
797 { "Stream Converter Service",
798 NS_STREAMCONVERTERSERVICE_CID,
799 NS_STREAMCONVERTERSERVICE_CONTRACTID,
800 CreateNewStreamConvServiceFactory,
801 RegisterStreamConverters, // registers *all* converters
802 UnregisterStreamConverters // unregisters *all* converters
805 #ifdef BUILD_APPLEFILE_DECODER
806 { NS_APPLEFILEDECODER_CLASSNAME,
807 NS_APPLEFILEDECODER_CID,
808 NS_IAPPLEFILEDECODER_CONTRACTID,
809 nsAppleFileDecoderConstructor
811 #endif
813 #ifdef NECKO_PROTOCOL_ftp
814 // from netwerk/streamconv/converters:
815 { "FTPDirListingConverter",
816 NS_FTPDIRLISTINGCONVERTER_CID,
817 NS_ISTREAMCONVERTER_KEY FTP_TO_INDEX,
818 CreateNewFTPDirListingConv
820 #endif
822 #ifdef NECKO_PROTOCOL_gopher
823 { "GopherDirListingConverter",
824 NS_GOPHERDIRLISTINGCONVERTER_CID,
825 NS_ISTREAMCONVERTER_KEY GOPHER_TO_INDEX,
826 nsGopherDirListingConvConstructor
828 #endif
830 { "Indexed to HTML Converter",
831 NS_NSINDEXEDTOHTMLCONVERTER_CID,
832 NS_ISTREAMCONVERTER_KEY INDEX_TO_HTML,
833 nsIndexedToHTML::Create
836 { "Directory Index Parser",
837 NS_DIRINDEXPARSER_CID,
838 NS_DIRINDEXPARSER_CONTRACTID,
839 nsDirIndexParserConstructor
842 { "MultiMixedConverter",
843 NS_MULTIMIXEDCONVERTER_CID,
844 NS_ISTREAMCONVERTER_KEY MULTI_MIXED_X,
845 CreateNewMultiMixedConvFactory
848 { "MultiMixedByteRange",
849 NS_MULTIMIXEDCONVERTER_CID,
850 NS_ISTREAMCONVERTER_KEY MULTI_BYTERANGES,
851 CreateNewMultiMixedConvFactory
854 { "MultiMixedConverter2",
855 NS_MULTIMIXEDCONVERTER_CID,
856 NS_ISTREAMCONVERTER_KEY MULTI_MIXED,
857 CreateNewMultiMixedConvFactory
860 { "Unknown Content-Type Decoder",
861 NS_UNKNOWNDECODER_CID,
862 NS_ISTREAMCONVERTER_KEY UNKNOWN_CONTENT,
863 CreateNewUnknownDecoderFactory
866 { "Unknown Content-Type Decoder",
867 NS_UNKNOWNDECODER_CID,
868 NS_GENERIC_CONTENT_SNIFFER,
869 CreateNewUnknownDecoderFactory
872 { "Binary Detector",
873 NS_BINARYDETECTOR_CID,
874 NS_BINARYDETECTOR_CONTRACTID,
875 CreateNewBinaryDetectorFactory,
876 nsBinaryDetector::Register
879 { "HttpCompressConverter",
880 NS_HTTPCOMPRESSCONVERTER_CID,
881 NS_ISTREAMCONVERTER_KEY GZIP_TO_UNCOMPRESSED,
882 CreateNewHTTPCompressConvFactory
885 { "HttpCompressConverter",
886 NS_HTTPCOMPRESSCONVERTER_CID,
887 NS_ISTREAMCONVERTER_KEY XGZIP_TO_UNCOMPRESSED,
888 CreateNewHTTPCompressConvFactory
890 { "HttpCompressConverter",
891 NS_HTTPCOMPRESSCONVERTER_CID,
892 NS_ISTREAMCONVERTER_KEY COMPRESS_TO_UNCOMPRESSED,
893 CreateNewHTTPCompressConvFactory
895 { "HttpCompressConverter",
896 NS_HTTPCOMPRESSCONVERTER_CID,
897 NS_ISTREAMCONVERTER_KEY XCOMPRESS_TO_UNCOMPRESSED,
898 CreateNewHTTPCompressConvFactory
900 { "HttpCompressConverter",
901 NS_HTTPCOMPRESSCONVERTER_CID,
902 NS_ISTREAMCONVERTER_KEY DEFLATE_TO_UNCOMPRESSED,
903 CreateNewHTTPCompressConvFactory
905 { "NSTXTToHTMLConverter",
906 NS_NSTXTTOHTMLCONVERTER_CID,
907 NS_ISTREAMCONVERTER_KEY PLAIN_TO_HTML,
908 CreateNewNSTXTToHTMLConvFactory
910 #ifdef BUILD_BINHEX_DECODER
911 { "nsBinHexConverter", NS_BINHEXDECODER_CID,
912 NS_ISTREAMCONVERTER_KEY BINHEX_TO_WILD,
913 nsBinHexDecoderConstructor
915 #endif
916 // This is not a real stream converter, it's just
917 // registering its cid factory here.
918 { "HACK-TXTToHTMLConverter",
919 MOZITXTTOHTMLCONV_CID,
920 MOZ_TXTTOHTMLCONV_CONTRACTID,
921 CreateNewTXTToHTMLConvFactory
924 { "Directory Index",
925 NS_DIRINDEX_CID,
926 "@mozilla.org/dirIndex;1",
927 nsDirIndexConstructor
930 // from netwerk/mime:
931 { "mime header param",
932 NS_MIMEHEADERPARAM_CID,
933 NS_MIMEHEADERPARAM_CONTRACTID,
934 nsMIMEHeaderParamImplConstructor
937 #ifdef NECKO_PROTOCOL_file
938 // from netwerk/protocol/file:
939 { NS_FILEPROTOCOLHANDLER_CLASSNAME,
940 NS_FILEPROTOCOLHANDLER_CID,
941 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "file",
942 nsFileProtocolHandlerConstructor
944 #endif
946 #ifdef NECKO_PROTOCOL_http
947 { "HTTP Handler",
948 NS_HTTPPROTOCOLHANDLER_CID,
949 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "http",
950 nsHttpHandlerConstructor },
952 { "HTTPS Handler",
953 NS_HTTPSPROTOCOLHANDLER_CID,
954 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "https",
955 nsHttpsHandlerConstructor },
957 { "HTTP Basic Auth Encoder",
958 NS_HTTPBASICAUTH_CID,
959 NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX "basic",
960 nsHttpBasicAuthConstructor },
962 { "HTTP Digest Auth Encoder",
963 NS_HTTPDIGESTAUTH_CID,
964 NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX "digest",
965 nsHttpDigestAuthConstructor },
967 { "HTTP NTLM Auth Encoder",
968 NS_HTTPNTLMAUTH_CID,
969 NS_HTTP_AUTHENTICATOR_CONTRACTID_PREFIX "ntlm",
970 nsHttpNTLMAuthConstructor },
972 { NS_HTTPAUTHMANAGER_CLASSNAME,
973 NS_HTTPAUTHMANAGER_CID,
974 NS_HTTPAUTHMANAGER_CONTRACTID,
975 nsHttpAuthManagerConstructor },
976 #endif // !NECKO_PROTOCOL_http
978 #ifdef NECKO_PROTOCOL_ftp
979 // from netwerk/protocol/ftp:
980 { NS_FTPPROTOCOLHANDLER_CLASSNAME,
981 NS_FTPPROTOCOLHANDLER_CID,
982 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "ftp",
983 nsFtpProtocolHandlerConstructor
985 #endif
987 #ifdef NECKO_PROTOCOL_res
988 // from netwerk/protocol/res:
989 { NS_RESPROTOCOLHANDLER_CLASSNAME,
990 NS_RESPROTOCOLHANDLER_CID,
991 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "resource",
992 nsResProtocolHandlerConstructor
994 { NS_RESURL_CLASSNAME, // needed only for fastload
995 NS_RESURL_CID,
996 nsnull,
997 nsResURLConstructor
999 #endif
1001 // from netwerk/protocol/about (about:blank is mandatory):
1002 { NS_ABOUTPROTOCOLHANDLER_CLASSNAME,
1003 NS_ABOUTPROTOCOLHANDLER_CID,
1004 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "about",
1005 nsAboutProtocolHandlerConstructor
1007 { NS_SAFEABOUTPROTOCOLHANDLER_CLASSNAME,
1008 NS_SAFEABOUTPROTOCOLHANDLER_CID,
1009 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "moz-safe-about",
1010 nsSafeAboutProtocolHandlerConstructor
1012 { "about:blank",
1013 NS_ABOUT_BLANK_MODULE_CID,
1014 NS_ABOUT_MODULE_CONTRACTID_PREFIX "blank",
1015 nsAboutBlank::Create
1017 #ifdef NECKO_PROTOCOL_about
1018 #ifdef NS_BUILD_REFCNT_LOGGING
1019 { "about:bloat",
1020 NS_ABOUT_BLOAT_MODULE_CID,
1021 NS_ABOUT_MODULE_CONTRACTID_PREFIX "bloat",
1022 nsAboutBloat::Create
1024 #endif
1025 { "about:cache",
1026 NS_ABOUT_CACHE_MODULE_CID,
1027 NS_ABOUT_MODULE_CONTRACTID_PREFIX "cache",
1028 nsAboutCache::Create
1030 { "about:cache-entry",
1031 NS_ABOUT_CACHE_ENTRY_MODULE_CID,
1032 NS_ABOUT_MODULE_CONTRACTID_PREFIX "cache-entry",
1033 nsAboutCacheEntryConstructor
1035 #endif
1037 { "nsSOCKSSocketProvider",
1038 NS_SOCKSSOCKETPROVIDER_CID,
1039 NS_NETWORK_SOCKET_CONTRACTID_PREFIX "socks",
1040 nsSOCKSSocketProvider::CreateV5
1043 { "nsSOCKS4SocketProvider",
1044 NS_SOCKS4SOCKETPROVIDER_CID,
1045 NS_NETWORK_SOCKET_CONTRACTID_PREFIX "socks4",
1046 nsSOCKSSocketProvider::CreateV4
1049 { "nsUDPSocketProvider",
1050 NS_UDPSOCKETPROVIDER_CID,
1051 NS_NETWORK_SOCKET_CONTRACTID_PREFIX "udp",
1052 nsUDPSocketProviderConstructor
1055 { NS_CACHESERVICE_CLASSNAME,
1056 NS_CACHESERVICE_CID,
1057 NS_CACHESERVICE_CONTRACTID,
1058 nsCacheService::Create
1061 #ifdef NECKO_OFFLINE_CACHE
1062 { NS_APPLICATIONCACHESERVICE_CLASSNAME,
1063 NS_APPLICATIONCACHESERVICE_CID,
1064 NS_APPLICATIONCACHESERVICE_CONTRACTID,
1065 nsOfflineCacheDeviceConstructor
1067 { NS_APPLICATIONCACHENAMESPACE_CLASSNAME,
1068 NS_APPLICATIONCACHENAMESPACE_CID,
1069 NS_APPLICATIONCACHENAMESPACE_CONTRACTID,
1070 nsApplicationCacheNamespaceConstructor
1072 #endif
1074 #ifdef NECKO_COOKIES
1075 { NS_COOKIEMANAGER_CLASSNAME,
1076 NS_COOKIEMANAGER_CID,
1077 NS_COOKIEMANAGER_CONTRACTID,
1078 nsCookieServiceConstructor
1081 { NS_COOKIESERVICE_CLASSNAME,
1082 NS_COOKIESERVICE_CID,
1083 NS_COOKIESERVICE_CONTRACTID,
1084 nsCookieServiceConstructor
1086 #endif
1088 #ifdef NECKO_PROTOCOL_gopher
1089 //gopher:
1090 { "The Gopher Protocol Handler",
1091 NS_GOPHERHANDLER_CID,
1092 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "gopher",
1093 nsGopherHandlerConstructor
1095 #endif
1097 #ifdef NECKO_PROTOCOL_data
1098 // from netwerk/protocol/data:
1099 { "Data Protocol Handler",
1100 NS_DATAPROTOCOLHANDLER_CID,
1101 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "data",
1102 nsDataHandler::Create},
1103 #endif
1105 #ifdef NECKO_PROTOCOL_viewsource
1106 // from netwerk/protocol/viewsource:
1107 { "The ViewSource Protocol Handler",
1108 NS_VIEWSOURCEHANDLER_CID,
1109 NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "view-source",
1110 nsViewSourceHandlerConstructor
1112 #endif
1114 #if defined(XP_WIN) && !defined(WINCE)
1115 { NS_NETWORK_LINK_SERVICE_CLASSNAME,
1116 NS_NETWORK_LINK_SERVICE_CID,
1117 NS_NETWORK_LINK_SERVICE_CONTRACTID,
1118 nsNotifyAddrListenerConstructor
1120 #elif defined(MOZ_WIDGET_COCOA)
1121 { NS_NETWORK_LINK_SERVICE_CLASSNAME,
1122 NS_NETWORK_LINK_SERVICE_CID,
1123 NS_NETWORK_LINK_SERVICE_CONTRACTID,
1124 nsNetworkLinkServiceConstructor
1126 #endif
1129 NS_IMPL_NSGETMODULE_WITH_CTOR_DTOR(necko, gNetModuleInfo,
1130 nsNetStartup, nsNetShutdown)