1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=8 et tw=80 : */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #define ALLOW_LATE_HTTPLOG_H_INCLUDE 1
8 #include "base/basictypes.h"
11 #include "nsIClassInfoImpl.h"
12 #include "mozilla/Components.h"
13 #include "mozilla/ModuleUtils.h"
15 #include "nsSimpleURI.h"
16 #include "nsLoadGroup.h"
17 #include "nsMimeTypes.h"
18 #include "nsDNSPrefetch.h"
19 #include "nsXULAppAPI.h"
20 #include "nsCategoryCache.h"
21 #include "nsIContentSniffer.h"
22 #include "nsStandardURL.h"
23 #include "mozilla/net/BackgroundChannelRegistrar.h"
24 #include "mozilla/net/NeckoChild.h"
25 #ifdef MOZ_AUTH_EXTENSION
26 # include "nsAuthGSSAPI.h"
31 #if defined(XP_MACOSX) || defined(XP_WIN) || defined(XP_LINUX)
32 # define BUILD_NETWORK_INFO_SERVICE 1
35 using namespace mozilla
;
37 using ContentSnifferCache
= nsCategoryCache
<nsIContentSniffer
>;
38 ContentSnifferCache
* gNetSniffers
= nullptr;
39 ContentSnifferCache
* gDataSniffers
= nullptr;
40 ContentSnifferCache
* gORBSniffers
= nullptr;
41 ContentSnifferCache
* gNetAndORBSniffers
= nullptr;
44 using nsLoadGroup
= mozilla::net::nsLoadGroup
;
45 NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsLoadGroup
, Init
)
48 ///////////////////////////////////////////////////////////////////////////////
50 ///////////////////////////////////////////////////////////////////////////////
53 #include "nsHttpHandler.h"
54 #include "Http2Compression.h"
57 #include "nsHttpAuthManager.h"
58 #include "nsHttpActivityDistributor.h"
59 #include "ThrottleQueue.h"
63 NS_IMPL_COMPONENT_FACTORY(net::nsHttpHandler
) {
64 return net::nsHttpHandler::GetInstance().downcast
<nsIHttpProtocolHandler
>();
67 NS_IMPL_COMPONENT_FACTORY(net::nsHttpsHandler
) {
68 auto handler
= MakeRefPtr
<net::nsHttpsHandler
>();
70 if (NS_FAILED(handler
->Init())) {
73 return handler
.forget().downcast
<nsIHttpProtocolHandler
>();
76 #include "WebSocketChannel.h"
77 #include "WebSocketChannelChild.h"
78 namespace mozilla::net
{
79 static BaseWebSocketChannel
* WebSocketChannelConstructor(bool aSecure
) {
81 return new WebSocketChannelChild(aSecure
);
85 return new WebSocketSSLChannel
;
87 return new WebSocketChannel
;
90 #define WEB_SOCKET_HANDLER_CONSTRUCTOR(type, secure) \
91 nsresult type##Constructor(REFNSIID aIID, void** aResult) { \
92 RefPtr<BaseWebSocketChannel> inst; \
95 inst = WebSocketChannelConstructor(secure); \
96 return inst->QueryInterface(aIID, aResult); \
99 WEB_SOCKET_HANDLER_CONSTRUCTOR(WebSocketChannel
, false)
100 WEB_SOCKET_HANDLER_CONSTRUCTOR(WebSocketSSLChannel
, true)
101 #undef WEB_SOCKET_HANDLER_CONSTRUCTOR
102 } // namespace mozilla::net
104 ///////////////////////////////////////////////////////////////////////////////
106 #include "nsStreamConverterService.h"
107 #include "nsMultiMixedConv.h"
108 #include "nsHTTPCompressConv.h"
109 #include "mozTXTToHTMLConv.h"
110 #include "nsUnknownDecoder.h"
112 ///////////////////////////////////////////////////////////////////////////////
114 #include "nsIndexedToHTML.h"
116 nsresult
NS_NewMultiMixedConv(nsMultiMixedConv
** result
);
117 nsresult
MOZ_NewTXTToHTMLConv(mozTXTToHTMLConv
** result
);
118 nsresult
NS_NewHTTPCompressConv(mozilla::net::nsHTTPCompressConv
** result
);
119 nsresult
NS_NewStreamConv(nsStreamConverterService
** aStreamConv
);
121 nsresult
CreateNewStreamConvServiceFactory(REFNSIID aIID
, void** aResult
) {
123 return NS_ERROR_INVALID_POINTER
;
125 RefPtr
<nsStreamConverterService
> inst
;
126 nsresult rv
= NS_NewStreamConv(getter_AddRefs(inst
));
131 rv
= inst
->QueryInterface(aIID
, aResult
);
138 nsresult
CreateNewMultiMixedConvFactory(REFNSIID aIID
, void** aResult
) {
140 return NS_ERROR_INVALID_POINTER
;
142 RefPtr
<nsMultiMixedConv
> inst
;
143 nsresult rv
= NS_NewMultiMixedConv(getter_AddRefs(inst
));
148 rv
= inst
->QueryInterface(aIID
, aResult
);
155 nsresult
CreateNewTXTToHTMLConvFactory(REFNSIID aIID
, void** aResult
) {
157 return NS_ERROR_INVALID_POINTER
;
159 RefPtr
<mozTXTToHTMLConv
> inst
;
160 nsresult rv
= MOZ_NewTXTToHTMLConv(getter_AddRefs(inst
));
165 rv
= inst
->QueryInterface(aIID
, aResult
);
172 nsresult
CreateNewHTTPCompressConvFactory(REFNSIID aIID
, void** aResult
) {
174 return NS_ERROR_INVALID_POINTER
;
176 RefPtr
<mozilla::net::nsHTTPCompressConv
> inst
;
177 nsresult rv
= NS_NewHTTPCompressConv(getter_AddRefs(inst
));
182 rv
= inst
->QueryInterface(aIID
, aResult
);
189 nsresult
CreateNewUnknownDecoderFactory(REFNSIID aIID
, void** aResult
) {
191 return NS_ERROR_NULL_POINTER
;
195 RefPtr
<nsUnknownDecoder
> inst
= new nsUnknownDecoder();
196 return inst
->QueryInterface(aIID
, aResult
);
199 nsresult
CreateNewBinaryDetectorFactory(REFNSIID aIID
, void** aResult
) {
201 return NS_ERROR_NULL_POINTER
;
205 RefPtr
<nsBinaryDetector
> inst
= new nsBinaryDetector();
206 return inst
->QueryInterface(aIID
, aResult
);
209 ///////////////////////////////////////////////////////////////////////////////
210 // Module implementation for the net library
212 // Net module startup hook
213 nsresult
nsNetStartup() {
214 mozilla::net::nsStandardURL::InitGlobalObjects();
218 // Net module shutdown hook
219 void nsNetShutdown() {
220 // Release the url parser that the stdurl is holding.
221 mozilla::net::nsStandardURL::ShutdownGlobalObjects();
223 // Release global state used by the URL helper module.
224 net_ShutdownURLHelper();
226 net_ShutdownURLHelperOSX();
229 // Release DNS service reference.
230 nsDNSPrefetch::Shutdown();
232 // Release the Websocket Admission Manager
233 mozilla::net::WebSocketChannel::Shutdown();
235 mozilla::net::Http2CompressionCleanup();
237 #ifdef MOZ_AUTH_EXTENSION
238 nsAuthGSSAPI::Shutdown();
242 gNetSniffers
= nullptr;
243 delete gDataSniffers
;
244 gDataSniffers
= nullptr;
246 gORBSniffers
= nullptr;
247 delete gNetAndORBSniffers
;
248 gNetAndORBSniffers
= nullptr;