diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp
index 5a2b0548255..64d5d7e1335 100644
--- a/mozilla/content/html/document/src/nsHTMLDocument.cpp
+++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp
@@ -41,6 +41,7 @@
#include "nsIScriptGlobalObject.h"
#include "nsContentList.h"
#include "nsINetService.h"
+#include "nsIServiceManager.h"
#include "nsIFormManager.h"
#include "nsRepository.h"
#include "nsParserCIID.h"
@@ -67,6 +68,8 @@ static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
static NS_DEFINE_IID(kIDOMNSHTMLDocumentIID, NS_IDOMNSHTMLDOCUMENT_IID);
+static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
+static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
NS_LAYOUT nsresult
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult)
@@ -684,9 +687,9 @@ NS_IMETHODIMP
nsHTMLDocument::GetCookie(nsString& aCookie)
{
nsINetService *service;
- nsresult res = NS_OK;
-
- res = NS_NewINetService(&service, nsnull);
+ nsresult res = nsServiceManager::GetService(kNetServiceCID,
+ kINetServiceIID,
+ (nsISupports **)&service);
if ((NS_OK == res) && (nsnull != service)) {
res = service->GetCookieString(mDocumentURL, aCookie);
@@ -701,9 +704,9 @@ NS_IMETHODIMP
nsHTMLDocument::SetCookie(const nsString& aCookie)
{
nsINetService *service;
- nsresult res = NS_OK;
-
- res = NS_NewINetService(&service, nsnull);
+ nsresult res = nsServiceManager::GetService(kNetServiceCID,
+ kINetServiceIID,
+ (nsISupports **)&service);
if ((NS_OK == res) && (nsnull != service)) {
res = service->SetCookieString(mDocumentURL, aCookie);
diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp
index 2afaeaa175d..2046b72037f 100644
--- a/mozilla/dom/src/base/nsGlobalWindow.cpp
+++ b/mozilla/dom/src/base/nsGlobalWindow.cpp
@@ -27,6 +27,7 @@
#include "nsIScriptContext.h"
#include "nsIDOMDocument.h"
#include "nsINetService.h"
+#include "nsIServiceManager.h"
#include "nsINetContainerApplication.h"
#include "nsITimer.h"
#include "nsEventListenerManager.h"
@@ -71,6 +72,8 @@ static NS_DEFINE_IID(kIDOMEventReceiverIID, NS_IDOMEVENTRECEIVER_IID);
static NS_DEFINE_IID(kIBrowserWindowIID, NS_IBROWSER_WINDOW_IID);
static NS_DEFINE_IID(kIScriptContextOwnerIID, NS_ISCRIPTCONTEXTOWNER_IID);
static NS_DEFINE_IID(kIDocumentIID, NS_IDOCUMENT_IID);
+static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
+static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
GlobalWindowImpl::GlobalWindowImpl()
{
@@ -1548,133 +1551,145 @@ NavigatorImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObject)
NS_IMETHODIMP
NavigatorImpl::GetUserAgent(nsString& aUserAgent)
{
- nsINetService *service;
- nsresult res = NS_OK;
-
- res = NS_NewINetService(&service, nsnull);
- if ((NS_OK == res) && (nsnull != service)) {
- nsINetContainerApplication *container;
+ nsINetService *service = nsnull;
+ nsresult res = nsServiceManager::GetService(kNetServiceCID,
+ kINetServiceIID,
+ (nsISupports **)&service);
- res = service->GetContainerApplication(&container);
- if ((NS_OK == res) && (nsnull != container)) {
- nsAutoString appVersion;
- container->GetAppCodeName(aUserAgent);
- container->GetAppVersion(appVersion);
+ if ((NS_OK == res) && (nsnull != service)) {
- aUserAgent.Append('/');
- aUserAgent.Append(appVersion);
- NS_RELEASE(container);
+ nsINetContainerApplication *container;
+ res = service->GetContainerApplication(&container);
+ if ((NS_OK == res) && (nsnull != container)) {
+
+ if (NS_OK == (res = container->GetAppCodeName(aUserAgent)) ) {
+
+ nsAutoString appVersion;
+ if (NS_OK == (res = container->GetAppVersion(appVersion)) ) {
+ aUserAgent.Append('/');
+ aUserAgent.Append(appVersion);
+ }
+ }
+ NS_RELEASE(container);
+ }
+ NS_RELEASE(service);
}
-
- NS_RELEASE(service);
- }
-
- return res;
+ return res;
}
NS_IMETHODIMP
NavigatorImpl::GetAppCodeName(nsString& aAppCodeName)
{
- nsINetService *service;
- nsresult res = NS_OK;
-
- res = NS_NewINetService(&service, nsnull);
- if ((NS_OK == res) && (nsnull != service)) {
- nsINetContainerApplication *container;
+ nsINetService *service;
+ nsresult res = nsServiceManager::GetService(kNetServiceCID,
+ kINetServiceIID,
+ (nsISupports **)&service);
- res = service->GetContainerApplication(&container);
- if ((NS_OK == res) && (nsnull != container)) {
- res = container->GetAppCodeName(aAppCodeName);
- NS_RELEASE(container);
+ if ((NS_OK == res) && (nsnull != service)) {
+
+ nsINetContainerApplication *container;
+ res = service->GetContainerApplication(&container);
+ if ((NS_OK == res) && (nsnull != container)) {
+
+ res = container->GetAppCodeName(aAppCodeName);
+ NS_RELEASE(container);
+ }
+ NS_RELEASE(service);
}
-
- NS_RELEASE(service);
- }
- return res;
+
+ return res;
}
NS_IMETHODIMP
NavigatorImpl::GetAppVersion(nsString& aAppVersion)
{
- nsINetService *service;
- nsresult res = NS_OK;
-
- res = NS_NewINetService(&service, nsnull);
- if ((NS_OK == res) && (nsnull != service)) {
- nsINetContainerApplication *container;
+ nsINetService *service;
+ nsresult res = nsServiceManager::GetService(kNetServiceCID,
+ kINetServiceIID,
+ (nsISupports **)&service);
- res = service->GetContainerApplication(&container);
- if ((NS_OK == res) && (nsnull != container)) {
- res = container->GetAppVersion(aAppVersion);
- NS_RELEASE(container);
+ if ((NS_OK == res) && (nsnull != service)) {
+
+ nsINetContainerApplication *container;
+ res = service->GetContainerApplication(&container);
+ if ((NS_OK == res) && (nsnull != container)) {
+
+ res = container->GetAppVersion(aAppVersion);
+ NS_RELEASE(container);
+ }
+ NS_RELEASE(service);
}
-
- NS_RELEASE(service);
- }
- return res;
+
+ return res;
}
NS_IMETHODIMP
NavigatorImpl::GetAppName(nsString& aAppName)
{
- nsINetService *service;
- nsresult res = NS_OK;
-
- res = NS_NewINetService(&service, nsnull);
- if ((NS_OK == res) && (nsnull != service)) {
- nsINetContainerApplication *container;
+ nsINetService *service;
+ nsresult res = nsServiceManager::GetService(kNetServiceCID,
+ kINetServiceIID,
+ (nsISupports **)&service);
- res = service->GetContainerApplication(&container);
- if ((NS_OK == res) && (nsnull != container)) {
- res = container->GetAppName(aAppName);
- NS_RELEASE(container);
+ if ((NS_OK == res) && (nsnull != service)) {
+
+ nsINetContainerApplication *container;
+ res = service->GetContainerApplication(&container);
+ if ((NS_OK == res) && (nsnull != container)) {
+
+ res = container->GetAppName(aAppName);
+ NS_RELEASE(container);
+ }
+ NS_RELEASE(service);
}
-
- NS_RELEASE(service);
- }
- return res;
+
+ return res;
}
NS_IMETHODIMP
NavigatorImpl::GetLanguage(nsString& aLanguage)
{
- nsINetService *service;
- nsresult res = NS_OK;
-
- res = NS_NewINetService(&service, nsnull);
- if ((NS_OK == res) && (nsnull != service)) {
- nsINetContainerApplication *container;
+ nsINetService *service;
+ nsresult res = nsServiceManager::GetService(kNetServiceCID,
+ kINetServiceIID,
+ (nsISupports **)&service);
- res = service->GetContainerApplication(&container);
- if ((NS_OK == res) && (nsnull != container)) {
- res = container->GetLanguage(aLanguage);
- NS_RELEASE(container);
+ if ((NS_OK == res) && (nsnull != service)) {
+
+ nsINetContainerApplication *container;
+ res = service->GetContainerApplication(&container);
+ if ((NS_OK == res) && (nsnull != container)) {
+
+ res = container->GetLanguage(aLanguage);
+ NS_RELEASE(container);
+ }
+ NS_RELEASE(service);
}
-
- NS_RELEASE(service);
- }
- return res;
+
+ return res;
}
NS_IMETHODIMP
NavigatorImpl::GetPlatform(nsString& aPlatform)
{
- nsINetService *service;
- nsresult res = NS_OK;
-
- res = NS_NewINetService(&service, nsnull);
- if ((NS_OK == res) && (nsnull != service)) {
- nsINetContainerApplication *container;
+ nsINetService *service;
+ nsresult res = nsServiceManager::GetService(kNetServiceCID,
+ kINetServiceIID,
+ (nsISupports **)&service);
- res = service->GetContainerApplication(&container);
- if ((NS_OK == res) && (nsnull != container)) {
- res = container->GetPlatform(aPlatform);
- NS_RELEASE(container);
+ if ((NS_OK == res) && (nsnull != service)) {
+
+ nsINetContainerApplication *container;
+ res = service->GetContainerApplication(&container);
+ if ((NS_OK == res) && (nsnull != container)) {
+
+ res = container->GetPlatform(aPlatform);
+ NS_RELEASE(container);
+ }
+ NS_RELEASE(service);
}
-
- NS_RELEASE(service);
- }
- return res;
+
+ return res;
}
NS_IMETHODIMP
diff --git a/mozilla/gfx/src/nsImageNetContextSync.cpp b/mozilla/gfx/src/nsImageNetContextSync.cpp
index d3c8fb93d93..01b0ec67444 100644
--- a/mozilla/gfx/src/nsImageNetContextSync.cpp
+++ b/mozilla/gfx/src/nsImageNetContextSync.cpp
@@ -27,9 +27,12 @@
#include "plstr.h"
#include "il_strm.h"
#include "nsINetService.h"
+#include "nsIServiceManager.h"
static NS_DEFINE_IID(kIImageNetContextIID, IL_INETCONTEXT_IID);
static NS_DEFINE_IID(kIURLIID, NS_IURL_IID);
+static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
+static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
class ImageNetContextSyncImpl : public ilINetContext {
public:
@@ -158,8 +161,11 @@ ImageNetContextSyncImpl::GetURL(ilIURL* aURL,
// Get a network service interface which we'll use to create a stream
nsINetService *service;
+ nsresult res = nsServiceManager::GetService(kNetServiceCID,
+ kINetServiceIID,
+ (nsISupports **)&service);
- if (NS_SUCCEEDED(NS_NewINetService(&service, nsnull))) {
+ if (NS_SUCCEEDED(res)) {
nsIInputStream* stream = nsnull;
// Initiate a synchronous URL load
diff --git a/mozilla/layout/html/document/src/nsHTMLDocument.cpp b/mozilla/layout/html/document/src/nsHTMLDocument.cpp
index 5a2b0548255..64d5d7e1335 100644
--- a/mozilla/layout/html/document/src/nsHTMLDocument.cpp
+++ b/mozilla/layout/html/document/src/nsHTMLDocument.cpp
@@ -41,6 +41,7 @@
#include "nsIScriptGlobalObject.h"
#include "nsContentList.h"
#include "nsINetService.h"
+#include "nsIServiceManager.h"
#include "nsIFormManager.h"
#include "nsRepository.h"
#include "nsParserCIID.h"
@@ -67,6 +68,8 @@ static NS_DEFINE_IID(kIDOMNodeIID, NS_IDOMNODE_IID);
static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IHTMLDOCUMENT_IID);
static NS_DEFINE_IID(kIDOMHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
static NS_DEFINE_IID(kIDOMNSHTMLDocumentIID, NS_IDOMNSHTMLDOCUMENT_IID);
+static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
+static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
NS_LAYOUT nsresult
NS_NewHTMLDocument(nsIDocument** aInstancePtrResult)
@@ -684,9 +687,9 @@ NS_IMETHODIMP
nsHTMLDocument::GetCookie(nsString& aCookie)
{
nsINetService *service;
- nsresult res = NS_OK;
-
- res = NS_NewINetService(&service, nsnull);
+ nsresult res = nsServiceManager::GetService(kNetServiceCID,
+ kINetServiceIID,
+ (nsISupports **)&service);
if ((NS_OK == res) && (nsnull != service)) {
res = service->GetCookieString(mDocumentURL, aCookie);
@@ -701,9 +704,9 @@ NS_IMETHODIMP
nsHTMLDocument::SetCookie(const nsString& aCookie)
{
nsINetService *service;
- nsresult res = NS_OK;
-
- res = NS_NewINetService(&service, nsnull);
+ nsresult res = nsServiceManager::GetService(kNetServiceCID,
+ kINetServiceIID,
+ (nsISupports **)&service);
if ((NS_OK == res) && (nsnull != service)) {
res = service->SetCookieString(mDocumentURL, aCookie);
diff --git a/mozilla/network/module/Makefile b/mozilla/network/module/Makefile
index 0201817b528..b39187eeefa 100644
--- a/mozilla/network/module/Makefile
+++ b/mozilla/network/module/Makefile
@@ -30,6 +30,7 @@ CPPSRCS = \
nsNetStubs.cpp \
nsNetIDs.cpp \
nsLoadAttribs.cpp \
+ nsNetFactory.cpp \
$(NULL)
REQUIRES = raptor js dbm nspr security pref xpcom util img \
diff --git a/mozilla/network/module/makefile.win b/mozilla/network/module/makefile.win
index 823400f6e58..889d943f2bb 100644
--- a/mozilla/network/module/makefile.win
+++ b/mozilla/network/module/makefile.win
@@ -72,6 +72,7 @@ OBJS= \
.\$(OBJDIR)\nsNetIDs.obj \
.\$(OBJDIR)\nsNetFile.obj \
.\$(OBJDIR)\nsLoadAttribs.obj \
+ .\$(OBJDIR)\nsNetFactory.obj \
$(NULL)
#//------------------------------------------------------------------------
diff --git a/mozilla/network/module/nsINetService.h b/mozilla/network/module/nsINetService.h
index dc735c27dc6..04368b97912 100644
--- a/mozilla/network/module/nsINetService.h
+++ b/mozilla/network/module/nsINetService.h
@@ -34,6 +34,12 @@
{ 0xcfb1a480, 0xc78f, 0x11d1, \
{0xbe, 0xa2, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc} }
+/* {3F1BFE70-4D9C-11d2-9E7E-006008BF092E} */
+#define NS_NETSERVICE_CID \
+{ 0x3f1bfe70, 0x4d9c, 0x11d2, \
+ {0x9e, 0x7e, 0x00, 0x60, 0x08, 0xbf, 0x09, 0x2e} }
+
+
class nsINetContainerApplication;
/**
diff --git a/mozilla/network/module/nsIStreamListener.h b/mozilla/network/module/nsIStreamListener.h
index aa3e3840b21..fd64f0baff2 100644
--- a/mozilla/network/module/nsIStreamListener.h
+++ b/mozilla/network/module/nsIStreamListener.h
@@ -83,9 +83,6 @@ public:
{ 0x45d234d0, 0xc6c9, 0x11d1, \
{0xbe, 0xa2, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc} }
-NS_DECLARE_ID(kIStreamListenerIID, 0x45d234d0, 0xc6c9, 0x11d1,
- 0xbe, 0xa2, 0x00, 0x80, 0x5f, 0x8a, 0x66, 0xdc);
-
/**
* The nsIStreamListener interface provides the necessary notifications
* during both synchronous and asynchronous URL loading.
diff --git a/mozilla/network/module/nsNetFactory.cpp b/mozilla/network/module/nsNetFactory.cpp
new file mode 100644
index 00000000000..0541235e473
--- /dev/null
+++ b/mozilla/network/module/nsNetFactory.cpp
@@ -0,0 +1,163 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ *
+ * The contents of this file are subject to the Netscape Public License
+ * Version 1.0 (the "NPL"); you may not use this file except in
+ * compliance with the NPL. You may obtain a copy of the NPL at
+ * http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the NPL is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
+ * for the specific language governing rights and limitations under the
+ * NPL.
+ *
+ * The Initial Developer of this code under the NPL is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998 Netscape Communications Corporation. All Rights
+ * Reserved.
+ */
+#include "nscore.h"
+#include "nsIFactory.h"
+#include "nsISupports.h"
+#include "nsINetService.h"
+#include "nsNetService.h"
+
+/* This implementation of the network service factory is presently
+ * only taking advantage of the service retrieval benefit that the
+ * nsINetService interface provides. The module initialization and
+ * unloading is still bound to main program execution and closing.
+ * Once we break this dependence, the
+ * nsNetFactory will also appropriately handle loading/initializing/
+ * unloading of the library.
+ */
+
+static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
+static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
+static NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
+
+extern nsNetlibService *gNetlibService; // See nsNetService.cpp
+
+class nsNetFactory : public nsIFactory
+{
+ public:
+ // nsISupports methods
+ NS_IMETHOD QueryInterface(const nsIID &aIID,
+ void **aResult);
+ NS_IMETHOD_(nsrefcnt) AddRef(void);
+ NS_IMETHOD_(nsrefcnt) Release(void);
+
+ // nsIFactory methods
+ NS_IMETHOD CreateInstance(nsISupports *aOuter,
+ const nsIID &aIID,
+ void **aResult);
+
+ NS_IMETHOD LockFactory(PRBool aLock);
+
+ nsNetFactory(const nsCID &aClass);
+
+ protected:
+ virtual ~nsNetFactory();
+
+ private:
+ nsrefcnt mRefCnt;
+ nsCID mClassID;
+};
+
+nsNetFactory::nsNetFactory(const nsCID &aClass)
+{
+ mRefCnt = 0;
+ mClassID = aClass;
+}
+
+nsNetFactory::~nsNetFactory()
+{
+ NS_ASSERTION(mRefCnt == 0, "non-zero refcnt at destruction");
+}
+
+nsresult nsNetFactory::QueryInterface(const nsIID &aIID,
+ void **aResult)
+{
+ if (aResult == NULL) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ // Always NULL result, in case of failure
+ *aResult = NULL;
+
+ if (aIID.Equals(kISupportsIID)) {
+ *aResult = (void *)(nsISupports*)this;
+ } else if (aIID.Equals(kIFactoryIID)) {
+ *aResult = (void *)(nsIFactory*)this;
+ }
+
+ if (*aResult == NULL) {
+ return NS_NOINTERFACE;
+ }
+
+ AddRef(); // Increase reference count for caller
+ return NS_OK;
+}
+
+nsrefcnt nsNetFactory::AddRef()
+{
+ return ++mRefCnt;
+}
+
+nsrefcnt nsNetFactory::Release()
+{
+ if (--mRefCnt == 0) {
+ delete this;
+ return 0; // Don't access mRefCnt after deleting!
+ }
+ return mRefCnt;
+}
+
+nsresult nsNetFactory::CreateInstance(nsISupports *aOuter,
+ const nsIID &aIID,
+ void **aResult)
+{
+ nsresult res;
+ if (aResult == NULL) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ *aResult = NULL;
+
+ if (mClassID.Equals(kNetServiceCID)) {
+ // No need create a new one if we've already got one.
+ if (!gNetlibService) {
+ res = NS_InitINetService(nsnull);
+ if (res != NS_OK)
+ return NS_ERROR_FAILURE;
+ }
+
+ // Hook the caller up.
+ res = NS_NewINetService((nsINetService**)aResult, aOuter);
+ }
+ return res;
+}
+
+nsresult nsNetFactory::LockFactory(PRBool aLock)
+{
+ // Not implemented in simplest case.
+ return NS_OK;
+}
+
+// return the proper factory to the caller
+#ifdef XP_MAC
+extern "C" NS_NET nsresult NSGetFactory_DOM_DLL(const nsCID &aClass, nsIFactory **aFactory)
+#else
+extern "C" NS_NET nsresult NSGetFactory(const nsCID &aClass, nsIFactory **aFactory)
+#endif
+{
+ if (nsnull == aFactory) {
+ return NS_ERROR_NULL_POINTER;
+ }
+
+ *aFactory = new nsNetFactory(aClass);
+
+ if (nsnull == aFactory) {
+ return NS_ERROR_OUT_OF_MEMORY;
+ }
+
+ return (*aFactory)->QueryInterface(kIFactoryIID, (void**)aFactory);
+}
diff --git a/mozilla/network/module/nsNetFile.cpp b/mozilla/network/module/nsNetFile.cpp
index 5510d8888d3..c5678dfdeb7 100644
--- a/mozilla/network/module/nsNetFile.cpp
+++ b/mozilla/network/module/nsNetFile.cpp
@@ -718,7 +718,7 @@ nsresult nsNetFile::FileRemove(const char *aPath) {
// We should never be deleting a relative file.
NS_PRECONDITION( ( (*path != mDirDel) && (*path && (*path+1 != ':'))), "Deleting a relative path.");
- if (PR_Delete(aPath) == PR_FAILURE)
+ if (PR_Delete(path) == PR_FAILURE)
return NS_ERROR_FAILURE;
return NS_OK;
diff --git a/mozilla/network/module/nsNetService.cpp b/mozilla/network/module/nsNetService.cpp
index 267ebadc8fc..ec60b844b5a 100644
--- a/mozilla/network/module/nsNetService.cpp
+++ b/mozilla/network/module/nsNetService.cpp
@@ -637,8 +637,8 @@ nsresult PerformNastyWindowsAsyncDNSHack(URL_Struct *URL_s, nsIURL* aURL)
}
#endif /* XP_WIN */
-
-static nsNetlibService *gNetlibService = nsnull;
+// This is global so it can be accessed by the NetFactory (nsNetFactory.cpp)
+nsNetlibService *gNetlibService = nsnull;
//
// Class to manage static initialization of the Netlib DLL...
diff --git a/mozilla/network/module/nsURL.cpp b/mozilla/network/module/nsURL.cpp
index 1ebcc4cc7a4..69e7784a7aa 100644
--- a/mozilla/network/module/nsURL.cpp
+++ b/mozilla/network/module/nsURL.cpp
@@ -18,6 +18,7 @@
#include "nsIURL.h"
#include "nsIInputStream.h"
#include "nsINetService.h"
+#include "nsIServiceManager.h"
#include "nsIHttpUrl.h" /* NS_NewHttpUrl(...) */
#include "nsString.h"
#include
@@ -614,11 +615,14 @@ nsresult URLImpl::ParseURL(const nsIURL* aURL, const nsString& aSpec)
return NS_OK;
}
+static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
+static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
+
nsIInputStream* URLImpl::Open(PRInt32* aErrorCode)
{
nsresult rv;
nsIInputStream* in = nsnull;
- nsINetService *inet;
+ nsINetService *inet = nsnull;
// XXX: Rewrite the resource: URL into a file: URL
if (PL_strcmp(mProtocol, "resource") == 0) {
@@ -629,7 +633,12 @@ nsIInputStream* URLImpl::Open(PRInt32* aErrorCode)
PR_Free(fileName);
}
- rv = NS_NewINetService(&inet, nsnull);
+ nsINetService *service;
+
+ rv = nsServiceManager::GetService(kNetServiceCID,
+ kINetServiceIID,
+ (nsISupports **)&inet);
+
if (NS_OK == rv) {
rv = inet->OpenBlockingStream(this, NULL, &in);
}
@@ -653,7 +662,9 @@ nsresult URLImpl::Open(nsIStreamListener *aListener)
PR_Free(fileName);
}
- rv = NS_NewINetService(&inet, nsnull);
+ rv = nsServiceManager::GetService(kNetServiceCID,
+ kINetServiceIID,
+ (nsISupports **)&inet);
if (NS_OK == rv) {
rv = inet->OpenStream(this, aListener);
}
diff --git a/mozilla/uriloader/base/nsDocLoader.cpp b/mozilla/uriloader/base/nsDocLoader.cpp
index c2b31f52458..6101d55562c 100644
--- a/mozilla/uriloader/base/nsDocLoader.cpp
+++ b/mozilla/uriloader/base/nsDocLoader.cpp
@@ -71,8 +71,7 @@ NS_DEFINE_IID(kIDocumentLoadInfoIID, NS_IDOCUMENTLOADINFO_IID);
NS_DEFINE_IID(kRefreshURLIID, NS_IREFRESHURL_IID);
NS_DEFINE_IID(kHTTPURLIID, NS_IHTTPURL_IID);
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
-
-
+NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
/*
* The nsDocumentBindInfo contains the state required when a single document
diff --git a/mozilla/webshell/src/nsDocLoader.cpp b/mozilla/webshell/src/nsDocLoader.cpp
index c2b31f52458..6101d55562c 100644
--- a/mozilla/webshell/src/nsDocLoader.cpp
+++ b/mozilla/webshell/src/nsDocLoader.cpp
@@ -71,8 +71,7 @@ NS_DEFINE_IID(kIDocumentLoadInfoIID, NS_IDOCUMENTLOADINFO_IID);
NS_DEFINE_IID(kRefreshURLIID, NS_IREFRESHURL_IID);
NS_DEFINE_IID(kHTTPURLIID, NS_IHTTPURL_IID);
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
-
-
+NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
/*
* The nsDocumentBindInfo contains the state required when a single document
diff --git a/mozilla/webshell/src/nsPluginViewer.cpp b/mozilla/webshell/src/nsPluginViewer.cpp
index 70316720d70..05e0f2cb8b1 100644
--- a/mozilla/webshell/src/nsPluginViewer.cpp
+++ b/mozilla/webshell/src/nsPluginViewer.cpp
@@ -38,6 +38,8 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_IID(kIPluginHostIID, NS_IPLUGINHOST_IID);
static NS_DEFINE_IID(kIPluginInstanceOwnerIID, NS_IPLUGININSTANCEOWNER_IID);
static NS_DEFINE_IID(kILinkHandlerIID, NS_ILINKHANDLER_IID);
+static NS_DEFINE_IID(kIStreamListenerIID, NS_ISTREAMLISTENER_IID);
+
class PluginViewerImpl;
diff --git a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp
index c470f33d718..8b090d5b88f 100644
--- a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp
+++ b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp
@@ -37,6 +37,7 @@
#include "nsParserCIID.h"
#include "nsDOMCID.h"
+#include "nsINetService.h"
#ifdef XP_PC
#define WIDGET_DLL "raptorwidget.dll"
@@ -47,6 +48,7 @@
#define PREF_DLL "xppref32.dll"
#define PARSER_DLL "raptorhtmlpars.dll"
#define DOM_DLL "jsdom.dll"
+#define NETLIB_DLL "netlib.dll"
#else
#ifdef XP_MAC
#include "nsMacRepository.h"
@@ -59,6 +61,7 @@
#define PREF_DLL "libpref.so"
#define PARSER_DLL "libraptorhtmlpars.so"
#define DOM_DLL "libjsdom.so"
+#define NETLIB_DLL "netlib.so"
#endif
#endif
@@ -94,6 +97,7 @@ static NS_DEFINE_IID(kCPluginHostCID, NS_PLUGIN_HOST_CID);
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
static NS_DEFINE_IID(kCDOMScriptObjectFactory, NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
+static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
extern "C" void
@@ -130,4 +134,5 @@ NS_SetupRegistry()
nsRepository::RegisterFactory(kCPluginHostCID, PLUGIN_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCParserCID, PARSER_DLL, PR_FALSE, PR_FALSE);
nsRepository::RegisterFactory(kCDOMScriptObjectFactory, DOM_DLL, PR_FALSE, PR_FALSE);
+ nsRepository::RegisterFactory(kNetServiceCID, NETLIB_DLL, PR_FALSE, PR_FALSE);
}