diff --git a/mozilla/network/module/nsHttpUrl.cpp b/mozilla/network/module/nsHttpUrl.cpp
index f0741e6024f..510c59c4707 100644
--- a/mozilla/network/module/nsHttpUrl.cpp
+++ b/mozilla/network/module/nsHttpUrl.cpp
@@ -53,6 +53,7 @@ public:
/* nsIProtocolConnection interface... */
NS_IMETHOD InitializeURLInfo(URL_Struct_ *URL_s);
+ NS_IMETHOD GetURLInfo(URL_Struct_** aResult);
/* nsIPostToServer interface... */
NS_IMETHOD SendFile(const char *aFile);
@@ -175,6 +176,22 @@ NS_METHOD nsHttpUrlImpl::InitializeURLInfo(URL_Struct *URL_s)
}
+NS_METHOD nsHttpUrlImpl::GetURLInfo(URL_Struct_** aResult)
+{
+ nsresult rv;
+
+ if (nsnull == aResult) {
+ rv = NS_ERROR_NULL_POINTER;
+ } else {
+ /* XXX: Should the URL be reference counted here?? */
+ *aResult = m_URL_s;
+ rv = NS_OK;
+ }
+
+ return rv;
+}
+
+
NS_METHOD nsHttpUrlImpl::SendFile(const char *aFile)
{
nsresult result;
diff --git a/mozilla/network/module/nsINetService.h b/mozilla/network/module/nsINetService.h
index 40f81377a29..dc7669e076f 100644
--- a/mozilla/network/module/nsINetService.h
+++ b/mozilla/network/module/nsINetService.h
@@ -73,6 +73,14 @@ struct nsINetService : public nsISupports
nsIStreamListener *aConsumer,
nsIInputStream **aNewStream) = 0;
+ /**
+ * Interrupt an asynchronous URL load.
+ *
+ * @param aUrl The URL to stop loading.
+ * @return Returns NS_OK if successful, or NS_ERROR_FAILURE if an error occurred.
+ */
+ NS_IMETHOD InterruptStream(nsIURL* aURL) = 0;
+
/**
* Get the complete cookie string associated with the URL
*
diff --git a/mozilla/network/module/nsIProtocolConnection.h b/mozilla/network/module/nsIProtocolConnection.h
index bfa47bb35a7..7c4dd72507f 100644
--- a/mozilla/network/module/nsIProtocolConnection.h
+++ b/mozilla/network/module/nsIProtocolConnection.h
@@ -1,4 +1,4 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+/* -*- 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
@@ -29,13 +29,15 @@ struct URL_Struct_;
/* 121CC0F1-EA26-11d1-BEAE-00805F8A66DC */
#define NS_IPROTOCOLCONNECTION_IID \
{ 0x121cc0f1, 0xea26, 0x11d1, \
- { 0xbe, 0xae, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0xdc } }
+ { 0xbe, 0xae, 0x0, 0x80, 0x5f, 0x8a, 0x66, 0xdc } }
-struct nsIProtocolConnection : public nsISupports
+class nsIProtocolConnection : public nsISupports
{
- NS_IMETHOD InitializeURLInfo(URL_Struct_ *URL_s) = 0;
+public:
+ NS_IMETHOD InitializeURLInfo(URL_Struct_ *URL_s) = 0;
+ NS_IMETHOD GetURLInfo(URL_Struct_ **aResult) = 0;
};
-#endif /* nsIHttpUrl_h___ */
+#endif /* nsIIProtocolConnection_h___ */
diff --git a/mozilla/network/module/nsNetService.cpp b/mozilla/network/module/nsNetService.cpp
index a282ae0ecaf..f359bc5bdec 100644
--- a/mozilla/network/module/nsNetService.cpp
+++ b/mozilla/network/module/nsNetService.cpp
@@ -310,12 +310,6 @@ nsresult nsNetlibService::OpenStream(nsIURL *aUrl,
SetupURLStruct(aUrl, URL_s);
- /*
- * Mark the URL as background loading. This prevents many
- * client upcall notifications...
- */
- URL_s->load_background = FALSE;
-
/*
* Attach the Data Consumer to the URL_Struct.
*
@@ -449,12 +443,6 @@ nsresult nsNetlibService::OpenBlockingStream(nsIURL *aUrl,
}
#endif /* XP_WIN && !NETLIB_THREAD */
- /*
- * Mark the URL as background loading. This prevents many
- * client upcall notifications...
- */
- URL_s->load_background = FALSE;
-
/*
* Attach the ConnectionInfo object to the URL_Struct.
*
@@ -506,6 +494,38 @@ loser:
return NS_FALSE;
}
+NS_IMETHODIMP
+nsNetlibService::InterruptStream(nsIURL* aURL)
+{
+ nsIProtocolConnection *pProtocol;
+ nsresult rv = NS_OK;
+
+ if (nsnull == aURL) {
+ rv = NS_ERROR_NULL_POINTER;
+ goto done;
+ }
+
+ rv = aURL->QueryInterface(kIProtocolConnectionIID, (void**)&pProtocol);
+ if (NS_SUCCEEDED(rv)) {
+ URL_Struct* URL_s;
+ int status = -1;
+
+ pProtocol->GetURLInfo(&URL_s);
+ if (nsnull != URL_s) {
+ status = NET_InterruptStream(URL_s);
+ }
+ NS_RELEASE(pProtocol);
+
+ if (status != 0) {
+ rv = NS_ERROR_FAILURE;
+ }
+ }
+
+done:
+ return rv;
+}
+
+
NS_IMETHODIMP
nsNetlibService::GetCookieString(nsIURL *aURL, nsString& aCookie)
{
diff --git a/mozilla/network/module/nsURL.cpp b/mozilla/network/module/nsURL.cpp
index 664467a6418..21e56659a4a 100644
--- a/mozilla/network/module/nsURL.cpp
+++ b/mozilla/network/module/nsURL.cpp
@@ -696,7 +696,7 @@ nsIInputStream* URLImpl::Open(PRInt32* aErrorCode)
(nsISupports **)&inet);
if (NS_OK == rv) {
rv = inet->OpenBlockingStream(this, NULL, &in);
- NS_RELEASE(inet);
+ nsServiceManager::ReleaseService(kNetServiceCID, inet);
}
*aErrorCode = rv;
@@ -716,7 +716,7 @@ nsresult URLImpl::Open(nsIStreamListener *aListener)
(nsISupports **)&inet);
if (NS_OK == rv) {
rv = inet->OpenStream(this, aListener);
- NS_RELEASE(inet);
+ nsServiceManager::ReleaseService(kNetServiceCID, inet);
}
}
return rv;