mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-17 22:32:51 +00:00
Necko API and implementation changes for retargeting. Needed for URL dispatching. r=mscott
This commit is contained in:
parent
1900c52e89
commit
34ecf73507
@ -125,8 +125,9 @@ nsChromeProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel* *result)
|
||||
{
|
||||
@ -151,7 +152,10 @@ nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = serv->NewChannelFromURI(verb, chromeURI, aGroup, eventSinkGetter,
|
||||
rv = serv->NewChannelFromURI(verb, chromeURI,
|
||||
aLoadGroup,
|
||||
notificationCallbacks,
|
||||
loadAttributes,
|
||||
originalURI ? originalURI : uri, result);
|
||||
|
||||
// Get a system principal for chrome and set the owner property
|
||||
|
@ -3771,7 +3771,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
||||
nsIUnicharStreamLoader* loader;
|
||||
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
rv = NS_NewUnicharStreamLoader(&loader, url, loadGroup, this);
|
||||
rv = NS_NewUnicharStreamLoader(&loader, url, this, loadGroup);
|
||||
NS_RELEASE(url);
|
||||
if (NS_OK == rv) {
|
||||
rv = NS_ERROR_HTMLPARSER_BLOCK;
|
||||
|
@ -1097,7 +1097,7 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
|
||||
result = NS_NewUnicharStreamLoader(&loader, urlClone, loadGroup, aData);
|
||||
result = NS_NewUnicharStreamLoader(&loader, urlClone, aData, loadGroup);
|
||||
#ifdef NS_DEBUG
|
||||
mSyncCallback = PR_FALSE;
|
||||
#endif
|
||||
|
@ -1813,7 +1813,7 @@ nsXMLContentSink::ProcessStartSCRIPTTag(const nsIParserNode& aNode)
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
rv = NS_NewUnicharStreamLoader(&loader, url, loadGroup, this);
|
||||
rv = NS_NewUnicharStreamLoader(&loader, url, this, loadGroup);
|
||||
NS_RELEASE(url);
|
||||
if (NS_OK == rv) {
|
||||
rv = NS_ERROR_HTMLPARSER_BLOCK;
|
||||
|
@ -4600,7 +4600,7 @@ nsXULDocument::LoadScript(nsIURI* aURI, const char* aVersion, PRBool* aBlock)
|
||||
|
||||
// N.B., the loader will be released in DoneLoadingScript()
|
||||
nsIUnicharStreamLoader* loader;
|
||||
rv = NS_NewUnicharStreamLoader(&loader, aURI, group, this);
|
||||
rv = NS_NewUnicharStreamLoader(&loader, aURI, this, group);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*aBlock = PR_TRUE;
|
||||
|
@ -109,6 +109,7 @@ NS_IMPL_QUERY_HEAD(nsDocShell)
|
||||
NS_IMPL_QUERY_BODY(nsIGenericWindow)
|
||||
NS_IMPL_QUERY_BODY(nsIScrollable)
|
||||
NS_IMPL_QUERY_BODY(nsITextScroll)
|
||||
NS_IMPL_QUERY_BODY(nsICapabilities)
|
||||
// NS_IMPL_QUERY_BODY(nsIInterfaceRequestor)
|
||||
NS_IMPL_QUERY_TAIL(nsIDocShell)
|
||||
|
||||
|
@ -73,6 +73,7 @@ friend class nsDSURIContentListener;
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_DECL_NSICAPABILITIES
|
||||
NS_DECL_NSIDOCSHELL
|
||||
NS_DECL_NSIDOCSHELLEDIT
|
||||
NS_DECL_NSIDOCSHELLFILE
|
||||
|
@ -169,6 +169,7 @@ public:
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICAPABILITIES
|
||||
|
||||
// nsIInterfaceRequestor
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
@ -780,6 +781,7 @@ NS_IMPL_QUERY_HEAD(nsWebShell)
|
||||
NS_IMPL_QUERY_BODY(nsIRefreshURI)
|
||||
NS_IMPL_QUERY_BODY(nsIClipboardCommands)
|
||||
NS_IMPL_QUERY_BODY(nsIInterfaceRequestor)
|
||||
NS_IMPL_QUERY_BODY(nsICapabilities)
|
||||
NS_IMPL_QUERY_TAIL(nsIWebShell)
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -802,7 +804,7 @@ nsWebShell::GetInterface(const nsIID &aIID, void** aInstancePtr)
|
||||
else if(mPluginManager) //XXX this seems a little wrong. MMP
|
||||
return mPluginManager->QueryInterface(aIID, aInstancePtr);
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
return QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -30,7 +30,6 @@
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIStringStream.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsIScriptContext.h"
|
||||
#include "nsIScriptContextOwner.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
@ -41,7 +40,7 @@
|
||||
#include "nsProxyObjectManager.h"
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsDOMError.h"
|
||||
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIEvaluateStringProxy.h"
|
||||
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
@ -191,27 +190,24 @@ nsJSProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJSProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
nsJSProtocolHandler::NewChannel(const char* verb,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel* *result)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(uri);
|
||||
NS_ENSURE_ARG_POINTER(eventSinkGetter);
|
||||
|
||||
nsresult rv;
|
||||
|
||||
// The event sink must be a script context owner or we fail.
|
||||
nsIScriptContextOwner* ownerPtr;
|
||||
rv = eventSinkGetter->GetEventSink(verb,
|
||||
NS_GET_IID(nsIScriptContextOwner),
|
||||
(nsISupports**)&ownerPtr);
|
||||
nsCOMPtr<nsIScriptContextOwner> owner;
|
||||
rv = notificationCallbacks->QueryCapability(NS_GET_IID(nsIScriptContextOwner),
|
||||
getter_AddRefs(owner));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIScriptContextOwner> owner = ownerPtr;
|
||||
NS_RELEASE(ownerPtr);
|
||||
|
||||
if (!owner)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@ -354,7 +350,9 @@ nsJSProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
nsIChannel* channel;
|
||||
|
||||
rv = serv->NewInputStreamChannel(uri, "text/html", length,
|
||||
in, aGroup, originalURI, &channel);
|
||||
in, aLoadGroup,
|
||||
notificationCallbacks, loadAttributes,
|
||||
originalURI, &channel);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
|
@ -236,8 +236,8 @@ NS_NewURItoFile(const char *in, nsFileSpec dirSpec, const char *out)
|
||||
nsCOMPtr<nsIChannel> pChannel;
|
||||
|
||||
// Async reading thru the calls of the event sink interface
|
||||
rv = serv->NewChannelFromURI("load", pURL, nsnull, nsnull, nsnull,
|
||||
getter_AddRefs(pChannel));
|
||||
rv = serv->NewChannelFromURI("load", pURL, nsnull, nsnull,
|
||||
nsIChannel::LOAD_NORMAL, nsnull, getter_AddRefs(pChannel));
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("ERROR: NewChannelFromURI failed for %s\n", in);
|
||||
return rv;
|
||||
|
@ -196,7 +196,8 @@ ImageNetContextSyncImpl::GetURL(ilIURL* aURL,
|
||||
|
||||
// XXX NECKO what verb? what event sink getter
|
||||
nsIChannel *channel = nsnull;
|
||||
rv = service->NewChannelFromURI("load", uri, nsnull, nsnull, nsnull, &channel);
|
||||
rv = service->NewChannelFromURI("load", uri, nsnull, nsnull,
|
||||
nsIChannel::LOAD_NORMAL, nsnull, &channel);
|
||||
NS_RELEASE(uri);
|
||||
if (NS_FAILED(rv))
|
||||
return -1;
|
||||
|
@ -3771,7 +3771,7 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
|
||||
nsIUnicharStreamLoader* loader;
|
||||
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
rv = NS_NewUnicharStreamLoader(&loader, url, loadGroup, this);
|
||||
rv = NS_NewUnicharStreamLoader(&loader, url, this, loadGroup);
|
||||
NS_RELEASE(url);
|
||||
if (NS_OK == rv) {
|
||||
rv = NS_ERROR_HTMLPARSER_BLOCK;
|
||||
|
@ -1097,7 +1097,7 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
|
||||
result = NS_NewUnicharStreamLoader(&loader, urlClone, loadGroup, aData);
|
||||
result = NS_NewUnicharStreamLoader(&loader, urlClone, aData, loadGroup);
|
||||
#ifdef NS_DEBUG
|
||||
mSyncCallback = PR_FALSE;
|
||||
#endif
|
||||
|
@ -1097,7 +1097,7 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
|
||||
result = NS_NewUnicharStreamLoader(&loader, urlClone, loadGroup, aData);
|
||||
result = NS_NewUnicharStreamLoader(&loader, urlClone, aData, loadGroup);
|
||||
#ifdef NS_DEBUG
|
||||
mSyncCallback = PR_FALSE;
|
||||
#endif
|
||||
|
@ -1813,7 +1813,7 @@ nsXMLContentSink::ProcessStartSCRIPTTag(const nsIParserNode& aNode)
|
||||
nsCOMPtr<nsILoadGroup> loadGroup;
|
||||
|
||||
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
|
||||
rv = NS_NewUnicharStreamLoader(&loader, url, loadGroup, this);
|
||||
rv = NS_NewUnicharStreamLoader(&loader, url, this, loadGroup);
|
||||
NS_RELEASE(url);
|
||||
if (NS_OK == rv) {
|
||||
rv = NS_ERROR_HTMLPARSER_BLOCK;
|
||||
|
@ -94,6 +94,7 @@
|
||||
#include "nsIMsgComposeService.h"
|
||||
#include "nsMsgCompFieldsFact.h"
|
||||
#include "nsMsgI18N.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
|
||||
static NS_DEFINE_CID(kIStreamConverterServiceCID, NS_STREAMCONVERTERSERVICE_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
@ -234,15 +235,15 @@ nsMessenger::Open3PaneWindow()
|
||||
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = appShell->CreateTopLevelWindow(nsnull, // parent
|
||||
url,
|
||||
PR_TRUE,
|
||||
PR_TRUE,
|
||||
NS_CHROME_ALL_CHROME,
|
||||
nsnull, // callbacks
|
||||
NS_SIZETOCONTENT, // width
|
||||
NS_SIZETOCONTENT, // height
|
||||
getter_AddRefs(newWindow)); // result widget
|
||||
rv = appShell->CreateTopLevelWindow(nsnull, // parent
|
||||
url,
|
||||
PR_TRUE,
|
||||
PR_TRUE,
|
||||
NS_CHROME_ALL_CHROME,
|
||||
nsnull, // callbacks
|
||||
NS_SIZETOCONTENT, // width
|
||||
NS_SIZETOCONTENT, // height
|
||||
getter_AddRefs(newWindow)); // result widget
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -460,14 +461,20 @@ nsMessenger::OpenAttachment(const char * url, const char * displayName,
|
||||
goto done;
|
||||
}
|
||||
aListener->m_channel = null_nsCOMPtr();
|
||||
NS_WITH_SERVICE(nsIIOService, netService, kIOServiceCID, &rv);
|
||||
rv = netService->NewInputStreamChannel(aURL,
|
||||
nsnull, // contentType
|
||||
-1, // contentLength
|
||||
nsnull, // inputStream
|
||||
nsnull, // loadGroup
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(aListener->m_channel));
|
||||
rv = NS_NewInputStreamChannel(aURL,
|
||||
nsnull, // contentType
|
||||
-1, // contentLength
|
||||
nsnull, // inputStream
|
||||
nsnull, // loadGroup
|
||||
nsnull, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(aListener->m_channel));
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
NS_RELEASE(aListener);
|
||||
goto done;
|
||||
}
|
||||
nsAutoString from, to;
|
||||
from = "message/rfc822";
|
||||
to = "text/xul";
|
||||
@ -587,15 +594,20 @@ nsMessenger::SaveAs(const char* url, PRBool asFile)
|
||||
goto done;
|
||||
}
|
||||
aListener->m_channel = null_nsCOMPtr();
|
||||
NS_WITH_SERVICE(nsIIOService, netService, kIOServiceCID,
|
||||
&rv);
|
||||
rv = netService->NewInputStreamChannel(aURL,
|
||||
nsnull, // contentType
|
||||
-1, // contentLength
|
||||
nsnull, // inputStream
|
||||
nsnull, // loadGroup
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(aListener->m_channel));
|
||||
rv = NS_NewInputStreamChannel(aURL,
|
||||
nsnull, // contentType
|
||||
-1, // contentLength
|
||||
nsnull, // inputStream
|
||||
nsnull, // loadGroup
|
||||
nsnull, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(aListener->m_channel));
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
NS_RELEASE(aListener);
|
||||
goto done;
|
||||
}
|
||||
nsAutoString from, to;
|
||||
from = "message/rfc822";
|
||||
to = saveAsFileType == 1 ? "text/html" : "text/plain";
|
||||
|
@ -67,7 +67,7 @@ nsresult nsMsgProtocol::OpenNetworkSocket(nsIURI * aURL) // open a connection on
|
||||
aURL->GetPort(&port);
|
||||
aURL->GetHost(getter_Copies(hostName));
|
||||
|
||||
rv = socketService->CreateTransport(hostName, port, nsnull, nsnull, getter_AddRefs(m_channel));
|
||||
rv = socketService->CreateTransport(hostName, port, nsnull, getter_AddRefs(m_channel));
|
||||
if (NS_SUCCEEDED(rv) && m_channel)
|
||||
{
|
||||
m_socketIsOpen = PR_FALSE;
|
||||
@ -97,8 +97,9 @@ nsresult nsMsgProtocol::OpenFileSocket(nsIURI * aURL, const nsFileSpec * aFileSp
|
||||
|
||||
rv = netService->NewChannel("Load", urlSpec,
|
||||
nsnull, // null base URI
|
||||
nsnull, // null load group
|
||||
nsnull, // null eventsink getter
|
||||
nsnull, // loadGroup
|
||||
nsnull, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(m_channel));
|
||||
PR_FREEIF(urlSpec);
|
||||
@ -245,7 +246,7 @@ nsresult nsMsgProtocol::SetUrl(nsIURI * aURL)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult nsMsgProtocol::SetLoadGroup(nsILoadGroup * aLoadGroup)
|
||||
NS_IMETHODIMP nsMsgProtocol::SetLoadGroup(nsILoadGroup * aLoadGroup)
|
||||
{
|
||||
m_loadGroup = dont_QueryInterface(aLoadGroup);
|
||||
return NS_OK;
|
||||
@ -319,7 +320,7 @@ NS_IMETHODIMP nsMsgProtocol::GetLoadAttributes(nsLoadFlags *aLoadAttributes)
|
||||
|
||||
NS_IMETHODIMP nsMsgProtocol::SetLoadAttributes(nsLoadFlags aLoadAttributes)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_OK; // don't fail when trying to set this
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgProtocol::GetContentType(char * *aContentType)
|
||||
@ -350,10 +351,24 @@ NS_IMETHODIMP nsMsgProtocol::SetOwner(nsISupports * aPrincipal)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgProtocol::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = m_loadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgProtocol::GetNotificationCallbacks(nsICapabilities* *aNotificationCallbacks)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgProtocol::SetNotificationCallbacks(nsICapabilities* aNotificationCallbacks)
|
||||
{
|
||||
return NS_OK; // don't fail when trying to set this
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// From nsIRequest
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -58,7 +58,6 @@ public:
|
||||
virtual nsresult LoadUrl(nsIURI * aURL, nsISupports * aConsumer = nsnull);
|
||||
|
||||
virtual nsresult SetUrl(nsIURI * aURL); // sometimes we want to set the url before we load it
|
||||
virtual nsresult SetLoadGroup(nsILoadGroup * aLoadGroup);
|
||||
|
||||
// Flag manipulators
|
||||
PRBool TestFlag (PRUint32 flag) {return flag & m_flags;}
|
||||
|
@ -52,12 +52,12 @@
|
||||
#include "nsRDFCID.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsMsgMimeCID.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
|
||||
// CID's needed
|
||||
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
//
|
||||
// Implementation...
|
||||
@ -190,19 +190,19 @@ nsresult rv;
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIChannel> dummyChannel;
|
||||
NS_WITH_SERVICE(nsIIOService, netService, kIOServiceCID, &rv);
|
||||
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
rv = CreateStartupUrl(mURI, getter_AddRefs(aURL));
|
||||
|
||||
rv = netService->NewInputStreamChannel(aURL,
|
||||
nsnull, // contentType
|
||||
-1, // contentLength
|
||||
nsnull, // inputStream
|
||||
nsnull, // loadGroup
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(dummyChannel));
|
||||
nsCOMPtr<nsIChannel> dummyChannel;
|
||||
rv = NS_NewInputStreamChannel(aURL,
|
||||
nsnull, // contentType
|
||||
-1, // contentLength
|
||||
nsnull, // inputStream
|
||||
nsnull, // loadGroup
|
||||
nsnull, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(dummyChannel));
|
||||
if (NS_FAILED(mimeParser->AsyncConvertData(nsnull, nsnull, nsnull, dummyChannel)))
|
||||
{
|
||||
Release();
|
||||
|
@ -187,11 +187,13 @@ nsMsgQuote::QuoteMessage(const PRUnichar *msgURI, PRBool quoteHeaders, nsIStream
|
||||
mQuoteChannel = null_nsCOMPtr();
|
||||
NS_WITH_SERVICE(nsIIOService, netService, kIOServiceCID, &rv);
|
||||
rv = netService->NewInputStreamChannel(aURL,
|
||||
nsnull, // contentType
|
||||
-1, // contentLength
|
||||
nsnull, // inputStream
|
||||
nsnull, // loadGroup
|
||||
nsnull, // originalURI
|
||||
nsnull, // contentType
|
||||
-1, // contentLength
|
||||
nsnull, // inputStream
|
||||
nsnull, // loadGroup
|
||||
nsnull, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(mQuoteChannel));
|
||||
|
||||
NS_WITH_SERVICE(nsIStreamConverterService, streamConverterService, kIStreamConverterServiceCID, &rv);
|
||||
@ -208,7 +210,12 @@ nsMsgQuote::QuoteMessage(const PRUnichar *msgURI, PRBool quoteHeaders, nsIStream
|
||||
|
||||
// now we want to create a necko channel for this url and we want to open it
|
||||
nsCOMPtr<nsIChannel> aChannel;
|
||||
rv = netService->NewChannelFromURI(nsnull, aURL, nsnull, nsnull, nsnull, getter_AddRefs(aChannel));
|
||||
rv = netService->NewChannelFromURI(nsnull, aURL,
|
||||
nsnull, // loadGroup
|
||||
nsnull, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(aChannel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsISupports> aCtxt = do_QueryInterface(aURL);
|
||||
// now try to open the channel passing in our display consumer as the listener
|
||||
|
@ -238,8 +238,12 @@ NS_IMETHODIMP nsSmtpService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsSmtpService::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter, nsIURI* originalURI,
|
||||
NS_IMETHODIMP nsSmtpService::NewChannel(const char *verb,
|
||||
nsIURI *aURI,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **_retval)
|
||||
{
|
||||
// mscott - right now, I don't like the idea of returning channels to the caller. They just want us
|
||||
|
@ -204,7 +204,12 @@ nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = service->NewChannelFromURI("load", aURL, nsnull, nsnull, nsnull, getter_AddRefs(channel));
|
||||
rv = service->NewChannelFromURI("load", aURL,
|
||||
nsnull, // loadGroup
|
||||
nsnull, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(channel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->AsyncRead(0, -1, nsnull, this);
|
||||
|
@ -194,7 +194,12 @@ nsURLFetcher::FireURLRequest(nsIURI *aURL, nsOutputFileStream *fOut,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = service->NewChannelFromURI("load", aURL, nsnull, nsnull, nsnull, getter_AddRefs(channel));
|
||||
rv = service->NewChannelFromURI("load", aURL,
|
||||
nsnull, // loadGroup
|
||||
nsnull, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(channel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->AsyncRead(0, -1, nsnull, this);
|
||||
|
@ -56,7 +56,6 @@ interface nsIImapMockChannel : nsIChannel
|
||||
{
|
||||
void GetChannelListener(out nsIStreamListener aChannelListener);
|
||||
void GetChannelContext(out nsISupports aChannelContext);
|
||||
void SetLoadGroup(in nsILoadGroup aLoadGroup);
|
||||
void SetURI(in nsIURI aUrl);
|
||||
void Close();
|
||||
attribute boolean cancelled;
|
||||
|
@ -604,7 +604,7 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer)
|
||||
aURL->GetHost(getter_Copies(hostName));
|
||||
|
||||
ClearFlag(IMAP_CONNECTION_IS_OPEN);
|
||||
rv = socketService->CreateTransport(hostName, port, nsnull, nsnull, getter_AddRefs(m_channel));
|
||||
rv = socketService->CreateTransport(hostName, port, nsnull, getter_AddRefs(m_channel));
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = m_channel->OpenOutputStream(0 /* start position */, getter_AddRefs(m_outputStream));
|
||||
@ -6363,7 +6363,7 @@ NS_IMETHODIMP nsImapMockChannel::GetLoadAttributes(nsLoadFlags *aLoadAttributes)
|
||||
|
||||
NS_IMETHODIMP nsImapMockChannel::SetLoadAttributes(nsLoadFlags aLoadAttributes)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
return NS_OK; // don't fail when trying to set this
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMockChannel::GetContentType(char * *aContentType)
|
||||
@ -6427,3 +6427,16 @@ NS_IMETHODIMP nsImapMockChannel::SetCancelled(PRBool cancelled)
|
||||
m_cancelled = cancelled;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMockChannel::GetNotificationCallbacks(nsICapabilities* *aNotificationCallbacks)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImapMockChannel::SetNotificationCallbacks(nsICapabilities* aNotificationCallbacks)
|
||||
{
|
||||
return NS_OK; // don't fail when trying to set this
|
||||
}
|
||||
|
||||
|
@ -458,7 +458,8 @@ nsImapService::FetchMessage(nsIImapUrl * aImapUrl,
|
||||
if (NS_SUCCEEDED(rv) && mailnewsUrl)
|
||||
mailnewsUrl->GetLoadGroup(getter_AddRefs(aLoadGroup));
|
||||
|
||||
rv = NewChannel(nsnull, url, aLoadGroup, nsnull, nsnull, getter_AddRefs(aChannel));
|
||||
rv = NewChannel(nsnull, url, aLoadGroup, nsnull, nsIChannel::LOAD_NORMAL,
|
||||
nsnull, getter_AddRefs(aChannel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsISupports> aCtxt = do_QueryInterface(url);
|
||||
@ -2195,8 +2196,12 @@ NS_IMETHODIMP nsImapService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapService::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter, nsIURI* originalURI,
|
||||
NS_IMETHODIMP nsImapService::NewChannel(const char *verb,
|
||||
nsIURI *aURI,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **_retval)
|
||||
{
|
||||
// imap can't open and return a channel right away...the url needs to go in the imap url queue
|
||||
@ -2206,7 +2211,6 @@ NS_IMETHODIMP nsImapService::NewChannel(const char *verb, nsIURI *aURI, nsILoadG
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIImapMockChannel> mockChannel;
|
||||
nsCOMPtr<nsIImapUrl> imapUrl = do_QueryInterface(aURI, &rv);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// XXX this mock channel stuff is wrong -- the channel really should be owning the URL
|
||||
@ -2214,7 +2218,15 @@ NS_IMETHODIMP nsImapService::NewChannel(const char *verb, nsIURI *aURI, nsILoadG
|
||||
rv = imapUrl->GetMockChannel(getter_AddRefs(mockChannel));
|
||||
if (NS_FAILED(rv) || !mockChannel) return rv;
|
||||
|
||||
mockChannel->SetLoadGroup(aGroup);
|
||||
// XXX this seems wrong to do to this shared mock channel too,
|
||||
// but oh well...
|
||||
rv = mockChannel->SetLoadAttributes(loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = mockChannel->SetLoadGroup(aLoadGroup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = mockChannel->SetNotificationCallbacks(notificationCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*_retval = mockChannel;
|
||||
NS_IF_ADDREF(*_retval);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
@ -296,15 +296,24 @@ NS_IMETHODIMP nsMailboxService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIU
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMailboxService::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter, nsIURI* originalURI,
|
||||
NS_IMETHODIMP nsMailboxService::NewChannel(const char *verb,
|
||||
nsIURI *aURI,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsMailboxProtocol * protocol = new nsMailboxProtocol(aURI, originalURI);
|
||||
protocol->SetLoadGroup(aGroup);
|
||||
if (protocol)
|
||||
{
|
||||
rv = protocol->SetLoadAttributes(loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = protocol->SetLoadGroup(aLoadGroup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = protocol->SetNotificationCallbacks(notificationCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = protocol->QueryInterface(NS_GET_IID(nsIChannel), (void **) _retval);
|
||||
}
|
||||
else
|
||||
|
@ -259,8 +259,12 @@ NS_IMETHODIMP nsPop3Service::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsPop3Service::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter, nsIURI* originalURI,
|
||||
NS_IMETHODIMP nsPop3Service::NewChannel(const char *verb,
|
||||
nsIURI *aURI,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **_retval)
|
||||
{
|
||||
// mscott - right now, I don't like the idea of returning channels to the caller. They just want us
|
||||
|
@ -43,9 +43,9 @@
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIMsgQuote.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Bridge routines for new stream converter XP-COM interface
|
||||
@ -421,16 +421,20 @@ NS_IMETHODIMP nsStreamConverter::Init(nsIURI *aURI, nsIStreamListener * aOutList
|
||||
|
||||
// the following output channel stream is used to fake the content type for people who later
|
||||
// call into us..
|
||||
NS_WITH_SERVICE(nsIIOService, netService, kIOServiceCID, &rv);
|
||||
rv = netService->NewInputStreamChannel(aURI, mOutputFormat,
|
||||
-1, // XXX fix contentLength
|
||||
nsnull, nsnull, nsnull, getter_AddRefs(mOutgoingChannel));
|
||||
if (NS_FAILED(rv))
|
||||
rv = NS_NewInputStreamChannel(aURI, mOutputFormat,
|
||||
-1, // XXX fix contentLength
|
||||
nsnull, // inputStream
|
||||
nsnull, // loadGroup
|
||||
nsnull, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(mOutgoingChannel));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
// Set system principal for this document, which will be dynamically generated
|
||||
NS_WITH_SERVICE(nsIScriptSecurityManager, securityManager,
|
||||
NS_SCRIPTSECURITYMANAGER_PROGID, &rv);
|
||||
NS_SCRIPTSECURITYMANAGER_PROGID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
nsCOMPtr<nsIPrincipal> principal;
|
||||
|
@ -939,8 +939,12 @@ NS_IMETHODIMP nsNntpService::NewURI(const char *aSpec, nsIURI *aBaseURI, nsIURI
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsNntpService::NewChannel(const char *verb, nsIURI *aURI, nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter, nsIURI* originalURI,
|
||||
NS_IMETHODIMP nsNntpService::NewChannel(const char *verb,
|
||||
nsIURI *aURI,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **_retval)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
@ -949,7 +953,14 @@ NS_IMETHODIMP nsNntpService::NewChannel(const char *verb, nsIURI *aURI, nsILoadG
|
||||
|
||||
rv = nntpProtocol->Initialize();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nntpProtocol->SetLoadGroup(aGroup);
|
||||
|
||||
rv = nntpProtocol->SetLoadAttributes(loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = nntpProtocol->SetLoadGroup(aLoadGroup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = nntpProtocol->SetNotificationCallbacks(notificationCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return nntpProtocol->QueryInterface(NS_GET_IID(nsIChannel), (void **) _retval);
|
||||
}
|
||||
|
||||
|
@ -122,12 +122,13 @@ nsJARChannel::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARChannel::Init(nsIJARProtocolHandler* aHandler,
|
||||
const char* command,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* getter,
|
||||
nsIURI* originalURI)
|
||||
nsJARChannel::Init(nsIJARProtocolHandler* aHandler,
|
||||
const char* command,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI)
|
||||
{
|
||||
nsresult rv;
|
||||
mURI = do_QueryInterface(uri, &rv);
|
||||
@ -135,9 +136,17 @@ nsJARChannel::Init(nsIJARProtocolHandler* aHandler,
|
||||
mCommand = nsCRT::strdup(command);
|
||||
if (mCommand == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
mLoadGroup = aGroup;
|
||||
mEventSinkGetter = getter;
|
||||
mOriginalURI = originalURI;
|
||||
|
||||
rv = SetLoadAttributes(loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetLoadGroup(aLoadGroup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetNotificationCallbacks(notificationCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -220,7 +229,7 @@ nsJARChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
|
||||
nsCOMPtr<nsIChannel> jarBaseChannel;
|
||||
rv = NS_OpenURI(getter_AddRefs(jarBaseChannel),
|
||||
mJARBaseURI, mLoadGroup, mEventSinkGetter);
|
||||
mJARBaseURI, mLoadGroup, mCallbacks, mLoadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIFileChannel> jarBaseFile = do_QueryInterface(jarBaseChannel, &rv);
|
||||
@ -249,10 +258,13 @@ nsJARChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
// use a file transport to serve as a data pump for the download (done
|
||||
// on some other thread)
|
||||
nsCOMPtr<nsIChannel> jarCacheTransport;
|
||||
rv = fts->CreateTransport(jarCacheFile, mCommand, mEventSinkGetter,
|
||||
rv = fts->CreateTransport(jarCacheFile, mCommand,
|
||||
getter_AddRefs(jarCacheTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = jarCacheTransport->SetNotificationCallbacks(mCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIStreamObserver> downloadObserver = new nsJARDownloadObserver(this);
|
||||
if (downloadObserver == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -299,10 +311,13 @@ nsJARChannel::ExtractJARElement(nsIFileChannel* jarBaseFile)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> jarTransport;
|
||||
rv = fts->CreateTransportFromFileSystem(this, mCommand, mEventSinkGetter,
|
||||
rv = fts->CreateTransportFromFileSystem(this, mCommand,
|
||||
getter_AddRefs(jarTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = jarTransport->SetNotificationCallbacks(mCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = jarTransport->AsyncRead(mStartPosition, mReadCount, nsnull, this);
|
||||
return rv;
|
||||
}
|
||||
@ -400,6 +415,13 @@ nsJARChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetOwner(nsISupports* *aOwner)
|
||||
{
|
||||
@ -415,6 +437,21 @@ nsJARChannel::SetOwner(nsISupports* aOwner)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetNotificationCallbacks(nsICapabilities* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetNotificationCallbacks(nsICapabilities* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIStreamObserver methods:
|
||||
|
||||
|
@ -65,8 +65,13 @@ public:
|
||||
static NS_METHOD
|
||||
Create(nsISupports* aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
nsresult Init(nsIJARProtocolHandler* aHandler, const char* verb, nsIURI* uri,
|
||||
nsILoadGroup* aGroup, nsIEventSinkGetter* getter, nsIURI* originalURI);
|
||||
nsresult Init(nsIJARProtocolHandler* aHandler,
|
||||
const char* command,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI);
|
||||
|
||||
nsresult ExtractJARElement(nsIFileChannel* jarFileChannel);
|
||||
nsresult GetCacheFile(nsFileSpec& cacheFile);
|
||||
@ -75,7 +80,7 @@ protected:
|
||||
char* mCommand;
|
||||
nsCOMPtr<nsIJARURI> mURI;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
nsCOMPtr<nsIEventSinkGetter> mEventSinkGetter;
|
||||
nsCOMPtr<nsICapabilities> mCallbacks;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsLoadFlags mLoadAttributes;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
|
@ -118,10 +118,11 @@ nsJARProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
nsILoadGroup* loadGroup,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel* *result)
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -129,7 +130,8 @@ nsJARProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
rv = nsJARChannel::Create(nsnull, NS_GET_IID(nsIJARChannel), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->Init(this, verb, uri, loadGroup, eventSinkGetter, originalURI);
|
||||
rv = channel->Init(this, verb, uri, aLoadGroup, notificationCallbacks,
|
||||
loadAttributes, originalURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
|
@ -37,7 +37,6 @@ XPIDLSRCS = \
|
||||
nsIStreamObserver.idl \
|
||||
nsIStreamListener.idl \
|
||||
nsIIOService.idl \
|
||||
nsIEventSinkGetter.idl \
|
||||
nsIPrompt.idl \
|
||||
nsIProtocolHandler.idl \
|
||||
nsIProgressEventSink.idl \
|
||||
|
@ -37,7 +37,6 @@ XPIDLSRCS = \
|
||||
.\nsIStreamObserver.idl \
|
||||
.\nsIStreamListener.idl \
|
||||
.\nsIIOService.idl \
|
||||
.\nsIEventSinkGetter.idl \
|
||||
.\nsIPrompt.idl \
|
||||
.\nsIProtocolHandler.idl \
|
||||
.\nsIProgressEventSink.idl \
|
||||
@ -50,7 +49,7 @@ XPIDLSRCS = \
|
||||
.\nsIStatusCodeEventSink.idl \
|
||||
.\nsIFileSystem.idl \
|
||||
.\nsIUnicharStreamLoader.idl \
|
||||
.\nsINetPrompt.idl \
|
||||
.\nsINetPrompt.idl \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
@ -28,6 +28,7 @@ interface nsIOutputStream;
|
||||
interface nsIStreamObserver;
|
||||
interface nsIStreamListener;
|
||||
interface nsILoadGroup;
|
||||
interface nsICapabilities;
|
||||
|
||||
typedef unsigned long nsLoadFlags;
|
||||
|
||||
@ -149,9 +150,16 @@ interface nsIChannel : nsIRequest
|
||||
attribute nsISupports owner;
|
||||
|
||||
/**
|
||||
* Returns the load group in which the channel is a currently a member.
|
||||
* Accesses the load group in which the channel is a currently a member.
|
||||
*/
|
||||
readonly attribute nsILoadGroup loadGroup;
|
||||
attribute nsILoadGroup loadGroup;
|
||||
|
||||
/**
|
||||
* Accesses the capabilities callbacks of the channel. This is set by clients
|
||||
* who wish to provide a means to receive progress, status and protocol-specific
|
||||
* notifications.
|
||||
*/
|
||||
attribute nsICapabilities notificationCallbacks;
|
||||
|
||||
};
|
||||
|
||||
@ -169,7 +177,9 @@ interface nsIInputStreamChannel : nsIChannel
|
||||
in string contentType,
|
||||
in long contentLength,
|
||||
in nsIInputStream inStr,
|
||||
in nsILoadGroup group,
|
||||
in nsILoadGroup aLoadGroup,
|
||||
in nsICapabilities notificationCallbacks,
|
||||
in nsLoadFlags loadAttributes,
|
||||
in nsIURI originalURI);
|
||||
};
|
||||
|
||||
|
@ -36,20 +36,17 @@ native nsFileSpec(nsFileSpec&);
|
||||
interface nsIFileTransportService : nsISupports
|
||||
{
|
||||
[noscript] nsIChannel createTransport(in nsFileSpec spec, // XXX change to nsIFile later
|
||||
in string command,
|
||||
in nsIEventSinkGetter getter);
|
||||
in string command);
|
||||
|
||||
// This version can be used with an existing input stream to serve
|
||||
// as a data pump:
|
||||
nsIChannel createTransportFromStream(in nsIInputStream fromStream,
|
||||
in string contentType,
|
||||
in long contentLength,
|
||||
in string command,
|
||||
in nsIEventSinkGetter getter);
|
||||
in string command);
|
||||
|
||||
nsIChannel createTransportFromFileSystem(in nsIFileSystem fsObj,
|
||||
in string command,
|
||||
in nsIEventSinkGetter getter);
|
||||
in string command);
|
||||
|
||||
void dispatchRequest(in nsIRunnable runnable);
|
||||
void suspend(in nsIRunnable trans);
|
||||
|
@ -21,11 +21,11 @@
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIChannel.idl"
|
||||
|
||||
interface nsIProtocolHandler;
|
||||
interface nsIURI;
|
||||
interface nsIEventSinkGetter;
|
||||
interface nsIChannel;
|
||||
interface nsICapabilities;
|
||||
interface nsIStreamObserver;
|
||||
interface nsIStreamListener;
|
||||
interface nsIEventQueue;
|
||||
@ -53,8 +53,8 @@ interface nsIIOService : nsISupports
|
||||
nsIURI newURI(in string aSpec, in nsIURI aBaseURI);
|
||||
|
||||
/**
|
||||
* Creates a channel for a given URI. The eventSinkGetter is used to
|
||||
* obtain the appropriate callbacks for the URI's protocol from the
|
||||
* Creates a channel for a given URI. The notificationCallbacks argument
|
||||
* is used to obtain the appropriate callbacks for the URI's protocol from the
|
||||
* application.
|
||||
*
|
||||
* @param originalURI - Specifies the original URI which caused the creation
|
||||
@ -67,7 +67,8 @@ interface nsIIOService : nsISupports
|
||||
nsIChannel newChannelFromURI(in string verb,
|
||||
in nsIURI aURI,
|
||||
in nsILoadGroup aLoadGroup,
|
||||
in nsIEventSinkGetter eventSinkGetter,
|
||||
in nsICapabilities notificationCallbacks,
|
||||
in nsLoadFlags loadAttributes,
|
||||
in nsIURI originalURI);
|
||||
|
||||
/**
|
||||
@ -78,7 +79,8 @@ interface nsIIOService : nsISupports
|
||||
in string aSpec,
|
||||
in nsIURI aBaseURI,
|
||||
in nsILoadGroup aLoadGroup,
|
||||
in nsIEventSinkGetter eventSinkGetter,
|
||||
in nsICapabilities notificationCallbacks,
|
||||
in nsLoadFlags loadAttributes,
|
||||
in nsIURI originalURI);
|
||||
|
||||
/**
|
||||
@ -155,7 +157,9 @@ interface nsIIOService : nsISupports
|
||||
in string contentType,
|
||||
in long contentLength,
|
||||
in nsIInputStream inStr,
|
||||
in nsILoadGroup group,
|
||||
in nsILoadGroup aLoadGroup,
|
||||
in nsICapabilities notificationCallbacks,
|
||||
in nsLoadFlags loadAttributes,
|
||||
in nsIURI originalURI);
|
||||
|
||||
/**
|
||||
|
@ -21,10 +21,10 @@
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIChannel.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface nsIEventSinkGetter;
|
||||
interface nsIChannel;
|
||||
interface nsICapabilities;
|
||||
interface nsILoadGroup;
|
||||
|
||||
[scriptable, uuid(15fd6940-8ea7-11d3-93ad-00104ba0fd40)]
|
||||
@ -55,7 +55,8 @@ interface nsIProtocolHandler : nsISupports
|
||||
nsIChannel newChannel(in string verb,
|
||||
in nsIURI aURI,
|
||||
in nsILoadGroup aLoadGroup,
|
||||
in nsIEventSinkGetter eventSinkGetter,
|
||||
in nsICapabilities notificationCallbacks,
|
||||
in nsLoadFlags loadAttributes,
|
||||
in nsIURI originalURI);
|
||||
};
|
||||
|
||||
|
@ -38,12 +38,10 @@ interface nsISocketTransportService : nsISupports
|
||||
*/
|
||||
nsIChannel createTransport(in string host,
|
||||
in long port,
|
||||
in nsIEventSinkGetter eventSinkGetter,
|
||||
in string printHost);
|
||||
nsIChannel createTransportOfType(in string socketType,
|
||||
in string host,
|
||||
in long port,
|
||||
in nsIEventSinkGetter eventSinkGetter,
|
||||
in string printHost);
|
||||
|
||||
/**
|
||||
|
@ -21,11 +21,13 @@
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIChannel.idl"
|
||||
|
||||
interface nsIURI;
|
||||
interface nsILoadGroup;
|
||||
interface nsIStreamObserver;
|
||||
interface nsIUnicharStreamLoader;
|
||||
interface nsICapabilities;
|
||||
|
||||
[scriptable, uuid(c75e57d0-8e5a-11d3-93ad-00104ba0fd40)]
|
||||
interface nsIUnicharStreamLoaderObserver : nsISupports
|
||||
@ -39,8 +41,10 @@ interface nsIUnicharStreamLoaderObserver : nsISupports
|
||||
interface nsIUnicharStreamLoader : nsISupports
|
||||
{
|
||||
void init(in nsIURI uri,
|
||||
in nsIUnicharStreamLoaderObserver completionObserver,
|
||||
in nsILoadGroup loadGroup,
|
||||
in nsIUnicharStreamLoaderObserver completionObserver);
|
||||
in nsICapabilities notificationCallbacks,
|
||||
in nsLoadFlags loadAttributes);
|
||||
|
||||
/**
|
||||
* Gets the number of bytes read so far.
|
||||
@ -63,8 +67,10 @@ interface nsIUnicharStreamLoader : nsISupports
|
||||
inline nsresult
|
||||
NS_NewUnicharStreamLoader(nsIUnicharStreamLoader* *result,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup* loadGroup,
|
||||
nsIUnicharStreamLoaderObserver* observer)
|
||||
nsIUnicharStreamLoaderObserver* observer,
|
||||
nsILoadGroup* loadGroup = nsnull,
|
||||
nsICapabilities* notificationCallbacks = nsnull,
|
||||
nsLoadFlags loadAttributes = nsIChannel::LOAD_NORMAL)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIUnicharStreamLoader> loader;
|
||||
@ -74,7 +80,7 @@ NS_NewUnicharStreamLoader(nsIUnicharStreamLoader* *result,
|
||||
NS_GET_IID(nsIUnicharStreamLoader),
|
||||
getter_AddRefs(loader));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = loader->Init(uri, loadGroup, observer);
|
||||
rv = loader->Init(uri, observer, loadGroup, notificationCallbacks, loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
*result = loader;
|
||||
NS_ADDREF(*result);
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsIIOService.h"
|
||||
@ -67,7 +67,7 @@ NS_NewURI(nsIURI* *result, const nsString& spec, nsIURI* baseURI = nsnull)
|
||||
|
||||
inline nsresult
|
||||
NS_OpenURI(nsIChannel* *result, nsIURI* uri, nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter = nsnull)
|
||||
nsICapabilities *capabilities = nsnull)
|
||||
{
|
||||
nsresult rv;
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
@ -75,7 +75,7 @@ NS_OpenURI(nsIChannel* *result, nsIURI* uri, nsILoadGroup *aGroup,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIChannel* channel;
|
||||
rv = serv->NewChannelFromURI("load", uri, aGroup, eventSinkGetter,
|
||||
rv = serv->NewChannelFromURI("load", uri, aGroup, capabilities,
|
||||
nsnull, &channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "nsFileTransport.h"
|
||||
#include "nsFileTransportService.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIIOService.h"
|
||||
@ -286,32 +286,31 @@ nsFileTransport::nsFileTransport()
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFileTransport::Init(nsFileSpec& spec, const char* command, nsIEventSinkGetter* getter)
|
||||
nsFileTransport::Init(nsFileSpec& spec, const char* command)
|
||||
{
|
||||
nsresult rv;
|
||||
mSpec = spec;
|
||||
nsCOMPtr<nsIFileSystem> fsObj;
|
||||
rv = nsLocalFileSystem::Create(spec, getter_AddRefs(fsObj));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return Init(fsObj, command, getter);
|
||||
return Init(fsObj, command);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFileTransport::Init(nsIInputStream* fromStream, const char* contentType,
|
||||
PRInt32 contentLength, const char* command, nsIEventSinkGetter* getter)
|
||||
PRInt32 contentLength, const char* command)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIFileSystem> fsObj;
|
||||
rv = nsInputStreamFileSystem::Create(fromStream, contentType, contentLength,
|
||||
getter_AddRefs(fsObj));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return Init(fsObj, command, getter);
|
||||
return Init(fsObj, command);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFileTransport::Init(nsIFileSystem* fsObj,
|
||||
const char* command,
|
||||
nsIEventSinkGetter* getter)
|
||||
const char* command)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mMonitor == nsnull) {
|
||||
@ -320,23 +319,6 @@ nsFileTransport::Init(nsIFileSystem* fsObj,
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mFileObject = fsObj;
|
||||
if (getter) {
|
||||
nsCOMPtr<nsISupports> sink;
|
||||
rv = getter->GetEventSink(command,
|
||||
nsIProgressEventSink::GetIID(), getter_AddRefs(sink));
|
||||
if (NS_FAILED(rv)) return NS_OK; // don't need a progress event sink
|
||||
|
||||
// Now generate a proxied event sink
|
||||
NS_WITH_SERVICE(nsIProxyObjectManager,
|
||||
proxyMgr, kProxyObjectManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = proxyMgr->GetProxyObject(nsnull, // primordial thread - should change?
|
||||
NS_GET_IID(nsIProgressEventSink),
|
||||
sink,
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
getter_AddRefs(mProgress));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -1110,4 +1092,44 @@ nsFileTransport::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileTransport::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileTransport::GetNotificationCallbacks(nsICapabilities* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileTransport::SetNotificationCallbacks(nsICapabilities* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
|
||||
// Get a nsIProgressEventSink so that we can fire status/progress on it-
|
||||
if (mCallbacks) {
|
||||
nsCOMPtr<nsISupports> sink;
|
||||
nsresult rv = mCallbacks->QueryCapability(NS_GET_IID(nsIProgressEventSink),
|
||||
getter_AddRefs(sink));
|
||||
if (NS_FAILED(rv)) return NS_OK; // don't need a progress event sink
|
||||
|
||||
// Now generate a proxied event sink
|
||||
NS_WITH_SERVICE(nsIProxyObjectManager,
|
||||
proxyMgr, kProxyObjectManagerCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = proxyMgr->GetProxyObject(nsnull, // primordial thread - should change?
|
||||
NS_GET_IID(nsIProgressEventSink),
|
||||
sink,
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
getter_AddRefs(mProgress));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -36,8 +36,9 @@
|
||||
#include "nsIBufferInputStream.h"
|
||||
#include "nsIBufferOutputStream.h"
|
||||
#include "nsIFileSystem.h"
|
||||
#include "nsICapabilities.h"
|
||||
|
||||
class nsIEventSinkGetter;
|
||||
class nsICapabilities;
|
||||
|
||||
class nsFileTransport : public nsIChannel,
|
||||
public nsIRunnable,
|
||||
@ -59,16 +60,13 @@ public:
|
||||
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
|
||||
|
||||
nsresult Init(nsFileSpec& spec,
|
||||
const char* command,
|
||||
nsIEventSinkGetter* getter);
|
||||
const char* command);
|
||||
nsresult Init(nsIInputStream* fromStream,
|
||||
const char* contentType,
|
||||
PRInt32 contentLength,
|
||||
const char* command,
|
||||
nsIEventSinkGetter* getter);
|
||||
const char* command);
|
||||
nsresult Init(nsIFileSystem* fsObj,
|
||||
const char* command,
|
||||
nsIEventSinkGetter* getter);
|
||||
const char* command);
|
||||
|
||||
void Process(void);
|
||||
|
||||
@ -92,6 +90,7 @@ public:
|
||||
};
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsICapabilities> mCallbacks;
|
||||
nsCOMPtr<nsIProgressEventSink> mProgress;
|
||||
nsFileSpec mSpec; // eliminate?
|
||||
nsCOMPtr<nsIFileSystem> mFileObject;
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIThreadPool.h"
|
||||
#include "nsISupportsArray.h"
|
||||
@ -84,7 +84,6 @@ nsFileTransportService::Create(nsISupports *aOuter, REFNSIID aIID, void **aResul
|
||||
NS_IMETHODIMP
|
||||
nsFileTransportService::CreateTransport(nsFileSpec& spec,
|
||||
const char* command,
|
||||
nsIEventSinkGetter* getter,
|
||||
nsIChannel** result)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -92,7 +91,7 @@ nsFileTransportService::CreateTransport(nsFileSpec& spec,
|
||||
if (trans == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(trans);
|
||||
rv = trans->Init(spec, command, getter);
|
||||
rv = trans->Init(spec, command);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(trans);
|
||||
return rv;
|
||||
@ -106,7 +105,6 @@ nsFileTransportService::CreateTransportFromStream(nsIInputStream *fromStream,
|
||||
const char* contentType,
|
||||
PRInt32 contentLength,
|
||||
const char *command,
|
||||
nsIEventSinkGetter *getter,
|
||||
nsIChannel** result)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -114,7 +112,7 @@ nsFileTransportService::CreateTransportFromStream(nsIInputStream *fromStream,
|
||||
if (trans == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(trans);
|
||||
rv = trans->Init(fromStream, contentType, contentLength, command, getter);
|
||||
rv = trans->Init(fromStream, contentType, contentLength, command);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(trans);
|
||||
return rv;
|
||||
@ -126,7 +124,6 @@ nsFileTransportService::CreateTransportFromStream(nsIInputStream *fromStream,
|
||||
NS_IMETHODIMP
|
||||
nsFileTransportService::CreateTransportFromFileSystem(nsIFileSystem *fsObj,
|
||||
const char *command,
|
||||
nsIEventSinkGetter *getter,
|
||||
nsIChannel **result)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -134,7 +131,7 @@ nsFileTransportService::CreateTransportFromFileSystem(nsIFileSystem *fsObj,
|
||||
if (trans == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(trans);
|
||||
rv = trans->Init(fsObj, command, getter);
|
||||
rv = trans->Init(fsObj, command);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(trans);
|
||||
return rv;
|
||||
|
@ -228,7 +228,8 @@ nsIOService::NewURI(const char* aSpec, nsIURI* aBaseURI,
|
||||
NS_IMETHODIMP
|
||||
nsIOService::NewChannelFromURI(const char* verb, nsIURI *aURI,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **result)
|
||||
{
|
||||
@ -242,12 +243,8 @@ nsIOService::NewChannelFromURI(const char* verb, nsIURI *aURI,
|
||||
rv = GetProtocolHandler((const char*)scheme, getter_AddRefs(handler));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIChannel* channel;
|
||||
rv = handler->NewChannel(verb, aURI, aGroup, eventSinkGetter,
|
||||
originalURI, &channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = channel;
|
||||
rv = handler->NewChannel(verb, aURI, aGroup, notificationCallbacks,
|
||||
loadAttributes, originalURI, result);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -255,7 +252,8 @@ NS_IMETHODIMP
|
||||
nsIOService::NewChannel(const char* verb, const char *aSpec,
|
||||
nsIURI *aBaseURI,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **result)
|
||||
{
|
||||
@ -264,8 +262,9 @@ nsIOService::NewChannel(const char* verb, const char *aSpec,
|
||||
nsCOMPtr<nsIProtocolHandler> handler;
|
||||
rv = NewURI(aSpec, aBaseURI, getter_AddRefs(uri), getter_AddRefs(handler));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = handler->NewChannel(verb, uri, aGroup, eventSinkGetter,
|
||||
originalURI, result);
|
||||
|
||||
rv = handler->NewChannel(verb, uri, aGroup, notificationCallbacks,
|
||||
loadAttributes, originalURI, result);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -382,17 +381,23 @@ nsIOService::NewChannelFromNativePath(const char *nativePath, nsIFileChannel **r
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIOService::NewInputStreamChannel(nsIURI* uri, const char *contentType,
|
||||
nsIOService::NewInputStreamChannel(nsIURI* uri,
|
||||
const char *contentType,
|
||||
PRInt32 contentLength,
|
||||
nsIInputStream *inStr, nsILoadGroup* group,
|
||||
nsIURI* originalURI, nsIChannel **result)
|
||||
nsIInputStream *inStr,
|
||||
nsILoadGroup *aGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsInputStreamChannel* channel;
|
||||
rv = nsInputStreamChannel::Create(nsnull, NS_GET_IID(nsIChannel),
|
||||
(void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = channel->Init(uri, contentType, contentLength, inStr, group, originalURI);
|
||||
rv = channel->Init(uri, contentType, contentLength, inStr, aGroup,
|
||||
notificationCallbacks, loadAttributes, originalURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
|
@ -60,15 +60,29 @@ nsInputStreamChannel::Create(nsISupports *aOuter, REFNSIID aIID,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::Init(nsIURI* uri, const char* contentType,
|
||||
PRInt32 contentLength, nsIInputStream* in,
|
||||
nsILoadGroup* group, nsIURI* originalURI)
|
||||
nsInputStreamChannel::Init(nsIURI* uri,
|
||||
const char* contentType,
|
||||
PRInt32 contentLength,
|
||||
nsIInputStream* in,
|
||||
nsILoadGroup *aGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI)
|
||||
{
|
||||
nsresult rv;
|
||||
mOriginalURI = originalURI ? originalURI : uri;
|
||||
mURI = uri;
|
||||
mLoadGroup = group;
|
||||
mContentLength = contentLength;
|
||||
|
||||
rv = SetLoadAttributes(loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetLoadGroup(aGroup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetNotificationCallbacks(notificationCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (contentType) {
|
||||
mContentType = nsCRT::strdup(contentType);
|
||||
const char *constContentType = mContentType;
|
||||
@ -156,8 +170,7 @@ nsInputStreamChannel::AsyncOpen(nsIStreamObserver *observer, nsISupports* ctxt)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = fts->CreateTransportFromStream(mInputStream, mContentType, mContentLength,
|
||||
"load", nsnull,
|
||||
getter_AddRefs(mFileTransport));
|
||||
"load", getter_AddRefs(mFileTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mFileTransport->AsyncOpen(observer, ctxt);
|
||||
@ -213,8 +226,7 @@ nsInputStreamChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = fts->CreateTransportFromStream(mInputStream, mContentType, mContentLength,
|
||||
"load", nsnull,
|
||||
getter_AddRefs(mFileTransport));
|
||||
"load", getter_AddRefs(mFileTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
@ -262,7 +274,7 @@ nsInputStreamChannel::GetContentLength(PRInt32 *aContentLength)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
nsInputStreamChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup.get();
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
@ -270,7 +282,14 @@ nsInputStreamChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::GetOwner(nsISupports * *aOwner)
|
||||
nsInputStreamChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::GetOwner(nsISupports* *aOwner)
|
||||
{
|
||||
*aOwner = mOwner.get();
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
@ -278,12 +297,27 @@ nsInputStreamChannel::GetOwner(nsISupports * *aOwner)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::SetOwner(nsISupports * aOwner)
|
||||
nsInputStreamChannel::SetOwner(nsISupports* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::GetNotificationCallbacks(nsICapabilities* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::SetNotificationCallbacks(nsICapabilities* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIStreamListener methods:
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsInputStreamChannel : public nsIInputStreamChannel,
|
||||
@ -49,6 +50,7 @@ public:
|
||||
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsICapabilities> mCallbacks;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
char* mContentType;
|
||||
|
@ -34,7 +34,7 @@
|
||||
#include "nsISocketProvider.h"
|
||||
#include "nsISocketProviderService.h"
|
||||
#include "nsStdURL.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsProxyObjectManager.h"
|
||||
#include "nsXPIDLString.h"
|
||||
|
||||
@ -228,7 +228,6 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
|
||||
const char* aHost,
|
||||
PRInt32 aPort,
|
||||
const char* aSocketType,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
const char* aPrintHost)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
@ -262,31 +261,6 @@ nsresult nsSocketTransport::Init(nsSocketTransportService* aService,
|
||||
}
|
||||
}
|
||||
|
||||
// Get a nsIProgressEventSink so that we can fire status/progress on it-
|
||||
if (NS_SUCCEEDED(rv) && eventSinkGetter)
|
||||
{
|
||||
nsIProgressEventSink* sink = nsnull;
|
||||
(void) eventSinkGetter->GetEventSink("load", // Hmmm...
|
||||
nsIProgressEventSink::GetIID(),
|
||||
(nsISupports**)&sink);
|
||||
if (sink)
|
||||
{
|
||||
// Now generate a proxied event sink-
|
||||
NS_WITH_SERVICE(nsIProxyObjectManager,
|
||||
proxyMgr, kProxyObjectManagerCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = proxyMgr->GetProxyObject(
|
||||
nsnull, // primordial thread - should change?
|
||||
NS_GET_IID(nsIProgressEventSink),
|
||||
sink,
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
getter_AddRefs(mEventSink));
|
||||
}
|
||||
NS_RELEASE(sink);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Create the lock used for synchronizing access to the transport instance.
|
||||
//
|
||||
@ -1822,46 +1796,87 @@ nsSocketTransport::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::GetOwner(nsISupports * *aOwner)
|
||||
{
|
||||
*aOwner = mOwner.get();
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
*aOwner = mOwner.get();
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::SetOwner(nsISupports * aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::GetNotificationCallbacks(nsICapabilities* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::SetNotificationCallbacks(nsICapabilities* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
|
||||
// Get a nsIProgressEventSink so that we can fire status/progress on it-
|
||||
if (mCallbacks) {
|
||||
nsCOMPtr<nsIProgressEventSink> sink;
|
||||
nsresult rv = mCallbacks->QueryCapability(NS_GET_IID(nsIProgressEventSink),
|
||||
getter_AddRefs(sink));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Now generate a proxied event sink-
|
||||
NS_WITH_SERVICE(nsIProxyObjectManager,
|
||||
proxyMgr, kProxyObjectManagerCID, &rv);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = proxyMgr->GetProxyObject(nsnull, // primordial thread - should change?
|
||||
NS_GET_IID(nsIProgressEventSink),
|
||||
sink,
|
||||
PROXY_ASYNC | PROXY_ALWAYS,
|
||||
getter_AddRefs(mEventSink));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsSocketTransport::fireStatus(PRUint32 aCode)
|
||||
{
|
||||
// need to optimize this - TODO
|
||||
nsXPIDLString tempmesg;
|
||||
nsresult rv = GetSocketErrorString(aCode, getter_Copies(tempmesg));
|
||||
// need to optimize this - TODO
|
||||
nsXPIDLString tempmesg;
|
||||
nsresult rv = GetSocketErrorString(aCode, getter_Copies(tempmesg));
|
||||
|
||||
nsAutoString mesg(tempmesg);
|
||||
if (mPrintHost)
|
||||
mesg.Append(mPrintHost);
|
||||
else
|
||||
mesg.Append(mHostName);
|
||||
nsAutoString mesg(tempmesg);
|
||||
if (mPrintHost)
|
||||
mesg.Append(mPrintHost);
|
||||
else
|
||||
mesg.Append(mHostName);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#ifndef BUG_16273_FIXED //TODO
|
||||
return mEventSink ? mEventSink->OnStatus(this,
|
||||
mReadContext,
|
||||
mesg.ToNewUnicode()) // this gets freed elsewhere.
|
||||
: NS_ERROR_FAILURE;
|
||||
return mEventSink ? mEventSink->OnStatus(this,
|
||||
mReadContext,
|
||||
mesg.ToNewUnicode()) // this gets freed elsewhere.
|
||||
: NS_ERROR_FAILURE;
|
||||
#else
|
||||
return mEventSink ? mEventSink->OnStatus(this,
|
||||
mReadContext,
|
||||
mesg.mUStr) // this gets freed elsewhere.
|
||||
: NS_ERROR_FAILURE;
|
||||
return mEventSink ? mEventSink->OnStatus(this,
|
||||
mReadContext,
|
||||
mesg.mUStr) // this gets freed elsewhere.
|
||||
: NS_ERROR_FAILURE;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "nsIDNSListener.h"
|
||||
#include "nsIPipe.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsICapabilities.h"
|
||||
|
||||
#define NS_SOCKET_TRANSPORT_SEGMENT_SIZE (2*1024)
|
||||
#define NS_SOCKET_TRANSPORT_BUFFER_SIZE (8*1024)
|
||||
@ -107,7 +108,7 @@ enum nsSocketReadWriteInfo {
|
||||
|
||||
// Forward declarations...
|
||||
class nsSocketTransportService;
|
||||
class nsIEventSinkGetter;
|
||||
class nsICapabilities;
|
||||
|
||||
class nsSocketTransport : public nsIChannel,
|
||||
public nsIDNSListener,
|
||||
@ -117,11 +118,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIREQUEST
|
||||
NS_DECL_NSICHANNEL
|
||||
|
||||
// nsIPipeObserver methods:
|
||||
NS_DECL_NSIPIPEOBSERVER
|
||||
|
||||
// nsIDNSListener methods:
|
||||
NS_DECL_NSIDNSLISTENER
|
||||
|
||||
// nsSocketTransport methods:
|
||||
@ -132,7 +129,6 @@ public:
|
||||
const char* aHost,
|
||||
PRInt32 aPort,
|
||||
const char* aSocketType,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
const char* aPrintHost); // This host is used for status mesg
|
||||
|
||||
nsresult Process(PRInt16 aSelectFlags);
|
||||
@ -197,6 +193,7 @@ protected:
|
||||
PRBool mCloseConnectionOnceDone;
|
||||
nsSocketState mCurrentState;
|
||||
nsCOMPtr<nsIRequest> mDNSRequest;
|
||||
nsCOMPtr<nsICapabilities> mCallbacks;
|
||||
nsCOMPtr<nsIProgressEventSink> mEventSink;
|
||||
char* mHostName;
|
||||
PRIntervalTime mLastActiveTime;
|
||||
|
@ -525,19 +525,16 @@ nsSocketTransportService::Run(void)
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransportService::CreateTransport(const char* aHost,
|
||||
PRInt32 aPort,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
const char* aPrintHost,
|
||||
nsIChannel** aResult)
|
||||
{
|
||||
return CreateTransportOfType(nsnull, aHost, aPort,
|
||||
eventSinkGetter, aPrintHost, aResult);
|
||||
return CreateTransportOfType(nsnull, aHost, aPort, aPrintHost, aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransportService::CreateTransportOfType(const char* aSocketType,
|
||||
const char* aHost,
|
||||
PRInt32 aPort,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
const char* aPrintHost,
|
||||
nsIChannel** aResult)
|
||||
{
|
||||
@ -553,8 +550,7 @@ nsSocketTransportService::CreateTransportOfType(const char* aSocketType,
|
||||
// Create and initialize a new connection object...
|
||||
NS_NEWXPCOM(transport, nsSocketTransport);
|
||||
if (transport) {
|
||||
rv = transport->Init(this, aHost, aPort,
|
||||
aSocketType, eventSinkGetter, aPrintHost);
|
||||
rv = transport->Init(this, aHost, aPort, aSocketType, aPrintHost);
|
||||
if (NS_FAILED(rv)) {
|
||||
delete transport;
|
||||
transport = nsnull;
|
||||
|
@ -40,8 +40,11 @@ nsUnicharStreamLoader::nsUnicharStreamLoader()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUnicharStreamLoader::Init(nsIURI* aURL, nsILoadGroup* aLoadGroup,
|
||||
nsIUnicharStreamLoaderObserver* observer)
|
||||
nsUnicharStreamLoader::Init(nsIURI* aURL,
|
||||
nsIUnicharStreamLoaderObserver* observer,
|
||||
nsILoadGroup* aGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
mObserver = observer;
|
||||
@ -55,8 +58,8 @@ nsUnicharStreamLoader::Init(nsIURI* aURL, nsILoadGroup* aLoadGroup,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIChannel* channel;
|
||||
rv = serv->NewChannelFromURI("load", aURL, aLoadGroup, nsnull,
|
||||
nsnull, &channel);
|
||||
rv = serv->NewChannelFromURI("load", aURL, aGroup, notificationCallbacks,
|
||||
loadAttributes, nsnull, &channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->AsyncRead(0, -1, nsnull, this);
|
||||
|
41
netwerk/cache/tests/xptest/disktest.cpp
vendored
41
netwerk/cache/tests/xptest/disktest.cpp
vendored
@ -59,7 +59,7 @@
|
||||
#include "nsIURL.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIDNSService.h"
|
||||
|
||||
#include "nsISimpleEnumerator.h"
|
||||
@ -573,35 +573,32 @@ InputTestConsumer::OnStopRequest(nsIChannel* channel,
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsEventSinkGetter : public nsIEventSinkGetter {
|
||||
class nsNotificationCallbacks : public nsICapabilities {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsEventSinkGetter() {
|
||||
nsNotificationCallbacks() {
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
NS_IMETHOD GetEventSink(const char* verb, const nsIID& eventSinkIID,
|
||||
nsISupports* *result) {
|
||||
NS_IMETHOD QueryCapability(const nsIID& eventSinkIID, nsISupports* *result) {
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (nsCRT::strcmp(verb, "load") == 0) { // makeshift verb for now
|
||||
if (eventSinkIID.Equals(nsCOMTypeInfo<nsIHTTPEventSink>::GetIID())) {
|
||||
TestHTTPEventSink *sink;
|
||||
if (eventSinkIID.Equals(NS_GET_IID(nsIHTTPEventSink))) {
|
||||
TestHTTPEventSink *sink;
|
||||
|
||||
sink = new TestHTTPEventSink();
|
||||
if (sink == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(sink);
|
||||
rv = sink->QueryInterface(eventSinkIID, (void**)result);
|
||||
NS_RELEASE(sink);
|
||||
}
|
||||
sink = new TestHTTPEventSink();
|
||||
if (sink == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(sink);
|
||||
rv = sink->QueryInterface(eventSinkIID, (void**)result);
|
||||
NS_RELEASE(sink);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsEventSinkGetter, nsCOMTypeInfo<nsIEventSinkGetter>::GetIID());
|
||||
NS_IMPL_ISUPPORTS1(nsNotificationCallbacks, nsICapabilities)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -620,23 +617,23 @@ nsresult StartLoadingURL(const char* aUrlString)
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIChannel> pChannel;
|
||||
nsEventSinkGetter* pMySink;
|
||||
nsNotificationCallbacks* callbacks;
|
||||
|
||||
pMySink = new nsEventSinkGetter();
|
||||
NS_IF_ADDREF(pMySink);
|
||||
if (!pMySink) {
|
||||
callbacks = new nsNotificationCallbacks();
|
||||
if (!callbacks) {
|
||||
NS_ERROR("Failed to create a new consumer!");
|
||||
return NS_ERROR_OUT_OF_MEMORY;;
|
||||
}
|
||||
NS_ADDREF(callbacks);
|
||||
|
||||
// Async reading thru the calls of the event sink interface
|
||||
rv = pService->NewChannelFromURI("load", pURL, nsnull, pMySink,
|
||||
rv = pService->NewChannelFromURI("load", pURL, nsnull, callbacks,
|
||||
getter_AddRefs(pChannel));
|
||||
NS_RELEASE(callbacks);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("ERROR: NewChannelFromURI failed for %s\n", aUrlString);
|
||||
return rv;
|
||||
}
|
||||
NS_RELEASE(pMySink);
|
||||
|
||||
/*
|
||||
You may optionally add/set other headers on this
|
||||
|
41
netwerk/cache/tests/xptest/memtest.cpp
vendored
41
netwerk/cache/tests/xptest/memtest.cpp
vendored
@ -46,7 +46,7 @@
|
||||
#include "nsIURL.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIDNSService.h"
|
||||
|
||||
#include "nsISimpleEnumerator.h"
|
||||
@ -557,35 +557,32 @@ InputTestConsumer::OnStopRequest(nsIChannel* channel,
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsEventSinkGetter : public nsIEventSinkGetter {
|
||||
class nsNotificationCallbacks : public nsICapabilities {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsEventSinkGetter() {
|
||||
nsNotificationCallbacks() {
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
NS_IMETHOD GetEventSink(const char* verb, const nsIID& eventSinkIID,
|
||||
nsISupports* *result) {
|
||||
NS_IMETHOD QueryCapability(const nsIID& eventSinkIID, nsISupports* *result) {
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (nsCRT::strcmp(verb, "load") == 0) { // makeshift verb for now
|
||||
if (eventSinkIID.Equals(nsCOMTypeInfo<nsIHTTPEventSink>::GetIID())) {
|
||||
TestHTTPEventSink *sink;
|
||||
if (eventSinkIID.Equals(NS_GET_IID(nsIHTTPEventSink))) {
|
||||
TestHTTPEventSink *sink;
|
||||
|
||||
sink = new TestHTTPEventSink();
|
||||
if (sink == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(sink);
|
||||
rv = sink->QueryInterface(eventSinkIID, (void**)result);
|
||||
NS_RELEASE(sink);
|
||||
}
|
||||
sink = new TestHTTPEventSink();
|
||||
if (sink == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(sink);
|
||||
rv = sink->QueryInterface(eventSinkIID, (void**)result);
|
||||
NS_RELEASE(sink);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsEventSinkGetter, nsCOMTypeInfo<nsIEventSinkGetter>::GetIID());
|
||||
NS_IMPL_ISUPPORTS1(nsNotificationCallbacks, nsICapabilities)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -604,23 +601,23 @@ nsresult StartLoadingURL(const char* aUrlString)
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIChannel> pChannel;
|
||||
nsEventSinkGetter* pMySink;
|
||||
nsNotificationCallbacks* callbacks;
|
||||
|
||||
pMySink = new nsEventSinkGetter();
|
||||
NS_IF_ADDREF(pMySink);
|
||||
if (!pMySink) {
|
||||
callbacks = new nsNotificationCallbacks();
|
||||
if (!callbacks) {
|
||||
NS_ERROR("Failed to create a new consumer!");
|
||||
return NS_ERROR_OUT_OF_MEMORY;;
|
||||
}
|
||||
NS_ADDREF(callbacks);
|
||||
|
||||
// Async reading thru the calls of the event sink interface
|
||||
rv = pService->NewChannelFromURI("load", pURL, nsnull, pMySink,
|
||||
rv = pService->NewChannelFromURI("load", pURL, nsnull, callbacks,
|
||||
getter_AddRefs(pChannel));
|
||||
NS_RELEASE(callbacks);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("ERROR: NewChannelFromURI failed for %s\n", aUrlString);
|
||||
return rv;
|
||||
}
|
||||
NS_RELEASE(pMySink);
|
||||
|
||||
/*
|
||||
You may optionally add/set other headers on this
|
||||
|
@ -21,11 +21,11 @@
|
||||
*/
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIChannel.idl"
|
||||
|
||||
interface nsIChannel;
|
||||
interface nsIURI;
|
||||
interface nsILoadGroup;
|
||||
interface nsIEventSinkGetter;
|
||||
interface nsICapabilities;
|
||||
interface nsIEventQueue;
|
||||
|
||||
[scriptable, uuid(692303c0-2f83-11d3-8cd0-0060b0fc14a3)]
|
||||
@ -33,8 +33,9 @@ interface nsIAboutModule : nsISupports
|
||||
{
|
||||
nsIChannel NewChannel(in string verb,
|
||||
in nsIURI aURI,
|
||||
in nsILoadGroup aGroup,
|
||||
in nsIEventSinkGetter eventSinkGetter,
|
||||
in nsILoadGroup aLoadGroup,
|
||||
in nsICapabilities notificationCallbacks,
|
||||
in nsLoadFlags loadAttributes,
|
||||
in nsIURI originalURI);
|
||||
};
|
||||
|
||||
|
@ -34,8 +34,9 @@ static const char kBlankPage[] = "";
|
||||
NS_IMETHODIMP
|
||||
nsAboutBlank::NewChannel(const char *verb,
|
||||
nsIURI *aURI,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **result)
|
||||
{
|
||||
@ -55,7 +56,8 @@ nsAboutBlank::NewChannel(const char *verb,
|
||||
|
||||
rv = serv->NewInputStreamChannel(aURI, "text/html",
|
||||
nsCRT::strlen(kBlankPage),
|
||||
in, aGroup, originalURI, &channel);
|
||||
in, aLoadGroup, notificationCallbacks,
|
||||
loadAttributes, originalURI, &channel);
|
||||
NS_RELEASE(in);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -44,8 +44,9 @@ NS_IMPL_ISUPPORTS(nsAboutBloat, NS_GET_IID(nsIAboutModule));
|
||||
NS_IMETHODIMP
|
||||
nsAboutBloat::NewChannel(const char *verb,
|
||||
nsIURI *aURI,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **result)
|
||||
{
|
||||
@ -141,7 +142,8 @@ nsAboutBloat::NewChannel(const char *verb,
|
||||
|
||||
nsIChannel* channel;
|
||||
rv = serv->NewInputStreamChannel(aURI, "text/plain",
|
||||
size, inStr, aGroup, originalURI, &channel);
|
||||
size, inStr, aLoadGroup, notificationCallbacks,
|
||||
loadAttributes, originalURI, &channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = channel;
|
||||
|
@ -120,8 +120,9 @@ nsAboutProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsAboutProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel* *result)
|
||||
{
|
||||
@ -147,8 +148,8 @@ nsAboutProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
nsCRT::free(progIDStr);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// The standard return case:
|
||||
return aboutMod->NewChannel(verb, uri, aGroup, eventSinkGetter,
|
||||
originalURI, result);
|
||||
return aboutMod->NewChannel(verb, uri, aLoadGroup, notificationCallbacks,
|
||||
loadAttributes, originalURI, result);
|
||||
}
|
||||
|
||||
// mumble...
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "nsIIOService.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "plbase64.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIPipe.h"
|
||||
#include "nsIBufferInputStream.h"
|
||||
#include "nsIBufferOutputStream.h"
|
||||
@ -45,47 +45,40 @@ nsDataChannel::nsDataChannel() {
|
||||
}
|
||||
|
||||
nsDataChannel::~nsDataChannel() {
|
||||
NS_IF_RELEASE(mDataStream);
|
||||
NS_RELEASE(mUrl);
|
||||
NS_IF_RELEASE(mLoadGroup);
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsDataChannel);
|
||||
NS_IMPL_RELEASE(nsDataChannel);
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDataChannel::QueryInterface(const nsIID& aIID, void** aInstancePtr) {
|
||||
NS_ASSERTION(aInstancePtr, "no instance pointer");
|
||||
if (aIID.Equals(NS_GET_IID(nsIDataChannel)) ||
|
||||
aIID.Equals(NS_GET_IID(nsIChannel)) ||
|
||||
aIID.Equals(NS_GET_IID(nsISupports)) ) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIDataChannel*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
NS_IMPL_ISUPPORTS3(nsDataChannel,
|
||||
nsIDataChannel,
|
||||
nsIChannel,
|
||||
nsIRequest)
|
||||
|
||||
nsresult
|
||||
nsDataChannel::Init(const char* verb, nsIURI* uri, nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* getter, nsIURI* originalURI)
|
||||
nsDataChannel::Init(const char* verb,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI)
|
||||
{
|
||||
// we don't care about event sinks in data
|
||||
nsresult rv;
|
||||
|
||||
mDataStream = nsnull;
|
||||
rv = SetLoadAttributes(loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetLoadGroup(aLoadGroup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetNotificationCallbacks(notificationCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Data urls contain all the data within the url string itself.
|
||||
mOriginalURI = originalURI ? originalURI : uri;
|
||||
mUrl = uri;
|
||||
NS_ADDREF(mUrl);
|
||||
|
||||
rv = ParseData();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mLoadGroup = aGroup;
|
||||
NS_IF_ADDREF(mLoadGroup);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -200,7 +193,7 @@ nsDataChannel::ParseData() {
|
||||
// Initialize the content length of the data...
|
||||
mContentLength = dataToWrite->dataLen;
|
||||
|
||||
rv = bufInStream->QueryInterface(NS_GET_IID(nsIInputStream), (void**)&mDataStream);
|
||||
rv = bufInStream->QueryInterface(NS_GET_IID(nsIInputStream), getter_AddRefs(mDataStream));
|
||||
NS_RELEASE(bufInStream);
|
||||
NS_RELEASE(bufOutStream);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -266,8 +259,8 @@ nsDataChannel::GetOriginalURI(nsIURI * *aURI)
|
||||
NS_IMETHODIMP
|
||||
nsDataChannel::GetURI(nsIURI * *aURI)
|
||||
{
|
||||
NS_ADDREF(mUrl);
|
||||
*aURI = mUrl;
|
||||
NS_IF_ADDREF(*aURI);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -381,7 +374,7 @@ nsDataChannel::GetContentLength(PRInt32 *aContentLength)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDataChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
nsDataChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
@ -389,7 +382,14 @@ nsDataChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDataChannel::GetOwner(nsISupports * *aOwner)
|
||||
nsDataChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDataChannel::GetOwner(nsISupports* *aOwner)
|
||||
{
|
||||
*aOwner = mOwner.get();
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
@ -397,9 +397,24 @@ nsDataChannel::GetOwner(nsISupports * *aOwner)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDataChannel::SetOwner(nsISupports * aOwner)
|
||||
nsDataChannel::SetOwner(nsISupports* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDataChannel::GetNotificationCallbacks(nsICapabilities* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDataChannel::SetNotificationCallbacks(nsICapabilities* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -32,12 +32,10 @@
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsICapabilities.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsIEventSinkGetter;
|
||||
class nsIProgressEventSink;
|
||||
|
||||
class nsDataChannel : public nsIDataChannel {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -53,19 +51,24 @@ public:
|
||||
static NS_METHOD
|
||||
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
|
||||
|
||||
nsresult Init(const char* verb, nsIURI* uri, nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* getter, nsIURI* originalURI);
|
||||
nsresult Init(const char* verb,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI);
|
||||
nsresult ParseData();
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsIURI *mUrl;
|
||||
nsIInputStream *mDataStream;
|
||||
PRUint32 mLoadAttributes;
|
||||
nsILoadGroup *mLoadGroup;
|
||||
nsCString mContentType;
|
||||
PRInt32 mContentLength;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
nsCOMPtr<nsICapabilities> mCallbacks;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mUrl;
|
||||
nsCOMPtr<nsIInputStream> mDataStream;
|
||||
PRUint32 mLoadAttributes;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
nsCString mContentType;
|
||||
PRInt32 mContentLength;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
|
||||
static NS_DEFINE_CID(kStandardURLCID, NS_STANDARDURL_CID);
|
||||
@ -97,8 +97,9 @@ nsDataHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDataHandler::NewChannel(const char* verb, nsIURI* url,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel* *result)
|
||||
{
|
||||
@ -108,7 +109,8 @@ nsDataHandler::NewChannel(const char* verb, nsIURI* url,
|
||||
rv = nsDataChannel::Create(nsnull, NS_GET_IID(nsIDataChannel), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->Init(verb, url, aGroup, eventSinkGetter, originalURI);
|
||||
rv = channel->Init(verb, url, aLoadGroup, notificationCallbacks,
|
||||
loadAttributes, originalURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
|
@ -22,7 +22,7 @@
|
||||
|
||||
#include "nsFileChannel.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIURI.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIStreamListener.h"
|
||||
@ -56,19 +56,22 @@ static NS_DEFINE_CID(kFileTransportServiceCID, NS_FILETRANSPORTSERVICE_CID);
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsFileChannel::nsFileChannel()
|
||||
: mLoadAttributes(LOAD_NORMAL),
|
||||
mRealListener(nsnull)
|
||||
: mLoadAttributes(LOAD_NORMAL)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsFileChannel::Init(nsIFileProtocolHandler* handler, const char* command, nsIURI* uri,
|
||||
nsILoadGroup *aGroup, nsIEventSinkGetter* getter, nsIURI* originalURI)
|
||||
nsFileChannel::Init(nsIFileProtocolHandler* handler,
|
||||
const char* command,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
mGetter = getter;
|
||||
mHandler = handler;
|
||||
mOriginalURI = originalURI ? originalURI : uri;
|
||||
mURI = uri;
|
||||
@ -76,11 +79,14 @@ nsFileChannel::Init(nsIFileProtocolHandler* handler, const char* command, nsIURI
|
||||
if (mCommand == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
mLoadGroup = aGroup;
|
||||
if (mLoadGroup) {
|
||||
rv = mLoadGroup->GetDefaultLoadAttributes(&mLoadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
rv = SetLoadAttributes(loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetLoadGroup(aLoadGroup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetNotificationCallbacks(notificationCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// if we support the nsIURL interface then use it to get just
|
||||
// the file path with no other garbage!
|
||||
@ -128,29 +134,12 @@ nsFileChannel::~nsFileChannel()
|
||||
if (mCommand) nsCRT::free(mCommand);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::QueryInterface(const nsIID& aIID, void** aInstancePtr)
|
||||
{
|
||||
NS_ASSERTION(aInstancePtr, "no instance pointer");
|
||||
if (aIID.Equals(NS_GET_IID(nsIFileChannel)) ||
|
||||
aIID.Equals(NS_GET_IID(nsIChannel)) ||
|
||||
aIID.Equals(NS_GET_IID(nsIRequest)) ||
|
||||
aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIFileChannel*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIStreamListener)) ||
|
||||
aIID.Equals(NS_GET_IID(nsIStreamObserver))) {
|
||||
*aInstancePtr = NS_STATIC_CAST(nsIStreamListener*, this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsFileChannel);
|
||||
NS_IMPL_RELEASE(nsFileChannel);
|
||||
NS_IMPL_ISUPPORTS5(nsFileChannel,
|
||||
nsIFileChannel,
|
||||
nsIChannel,
|
||||
nsIRequest,
|
||||
nsIStreamListener,
|
||||
nsIStreamObserver)
|
||||
|
||||
NS_METHOD
|
||||
nsFileChannel::Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult)
|
||||
@ -233,8 +222,10 @@ nsFileChannel::OpenInputStream(PRUint32 startPosition, PRInt32 readCount,
|
||||
NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = fts->CreateTransport(mSpec, mCommand, mGetter,
|
||||
getter_AddRefs(mFileTransport));
|
||||
rv = fts->CreateTransport(mSpec, mCommand, getter_AddRefs(mFileTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mFileTransport->SetNotificationCallbacks(mCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mFileTransport->OpenInputStream(startPosition, readCount, result);
|
||||
@ -251,8 +242,10 @@ nsFileChannel::OpenOutputStream(PRUint32 startPosition, nsIOutputStream **result
|
||||
NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = fts->CreateTransport(mSpec, mCommand, mGetter,
|
||||
getter_AddRefs(mFileTransport));
|
||||
rv = fts->CreateTransport(mSpec, mCommand, getter_AddRefs(mFileTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mFileTransport->SetNotificationCallbacks(mCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mFileTransport->OpenOutputStream(startPosition, result);
|
||||
@ -299,8 +292,10 @@ nsFileChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = fts->CreateTransport(mSpec, mCommand, mGetter,
|
||||
getter_AddRefs(mFileTransport));
|
||||
rv = fts->CreateTransport(mSpec, mCommand, getter_AddRefs(mFileTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mFileTransport->SetNotificationCallbacks(mCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mFileTransport->AsyncRead(startPosition, readCount, ctxt, tempListener);
|
||||
@ -320,8 +315,10 @@ nsFileChannel::AsyncWrite(nsIInputStream *fromStream,
|
||||
NS_WITH_SERVICE(nsIFileTransportService, fts, kFileTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = fts->CreateTransport(mSpec, mCommand, mGetter,
|
||||
getter_AddRefs(mFileTransport));
|
||||
rv = fts->CreateTransport(mSpec, mCommand, getter_AddRefs(mFileTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mFileTransport->SetNotificationCallbacks(mCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mFileTransport->AsyncWrite(fromStream, startPosition, writeCount, ctxt, observer);
|
||||
@ -385,7 +382,7 @@ nsFileChannel::GetContentLength(PRInt32 *aContentLength)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
nsFileChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
@ -393,7 +390,18 @@ nsFileChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::GetOwner(nsISupports * *aOwner)
|
||||
nsFileChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup;
|
||||
if (mLoadGroup) {
|
||||
nsresult rv = mLoadGroup->GetDefaultLoadAttributes(&mLoadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::GetOwner(nsISupports* *aOwner)
|
||||
{
|
||||
*aOwner = mOwner.get();
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
@ -401,12 +409,27 @@ nsFileChannel::GetOwner(nsISupports * *aOwner)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::SetOwner(nsISupports * aOwner)
|
||||
nsFileChannel::SetOwner(nsISupports* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::GetNotificationCallbacks(nsICapabilities* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::SetNotificationCallbacks(nsICapabilities* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIStreamListener methods:
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -746,10 +769,10 @@ nsFileChannel::CreateFileChannelFromFileSpec(nsFileSpec& spec, nsIFileChannel **
|
||||
urlStr,
|
||||
nsnull,
|
||||
mLoadGroup,
|
||||
mGetter,
|
||||
mCallbacks,
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull,
|
||||
&channel);
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// this cast is safe because nsFileURL::GetURLString aways
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include "nsIFileChannel.h"
|
||||
#include "nsIFileProtocolHandler.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIChannel.h"
|
||||
@ -63,8 +63,13 @@ public:
|
||||
static NS_METHOD
|
||||
Create(nsISupports* aOuter, const nsIID& aIID, void* *aResult);
|
||||
|
||||
nsresult Init(nsIFileProtocolHandler* handler, const char* verb, nsIURI* uri,
|
||||
nsILoadGroup *aGroup, nsIEventSinkGetter* getter, nsIURI* originalURI);
|
||||
nsresult Init(nsIFileProtocolHandler* handler,
|
||||
const char* command,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI);
|
||||
|
||||
protected:
|
||||
nsresult CreateFileChannelFromFileSpec(nsFileSpec& spec, nsIFileChannel** result);
|
||||
@ -73,7 +78,7 @@ protected:
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
nsCOMPtr<nsIFileProtocolHandler> mHandler;
|
||||
nsCOMPtr<nsIEventSinkGetter> mGetter; // XXX it seems wrong keeping this -- used by GetParent
|
||||
nsCOMPtr<nsICapabilities> mCallbacks;
|
||||
char* mCommand;
|
||||
nsFileSpec mSpec;
|
||||
nsCOMPtr<nsIChannel> mFileTransport;
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIThread.h"
|
||||
#include "nsIThreadPool.h"
|
||||
@ -127,9 +127,10 @@ nsFileProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileProtocolHandler::NewChannel(const char* verb, nsIURI* url,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
nsFileProtocolHandler::NewChannel(const char* command, nsIURI* url,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel* *result)
|
||||
{
|
||||
@ -139,7 +140,8 @@ nsFileProtocolHandler::NewChannel(const char* verb, nsIURI* url,
|
||||
rv = nsFileChannel::Create(nsnull, NS_GET_IID(nsIFileChannel), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->Init(this, verb, url, aGroup, eventSinkGetter, originalURI);
|
||||
rv = channel->Init(this, command, url, aLoadGroup, notificationCallbacks,
|
||||
loadAttributes, originalURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
@ -163,9 +165,10 @@ nsFileProtocolHandler::NewChannelFromNativePath(const char* nativePath,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = NewChannel("load", // XXX what should this be?
|
||||
uri,
|
||||
nsnull, // XXX bogus load group
|
||||
nsnull, // XXX bogus getter
|
||||
uri,
|
||||
nsnull, // loadGroup
|
||||
nsnull, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI same as uri
|
||||
(nsIChannel**)result);
|
||||
NS_RELEASE(uri);
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "nsFtpConnectionThread.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIMIMEService.h"
|
||||
#include "nsProxyObjectManager.h"
|
||||
|
||||
@ -88,9 +88,14 @@ NS_IMPL_QUERY_INTERFACE4(nsFTPChannel, nsIChannel, nsIFTPChannel, nsIStreamListe
|
||||
//NS_IMPL_ISUPPORTS4(nsFTPChannel, nsIChannel, nsIFTPChannel, nsIStreamListener, nsIStreamObserver);
|
||||
|
||||
nsresult
|
||||
nsFTPChannel::Init(const char* verb, nsIURI* uri, nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* getter, nsIURI* originalURI,
|
||||
nsIProtocolHandler* aHandler, nsIThreadPool* aPool)
|
||||
nsFTPChannel::Init(const char* verb,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIProtocolHandler* aHandler,
|
||||
nsIThreadPool* aPool)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -99,6 +104,15 @@ nsFTPChannel::Init(const char* verb, nsIURI* uri, nsILoadGroup *aGroup,
|
||||
|
||||
mHandler = aHandler;
|
||||
|
||||
rv = SetLoadAttributes(loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetLoadGroup(aLoadGroup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetNotificationCallbacks(notificationCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
NS_ASSERTION(aPool, "FTP channel needs a thread pool to play in");
|
||||
if (!aPool) return NS_ERROR_NULL_POINTER;
|
||||
mPool = aPool;
|
||||
@ -106,22 +120,6 @@ nsFTPChannel::Init(const char* verb, nsIURI* uri, nsILoadGroup *aGroup,
|
||||
mOriginalURI = originalURI ? originalURI : uri;
|
||||
mURL = uri;
|
||||
|
||||
if (aGroup) {
|
||||
mLoadGroup = aGroup;
|
||||
rv = mLoadGroup->AddChannel(this, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
mEventSinkGetter = getter;
|
||||
|
||||
if (mEventSinkGetter) {
|
||||
rv = mEventSinkGetter->GetEventSink(verb, NS_GET_IID(nsIProgressEventSink),
|
||||
getter_AddRefs(mEventSink));
|
||||
if (NS_FAILED(rv)) {
|
||||
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("nsFTPChannel::Init() (couldn't find event sink)\n"));
|
||||
}
|
||||
}
|
||||
|
||||
NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueService, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@ -270,7 +268,7 @@ nsFTPChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
rv = protocolInterpreter->Init(mURL, /* url to load */
|
||||
mEventQueue, /* event queue for this thread */
|
||||
mHandler,
|
||||
this, ctxt, mEventSinkGetter);
|
||||
this, ctxt, mCallbacks);
|
||||
mHandler = 0;
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(protocolInterpreter);
|
||||
@ -367,7 +365,7 @@ nsFTPChannel::GetContentLength(PRInt32 *aContentLength)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
nsFTPChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
@ -375,7 +373,18 @@ nsFTPChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::GetOwner(nsISupports * *aOwner)
|
||||
nsFTPChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup;
|
||||
if (mLoadGroup) {
|
||||
nsresult rv = mLoadGroup->AddChannel(this, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::GetOwner(nsISupports* *aOwner)
|
||||
{
|
||||
*aOwner = mOwner.get();
|
||||
NS_IF_ADDREF(*aOwner);
|
||||
@ -383,12 +392,35 @@ nsFTPChannel::GetOwner(nsISupports * *aOwner)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::SetOwner(nsISupports * aOwner)
|
||||
nsFTPChannel::SetOwner(nsISupports* aOwner)
|
||||
{
|
||||
mOwner = aOwner;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::GetNotificationCallbacks(nsICapabilities* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::SetNotificationCallbacks(nsICapabilities* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
|
||||
if (mCallbacks) {
|
||||
nsresult rv = mCallbacks->QueryCapability(NS_GET_IID(nsIProgressEventSink),
|
||||
getter_AddRefs(mEventSink));
|
||||
if (NS_FAILED(rv)) {
|
||||
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("nsFTPChannel::Init() (couldn't find event sink)\n"));
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIFTPChannel methods:
|
||||
NS_IMETHODIMP
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include "nsHashtable.h"
|
||||
#include "nsIProtocolHandler.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIThreadPool.h"
|
||||
#include "nsIRequest.h"
|
||||
|
||||
@ -60,16 +60,21 @@ public:
|
||||
// initializes the channel. creates the FTP connection thread
|
||||
// and returns it so the protocol handler can cache it and
|
||||
// join() it on shutdown.
|
||||
nsresult Init(const char* verb, nsIURI* uri, nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* getter, nsIURI* originalURI,
|
||||
nsIProtocolHandler* aHandler, nsIThreadPool* aPool);
|
||||
nsresult Init(const char* verb,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIProtocolHandler* aHandler,
|
||||
nsIThreadPool* aPool);
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mURL;
|
||||
nsCOMPtr<nsIEventQueue> mEventQueue;
|
||||
nsCOMPtr<nsIProgressEventSink> mEventSink;
|
||||
nsCOMPtr<nsIEventSinkGetter> mEventSinkGetter;
|
||||
nsCOMPtr<nsICapabilities> mCallbacks;
|
||||
|
||||
PRBool mConnected;
|
||||
nsCOMPtr<nsIStreamListener> mListener;
|
||||
|
@ -1481,10 +1481,7 @@ nsFtpConnectionThread::R_pasv() {
|
||||
nsAllocator::Free(response);
|
||||
|
||||
// now we know where to connect our data channel
|
||||
rv = mSTS->CreateTransport(host.GetBuffer(), port,
|
||||
nsnull, /* don't push the event sink getter through for the data channel */
|
||||
nsnull,
|
||||
getter_AddRefs(mDPipe)); // the data channel
|
||||
rv = mSTS->CreateTransport(host.GetBuffer(), port, nsnull, getter_AddRefs(mDPipe)); // the data channel
|
||||
if (NS_FAILED(rv)) return FTP_ERROR;
|
||||
|
||||
if (mAction == GET) {
|
||||
@ -1671,7 +1668,10 @@ nsFtpConnectionThread::Run() {
|
||||
port = FTP_DEFAULT_PORT;
|
||||
|
||||
// build our own
|
||||
rv = mSTS->CreateTransport(host, port, mEventSinkGetter, host, getter_AddRefs(mCPipe)); // the command channel
|
||||
rv = mSTS->CreateTransport(host, port, host, getter_AddRefs(mCPipe)); // the command channel
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = mCPipe->SetNotificationCallbacks(mCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// get the output stream so we can write to the server
|
||||
@ -1835,13 +1835,13 @@ nsFtpConnectionThread::Init(nsIURI* aUrl,
|
||||
nsIProtocolHandler* aHandler,
|
||||
nsIChannel* aChannel,
|
||||
nsISupports* aContext,
|
||||
nsIEventSinkGetter* aEventSinkGetter) {
|
||||
nsICapabilities* notificationCallbacks) {
|
||||
nsresult rv;
|
||||
|
||||
NS_ASSERTION(aChannel, "FTP: thread needs a channel");
|
||||
|
||||
mOutsideEventQueue = aEventQ;
|
||||
mEventSinkGetter = aEventSinkGetter;
|
||||
mCallbacks = notificationCallbacks;
|
||||
|
||||
NS_WITH_SERVICE(nsIProxyObjectManager, pIProxyObjectManager, kProxyObjectManagerCID, &rv);
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "nsIRunnable.h"
|
||||
#include "nsIRequest.h"
|
||||
#include "nsISocketTransportService.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsIInputStream.h"
|
||||
@ -138,7 +138,7 @@ public:
|
||||
nsIProtocolHandler* aHandler,
|
||||
nsIChannel* channel,
|
||||
nsISupports* ctxt,
|
||||
nsIEventSinkGetter* aEventSink);
|
||||
nsICapabilities* notificationCallbacks);
|
||||
nsresult Process();
|
||||
|
||||
// user level setup
|
||||
@ -255,8 +255,8 @@ private:
|
||||
|
||||
nsString2 mContentType; // the content type of the data we're dealing w/.
|
||||
nsXPIDLCString mURLSpec;
|
||||
nsCOMPtr<nsIEventSinkGetter> mEventSinkGetter;
|
||||
nsCOMPtr<nsIFTPChannel> mFTPChannel;
|
||||
nsCOMPtr<nsICapabilities> mCallbacks;
|
||||
nsCOMPtr<nsIFTPChannel> mFTPChannel;
|
||||
|
||||
nsCOMPtr<nsIBufferInputStream> mBufInStream;
|
||||
nsCOMPtr<nsIBufferOutputStream> mBufOutStream;
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "nsIURL.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsConnectionCacheObj.h"
|
||||
|
||||
@ -176,8 +176,9 @@ nsFtpProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFtpProtocolHandler::NewChannel(const char* verb, nsIURI* url,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel* *result)
|
||||
{
|
||||
@ -187,7 +188,8 @@ nsFtpProtocolHandler::NewChannel(const char* verb, nsIURI* url,
|
||||
rv = nsFTPChannel::Create(nsnull, NS_GET_IID(nsIFTPChannel), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->Init(verb, url, aGroup, eventSinkGetter, originalURI, this, mPool);
|
||||
rv = channel->Init(verb, url, aLoadGroup, notificationCallbacks, loadAttributes,
|
||||
originalURI, this, mPool);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
PR_LOG(gFTPLog, PR_LOG_DEBUG, ("nsFtpProtocolHandler::NewChannel() FAILED\n"));
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include "nsIHTTPProtocolHandler.h"
|
||||
#include "nsHTTPRequest.h"
|
||||
#include "nsHTTPResponse.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIStreamListener.h"
|
||||
@ -55,6 +55,11 @@ static NS_DEFINE_CID(kProxyObjectManagerCID, NS_PROXYEVENT_MANAGER_CID);
|
||||
#include "nsINetPrompt.h"
|
||||
#include "nsProxiedService.h"
|
||||
|
||||
static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID);
|
||||
static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_CID(kNetModuleMgrCID, NS_NETMODULEMGR_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
#if defined(PR_LOGGING)
|
||||
extern PRLogModuleInfo* gHTTPLog;
|
||||
#endif /* PR_LOGGING */
|
||||
@ -64,7 +69,6 @@ static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
nsHTTPChannel::nsHTTPChannel(nsIURI* i_URL,
|
||||
const char *i_Verb,
|
||||
nsIEventSinkGetter* i_EventSinkGetter,
|
||||
nsIURI* originalURI,
|
||||
nsHTTPHandler* i_Handler):
|
||||
mOriginalURI(dont_QueryInterface(originalURI ? originalURI : i_URL)),
|
||||
@ -72,7 +76,6 @@ nsHTTPChannel::nsHTTPChannel(nsIURI* i_URL,
|
||||
mConnected(PR_FALSE),
|
||||
mHandler(dont_QueryInterface(i_Handler)),
|
||||
mState(HS_IDLE),
|
||||
mEventSinkGetter(dont_QueryInterface(i_EventSinkGetter)),
|
||||
mResponse(nsnull),
|
||||
mResponseDataListener(nsnull),
|
||||
mLoadAttributes(LOAD_NORMAL),
|
||||
@ -90,17 +93,6 @@ nsHTTPChannel::nsHTTPChannel(nsIURI* i_URL,
|
||||
mContentLength = -1;
|
||||
|
||||
mVerb = i_Verb;
|
||||
|
||||
// Verify that the event sink is http
|
||||
if (i_EventSinkGetter) {
|
||||
nsIHTTPEventSink *sink = nsnull;
|
||||
|
||||
(void) i_EventSinkGetter->GetEventSink(i_Verb, NS_GET_IID(nsIHTTPEventSink),
|
||||
(nsISupports**)&sink);
|
||||
mEventSink = sink;
|
||||
NS_IF_RELEASE(sink);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
nsHTTPChannel::~nsHTTPChannel()
|
||||
@ -346,6 +338,43 @@ nsHTTPChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTTPChannel::SetLoadGroup(nsILoadGroup *aGroup)
|
||||
{
|
||||
//TODO think if we need to make a copy of the URL and keep it here
|
||||
//since it might get deleted off the creators thread. And the
|
||||
//stream listener could be elsewhere...
|
||||
|
||||
/*
|
||||
Set up a request object - later set to a clone of a default
|
||||
request from the handler. TODO
|
||||
*/
|
||||
nsresult rv;
|
||||
|
||||
//
|
||||
// Initialize the load group and copy any default load attributes...
|
||||
//
|
||||
mLoadGroup = aGroup;
|
||||
if (mLoadGroup) {
|
||||
mLoadGroup->GetDefaultLoadAttributes(&mLoadAttributes);
|
||||
}
|
||||
|
||||
mRequest = new nsHTTPRequest(mURI);
|
||||
if (mRequest == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(mRequest);
|
||||
mRequest->SetConnection(this);
|
||||
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRUnichar * ua = nsnull;
|
||||
rv = service->GetUserAgent(&ua);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCString uaString(ua);
|
||||
nsCRT::free(ua);
|
||||
mRequest->SetHeader(nsHTTPAtoms::User_Agent, uaString.GetBuffer());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTTPChannel::GetOwner(nsISupports * *aOwner)
|
||||
{
|
||||
@ -361,6 +390,30 @@ nsHTTPChannel::SetOwner(nsISupports * aOwner)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTTPChannel::GetNotificationCallbacks(nsICapabilities* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTTPChannel::SetNotificationCallbacks(nsICapabilities* aNotificationCallbacks)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
|
||||
// Verify that the event sink is http
|
||||
if (mCallbacks) {
|
||||
// we don't care if this fails -- we don't need an nsIHTTPEventSink
|
||||
// to proceed
|
||||
(void)mCallbacks->QueryCapability(NS_GET_IID(nsIHTTPEventSink),
|
||||
getter_AddRefs(mEventSink));
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIHTTPChannel methods:
|
||||
|
||||
@ -537,52 +590,9 @@ nsHTTPChannel::GetAuthTriedWithPrehost(PRBool* oTried)
|
||||
}
|
||||
|
||||
|
||||
static NS_DEFINE_IID(kProxyObjectManagerIID, NS_IPROXYEVENT_MANAGER_IID);
|
||||
static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID);
|
||||
static NS_DEFINE_CID(kNetModuleMgrCID, NS_NETMODULEMGR_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsHTTPChannel methods:
|
||||
|
||||
nsresult
|
||||
nsHTTPChannel::Init(nsILoadGroup *aGroup)
|
||||
{
|
||||
//TODO think if we need to make a copy of the URL and keep it here
|
||||
//since it might get deleted off the creators thread. And the
|
||||
//stream listener could be elsewhere...
|
||||
|
||||
/*
|
||||
Set up a request object - later set to a clone of a default
|
||||
request from the handler. TODO
|
||||
*/
|
||||
nsresult rv;
|
||||
|
||||
//
|
||||
// Initialize the load group and copy any default load attributes...
|
||||
//
|
||||
mLoadGroup = aGroup;
|
||||
if (mLoadGroup) {
|
||||
mLoadGroup->GetDefaultLoadAttributes(&mLoadAttributes);
|
||||
}
|
||||
|
||||
mRequest = new nsHTTPRequest(mURI);
|
||||
if (mRequest == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(mRequest);
|
||||
mRequest->SetConnection(this);
|
||||
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
PRUnichar * ua = nsnull;
|
||||
rv = service->GetUserAgent(&ua);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCString uaString(ua);
|
||||
nsCRT::free(ua);
|
||||
mRequest->SetHeader(nsHTTPAtoms::User_Agent, uaString.GetBuffer());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTTPChannel::Open(void)
|
||||
{
|
||||
@ -617,9 +627,8 @@ nsHTTPChannel::Open(void)
|
||||
}
|
||||
|
||||
rv = mHandler->RequestTransport(mURI,
|
||||
this,
|
||||
mEventSinkGetter,
|
||||
getter_AddRefs(transport));
|
||||
this,
|
||||
getter_AddRefs(transport));
|
||||
|
||||
if (NS_ERROR_BUSY == rv) {
|
||||
mState = HS_WAITING_FOR_OPEN;
|
||||
@ -630,6 +639,14 @@ nsHTTPChannel::Open(void)
|
||||
(void) ResponseCompleted(nsnull, rv, nsnull);
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = transport->SetNotificationCallbacks(mCallbacks);
|
||||
if (NS_FAILED(rv)) {
|
||||
// Unable to create a transport... End the request...
|
||||
(void) ResponseCompleted(nsnull, rv, nsnull);
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Check for any modules that want to set headers before we
|
||||
// send out a request.
|
||||
NS_WITH_SERVICE(nsINetModuleMgr, pNetModuleMgr, kNetModuleMgrCID, &rv);
|
||||
@ -733,13 +750,10 @@ nsresult nsHTTPChannel::Redirect(const char *aNewLocation,
|
||||
this, newURLSpec));
|
||||
#endif /* PR_LOGGING */
|
||||
|
||||
rv = serv->NewChannelFromURI(mVerb.GetBuffer(), newURI, mLoadGroup, mEventSinkGetter,
|
||||
mOriginalURI, getter_AddRefs(channel));
|
||||
rv = serv->NewChannelFromURI(mVerb.GetBuffer(), newURI, mLoadGroup, mCallbacks,
|
||||
mLoadAttributes, mOriginalURI, getter_AddRefs(channel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Copy the load attributes into the new channel...
|
||||
channel->SetLoadAttributes(mLoadAttributes);
|
||||
|
||||
// Start the redirect...
|
||||
rv = channel->AsyncRead(0, -1, mResponseContext, mResponseDataListener);
|
||||
|
||||
@ -986,15 +1000,11 @@ nsHTTPChannel::Authenticate(const char *iChallenge, nsIChannel **oChannel)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// This smells like a clone function... maybe there is a benefit in doing that, think. TODO.
|
||||
rv = serv->NewChannelFromURI(mVerb.GetBuffer(), mURI,
|
||||
mLoadGroup, mEventSinkGetter, mOriginalURI,
|
||||
getter_AddRefs(channel));
|
||||
rv = serv->NewChannelFromURI(mVerb.GetBuffer(), mURI, mLoadGroup, mCallbacks,
|
||||
mLoadAttributes, mOriginalURI, getter_AddRefs(channel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// Copy the load attributes into the new channel...
|
||||
channel->SetLoadAttributes(mLoadAttributes);
|
||||
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(channel));
|
||||
nsCOMPtr<nsIHTTPChannel> httpChannel = do_QueryInterface(channel);
|
||||
NS_ASSERTION(httpChannel, "Something terrible happened..!");
|
||||
if (!httpChannel)
|
||||
return rv;
|
||||
@ -1018,3 +1028,4 @@ nsHTTPChannel::SetUsingProxy(PRBool i_UsingProxy)
|
||||
mUsingProxy = i_UsingProxy;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "nsIURI.h"
|
||||
#include "nsHTTPHandler.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsCOMPtr.h"
|
||||
@ -55,7 +55,6 @@ public:
|
||||
// Constructors and Destructor
|
||||
nsHTTPChannel(nsIURI* i_URL,
|
||||
const char* verb,
|
||||
nsIEventSinkGetter* i_EventSinkGetter,
|
||||
nsIURI* originalURI,
|
||||
nsHTTPHandler* i_Handler);
|
||||
|
||||
@ -91,12 +90,12 @@ protected:
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsCOMPtr<nsIURI> mURI;
|
||||
PRBool mConnected;
|
||||
nsCOMPtr<nsHTTPHandler> mHandler;
|
||||
nsHTTPHandler* mHandler;
|
||||
HTTPState mState;
|
||||
|
||||
nsCString mVerb;
|
||||
nsCString mVerb;
|
||||
nsCOMPtr<nsIHTTPEventSink> mEventSink;
|
||||
nsCOMPtr<nsIEventSinkGetter> mEventSinkGetter;
|
||||
nsCOMPtr<nsICapabilities> mCallbacks;
|
||||
|
||||
nsHTTPRequest* mRequest;
|
||||
nsHTTPResponse* mResponse;
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "nsIChannel.h"
|
||||
#include "nsISocketTransportService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIFileStream.h"
|
||||
#include "nsIStringStream.h"
|
||||
@ -185,12 +185,11 @@ nsHTTPHandler::~nsHTTPHandler()
|
||||
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(nsHTTPHandler);
|
||||
|
||||
NS_METHOD
|
||||
nsHTTPHandler::NewChannel(const char* verb, nsIURI* i_URL,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **o_Instance)
|
||||
{
|
||||
@ -235,16 +234,21 @@ nsHTTPHandler::NewChannel(const char* verb, nsIURI* i_URL,
|
||||
// Create one
|
||||
pChannel = new nsHTTPChannel(i_URL,
|
||||
verb,
|
||||
eventSinkGetter,
|
||||
originalURI,
|
||||
this);
|
||||
if (pChannel) {
|
||||
NS_ADDREF(pChannel);
|
||||
pChannel->Init(aGroup);
|
||||
rv = pChannel->SetLoadAttributes(loadAttributes);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = pChannel->SetLoadGroup(aLoadGroup);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = pChannel->SetNotificationCallbacks(notificationCallbacks);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
rv = pChannel->QueryInterface(NS_GET_IID(nsIChannel),
|
||||
(void**)o_Instance);
|
||||
(void**)o_Instance);
|
||||
// add this instance to the active list of connections
|
||||
// TODO!
|
||||
done:
|
||||
NS_RELEASE(pChannel);
|
||||
} else {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -257,38 +261,10 @@ nsHTTPHandler::NewChannel(const char* verb, nsIURI* i_URL,
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsHTTPHandler::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
{
|
||||
if (NULL == aInstancePtr)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*aInstancePtr = NULL;
|
||||
|
||||
if (aIID.Equals(NS_GET_IID(nsIProtocolHandler))) {
|
||||
*aInstancePtr = (void*) ((nsIProtocolHandler*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIHTTPProtocolHandler))) {
|
||||
*aInstancePtr = (void*) ((nsIHTTPProtocolHandler*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIProxy))) {
|
||||
*aInstancePtr = (void*) ((nsIProxy*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsISupports))) {
|
||||
*aInstancePtr = (void*) ((nsISupports*)(nsIProtocolHandler*)this);
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
NS_IMPL_RELEASE(nsHTTPHandler);
|
||||
NS_IMPL_ISUPPORTS3(nsHTTPHandler,
|
||||
nsIHTTPProtocolHandler,
|
||||
nsIProtocolHandler,
|
||||
nsIProxy)
|
||||
|
||||
NS_METHOD
|
||||
nsHTTPHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
@ -379,7 +355,6 @@ nsHTTPHandler::NewPostDataStream(PRBool isFile,
|
||||
|
||||
nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri,
|
||||
nsHTTPChannel* i_Channel,
|
||||
nsIEventSinkGetter* i_ESG,
|
||||
nsIChannel** o_pTrans)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -473,11 +448,11 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri,
|
||||
// Create a new one...
|
||||
if (!mProxy || !mUseProxy)
|
||||
{
|
||||
rv = CreateTransport(host, port, i_ESG, host, &trans);
|
||||
rv = CreateTransport(host, port, host, &trans);
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = CreateTransport(mProxy, mProxyPort, i_ESG, host, &trans);
|
||||
rv = CreateTransport(mProxy, mProxyPort, host, &trans);
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
@ -500,7 +475,6 @@ nsresult nsHTTPHandler::RequestTransport(nsIURI* i_Uri,
|
||||
|
||||
nsresult nsHTTPHandler::CreateTransport(const char* host,
|
||||
PRInt32 port,
|
||||
nsIEventSinkGetter* i_ESG,
|
||||
const char* aPrintHost,
|
||||
nsIChannel** o_pTrans)
|
||||
{
|
||||
@ -510,13 +484,13 @@ nsresult nsHTTPHandler::CreateTransport(const char* host,
|
||||
kSocketTransportServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return sts->CreateTransport(host, port, i_ESG, aPrintHost, o_pTrans);
|
||||
return sts->CreateTransport(host, port, aPrintHost, o_pTrans);
|
||||
}
|
||||
|
||||
nsHTTPHandler * nsHTTPHandler::GetInstance(void)
|
||||
{
|
||||
static nsHTTPHandler* pHandler = new nsHTTPHandler();
|
||||
NS_ADDREF(pHandler);
|
||||
NS_IF_ADDREF(pHandler);
|
||||
return pHandler;
|
||||
};
|
||||
|
||||
|
@ -43,14 +43,14 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsCRT.h"
|
||||
//#include "nsIProxy.h"
|
||||
#include "nsIProxy.h"
|
||||
|
||||
//Forward decl.
|
||||
class nsHashtable;
|
||||
class nsIChannel;
|
||||
class nsHTTPChannel;
|
||||
|
||||
class nsHTTPHandler : public nsIHTTPProtocolHandler//, public nsIProxy
|
||||
class nsHTTPHandler : public nsIHTTPProtocolHandler, public nsIProxy
|
||||
{
|
||||
|
||||
public:
|
||||
@ -82,8 +82,9 @@ public:
|
||||
};
|
||||
|
||||
NS_IMETHOD NewChannel(const char* verb, nsIURI* url,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **_retval);
|
||||
|
||||
@ -130,7 +131,6 @@ public:
|
||||
*/
|
||||
virtual nsresult RequestTransport(nsIURI *i_Uri,
|
||||
nsHTTPChannel* i_Channel,
|
||||
nsIEventSinkGetter* i_ESG,
|
||||
nsIChannel** o_pTrans);
|
||||
|
||||
/**
|
||||
@ -139,7 +139,6 @@ public:
|
||||
**/
|
||||
|
||||
virtual nsresult CreateTransport(const char* host, PRInt32 port,
|
||||
nsIEventSinkGetter* i_ESG,
|
||||
const char* aPrintHost,
|
||||
nsIChannel** o_pTrans);
|
||||
|
||||
|
@ -122,12 +122,13 @@ nsJARChannel::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsJARChannel::Init(nsIJARProtocolHandler* aHandler,
|
||||
const char* command,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* getter,
|
||||
nsIURI* originalURI)
|
||||
nsJARChannel::Init(nsIJARProtocolHandler* aHandler,
|
||||
const char* command,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI)
|
||||
{
|
||||
nsresult rv;
|
||||
mURI = do_QueryInterface(uri, &rv);
|
||||
@ -135,9 +136,17 @@ nsJARChannel::Init(nsIJARProtocolHandler* aHandler,
|
||||
mCommand = nsCRT::strdup(command);
|
||||
if (mCommand == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
mLoadGroup = aGroup;
|
||||
mEventSinkGetter = getter;
|
||||
mOriginalURI = originalURI;
|
||||
|
||||
rv = SetLoadAttributes(loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetLoadGroup(aLoadGroup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = SetNotificationCallbacks(notificationCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -220,7 +229,7 @@ nsJARChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
|
||||
nsCOMPtr<nsIChannel> jarBaseChannel;
|
||||
rv = NS_OpenURI(getter_AddRefs(jarBaseChannel),
|
||||
mJARBaseURI, mLoadGroup, mEventSinkGetter);
|
||||
mJARBaseURI, mLoadGroup, mCallbacks, mLoadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIFileChannel> jarBaseFile = do_QueryInterface(jarBaseChannel, &rv);
|
||||
@ -249,10 +258,13 @@ nsJARChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
// use a file transport to serve as a data pump for the download (done
|
||||
// on some other thread)
|
||||
nsCOMPtr<nsIChannel> jarCacheTransport;
|
||||
rv = fts->CreateTransport(jarCacheFile, mCommand, mEventSinkGetter,
|
||||
rv = fts->CreateTransport(jarCacheFile, mCommand,
|
||||
getter_AddRefs(jarCacheTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = jarCacheTransport->SetNotificationCallbacks(mCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIStreamObserver> downloadObserver = new nsJARDownloadObserver(this);
|
||||
if (downloadObserver == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
@ -299,10 +311,13 @@ nsJARChannel::ExtractJARElement(nsIFileChannel* jarBaseFile)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIChannel> jarTransport;
|
||||
rv = fts->CreateTransportFromFileSystem(this, mCommand, mEventSinkGetter,
|
||||
rv = fts->CreateTransportFromFileSystem(this, mCommand,
|
||||
getter_AddRefs(jarTransport));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = jarTransport->SetNotificationCallbacks(mCallbacks);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = jarTransport->AsyncRead(mStartPosition, mReadCount, nsnull, this);
|
||||
return rv;
|
||||
}
|
||||
@ -400,6 +415,13 @@ nsJARChannel::GetLoadGroup(nsILoadGroup* *aLoadGroup)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetLoadGroup(nsILoadGroup* aLoadGroup)
|
||||
{
|
||||
mLoadGroup = aLoadGroup;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetOwner(nsISupports* *aOwner)
|
||||
{
|
||||
@ -415,6 +437,21 @@ nsJARChannel::SetOwner(nsISupports* aOwner)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::GetNotificationCallbacks(nsICapabilities* *aNotificationCallbacks)
|
||||
{
|
||||
*aNotificationCallbacks = mCallbacks.get();
|
||||
NS_IF_ADDREF(*aNotificationCallbacks);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARChannel::SetNotificationCallbacks(nsICapabilities* aNotificationCallbacks)
|
||||
{
|
||||
mCallbacks = aNotificationCallbacks;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIStreamObserver methods:
|
||||
|
||||
|
@ -65,8 +65,13 @@ public:
|
||||
static NS_METHOD
|
||||
Create(nsISupports* aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
nsresult Init(nsIJARProtocolHandler* aHandler, const char* verb, nsIURI* uri,
|
||||
nsILoadGroup* aGroup, nsIEventSinkGetter* getter, nsIURI* originalURI);
|
||||
nsresult Init(nsIJARProtocolHandler* aHandler,
|
||||
const char* command,
|
||||
nsIURI* uri,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI);
|
||||
|
||||
nsresult ExtractJARElement(nsIFileChannel* jarFileChannel);
|
||||
nsresult GetCacheFile(nsFileSpec& cacheFile);
|
||||
@ -75,7 +80,7 @@ protected:
|
||||
char* mCommand;
|
||||
nsCOMPtr<nsIJARURI> mURI;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
nsCOMPtr<nsIEventSinkGetter> mEventSinkGetter;
|
||||
nsCOMPtr<nsICapabilities> mCallbacks;
|
||||
nsCOMPtr<nsIURI> mOriginalURI;
|
||||
nsLoadFlags mLoadAttributes;
|
||||
nsCOMPtr<nsISupports> mOwner;
|
||||
|
@ -118,10 +118,11 @@ nsJARProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsJARProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
nsILoadGroup* loadGroup,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel* *result)
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -129,7 +130,8 @@ nsJARProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
rv = nsJARChannel::Create(nsnull, NS_GET_IID(nsIJARChannel), (void**)&channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->Init(this, verb, uri, loadGroup, eventSinkGetter, originalURI);
|
||||
rv = channel->Init(this, verb, uri, aLoadGroup, notificationCallbacks,
|
||||
loadAttributes, originalURI);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
|
@ -153,10 +153,12 @@ nsKeywordProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsKeywordProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
nsIURI* aOriginalURI,
|
||||
nsIChannel* *result) {
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* aOriginalURI,
|
||||
nsIChannel* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_ASSERTION(mEnabled && (mKeywordURL.Length() > 0), "someone's trying to use the keyword handler even though it hasn't been init'd");
|
||||
@ -172,7 +174,8 @@ nsKeywordProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// now we have an HTTP url, give the user an HTTP channel
|
||||
rv = serv->NewChannel(verb, httpSpec, nsnull, aGroup, eventSinkGetter, aOriginalURI, result);
|
||||
rv = serv->NewChannel(verb, httpSpec, nsnull, aLoadGroup, notificationCallbacks,
|
||||
loadAttributes, aOriginalURI, result);
|
||||
nsAllocator::Free(httpSpec);
|
||||
return rv;
|
||||
|
||||
|
@ -283,8 +283,9 @@ MangleResourceIntoFileURL(const char* aResourceFileName)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsResourceProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel* *result)
|
||||
{
|
||||
@ -308,8 +309,8 @@ nsResourceProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsIChannel* channel;
|
||||
rv = serv->NewChannel(verb, filePath, uri, aGroup, eventSinkGetter,
|
||||
originalURI, &channel);
|
||||
rv = serv->NewChannel(verb, filePath, uri, aLoadGroup, notificationCallbacks,
|
||||
loadAttributes, originalURI, &channel);
|
||||
nsCRT::free(filePath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -128,7 +128,12 @@ nsFTPDirListingConv::AsyncConvertData(const PRUnichar *aFromType, const PRUnicha
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = serv->NewInputStreamChannel(uri, "application/http-index-format", -1, // XXX fix contentLength
|
||||
nsnull, nsnull, nsnull, &mPartChannel);
|
||||
nsnull, // inStr
|
||||
nsnull, // loadGroup
|
||||
nsnull, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI
|
||||
&mPartChannel);
|
||||
NS_RELEASE(uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
@ -259,7 +259,12 @@ nsMultiMixedConv::OnDataAvailable(nsIChannel *channel, nsISupports *context,
|
||||
if (mContentType.Length() < 1)
|
||||
mContentType = "text/html"; // default to text/html, that's all we'll ever see anyway
|
||||
rv = serv->NewInputStreamChannel(partURI, mContentType.GetBuffer(), mContentLength,
|
||||
nsnull, nsnull, nsnull, getter_AddRefs(mPartChannel));
|
||||
nsnull, // inStr
|
||||
nsnull, // loadGroup
|
||||
nsnull, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(mPartChannel));
|
||||
if (NS_FAILED(rv)) {
|
||||
nsAllocator::Free(buffer);
|
||||
return rv;
|
||||
|
@ -277,7 +277,12 @@ main(int argc, char* argv[])
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = serv->NewInputStreamChannel(dummyURI, "multipart/x-mixed-replacE;boundary=thisrandomstring",
|
||||
-1, // XXX fix contentLength
|
||||
nsnull, nsnull, nsnull, getter_AddRefs(dummyChannel));
|
||||
nsnull, // inStr
|
||||
nsnull, // loadGroup
|
||||
nsnull, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(dummyChannel));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
|
||||
|
@ -369,7 +369,7 @@ ParallelReadTest(char* dirName, nsIFileTransportService* fts)
|
||||
NS_ASSERTION(listener, "QI failed");
|
||||
|
||||
nsIChannel* trans;
|
||||
rv = fts->CreateTransport(spec, "load", nsnull, &trans);
|
||||
rv = fts->CreateTransport(spec, "load", &trans);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "create failed");
|
||||
|
||||
rv = trans->AsyncRead(0, -1, nsnull, listener);
|
||||
|
@ -126,7 +126,7 @@ TestAsyncRead(const char* fileName, PRUint32 offset, PRInt32 length)
|
||||
|
||||
nsFileSpec fs(fileName);
|
||||
nsIChannel* fileTrans;
|
||||
rv = fts->CreateTransport(fs, "load", nsnull, &fileTrans);
|
||||
rv = fts->CreateTransport(fs, "load", &fileTrans);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
MyListener* listener = new MyListener();
|
||||
@ -167,7 +167,7 @@ TestAsyncWrite(const char* fileName, PRUint32 offset, PRInt32 length)
|
||||
outFile += ".out";
|
||||
nsFileSpec fs(outFile);
|
||||
nsIChannel* fileTrans;
|
||||
rv = fts->CreateTransport(fs, "load", nsnull, &fileTrans);
|
||||
rv = fts->CreateTransport(fs, "load", &fileTrans);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
MyListener* listener = new MyListener();
|
||||
@ -243,7 +243,7 @@ TestAsyncOpen(const char* fileName, PRUint32 offset, PRInt32 length)
|
||||
|
||||
nsFileSpec fs(fileName);
|
||||
nsIChannel* fileTrans;
|
||||
rv = fts->CreateTransport(fs, "load", nsnull, &fileTrans);
|
||||
rv = fts->CreateTransport(fs, "load", &fileTrans);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
MyListener* listener = new MyListener(1);
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include "nsIURL.h"
|
||||
#include "nsIHTTPChannel.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIDNSService.h"
|
||||
|
||||
#include "nsISimpleEnumerator.h"
|
||||
@ -463,35 +463,32 @@ InputTestConsumer::OnStopRequest(nsIChannel* channel,
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsEventSinkGetter : public nsIEventSinkGetter {
|
||||
class nsNotificationCallbacks : public nsICapabilities {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsEventSinkGetter() {
|
||||
nsNotificationCallbacks() {
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
NS_IMETHOD GetEventSink(const char* verb, const nsIID& eventSinkIID,
|
||||
nsISupports* *result) {
|
||||
NS_IMETHOD QueryCapability(const nsIID& eventSinkIID, void* *result) {
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (nsCRT::strcmp(verb, "load") == 0) { // makeshift verb for now
|
||||
if (eventSinkIID.Equals(NS_GET_IID(nsIHTTPEventSink))) {
|
||||
TestHTTPEventSink *sink;
|
||||
if (eventSinkIID.Equals(NS_GET_IID(nsIHTTPEventSink))) {
|
||||
TestHTTPEventSink *sink;
|
||||
|
||||
sink = new TestHTTPEventSink();
|
||||
if (sink == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(sink);
|
||||
rv = sink->QueryInterface(eventSinkIID, (void**)result);
|
||||
NS_RELEASE(sink);
|
||||
}
|
||||
sink = new TestHTTPEventSink();
|
||||
if (sink == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ADDREF(sink);
|
||||
rv = sink->QueryInterface(eventSinkIID, result);
|
||||
NS_RELEASE(sink);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsEventSinkGetter, NS_GET_IID(nsIEventSinkGetter));
|
||||
NS_IMPL_ISUPPORTS1(nsNotificationCallbacks, nsICapabilities)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@ -510,23 +507,26 @@ nsresult StartLoadingURL(const char* aUrlString)
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIChannel> pChannel;
|
||||
nsEventSinkGetter* pMySink;
|
||||
|
||||
pMySink = new nsEventSinkGetter();
|
||||
NS_IF_ADDREF(pMySink);
|
||||
if (!pMySink) {
|
||||
nsNotificationCallbacks* callbacks = new nsNotificationCallbacks();
|
||||
if (!callbacks) {
|
||||
NS_ERROR("Failed to create a new consumer!");
|
||||
return NS_ERROR_OUT_OF_MEMORY;;
|
||||
}
|
||||
NS_ADDREF(callbacks);
|
||||
|
||||
// Async reading thru the calls of the event sink interface
|
||||
rv = pService->NewChannelFromURI("load", pURL, nsnull, pMySink,
|
||||
nsnull, getter_AddRefs(pChannel));
|
||||
rv = pService->NewChannelFromURI("load", pURL,
|
||||
nsnull, // loadGroup
|
||||
callbacks, // notificationCallbacks
|
||||
nsIChannel::LOAD_NORMAL,
|
||||
nsnull, // originalURI
|
||||
getter_AddRefs(pChannel));
|
||||
NS_RELEASE(callbacks);
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("ERROR: NewChannelFromURI failed for %s\n", aUrlString);
|
||||
return rv;
|
||||
}
|
||||
NS_RELEASE(pMySink);
|
||||
|
||||
/*
|
||||
You may optionally add/set other headers on this
|
||||
|
@ -242,7 +242,7 @@ main(int argc, char* argv[])
|
||||
|
||||
// Create the socket transport...
|
||||
nsIChannel* transport;
|
||||
rv = sts->CreateTransport(hostName, port, nsnull, hostName, &transport);
|
||||
rv = sts->CreateTransport(hostName, port, hostName, &transport);
|
||||
|
||||
// This stuff is used to test the output stream
|
||||
#if 0
|
||||
|
@ -161,7 +161,7 @@ main(int argc, char* argv[])
|
||||
|
||||
nsIChannel* transport;
|
||||
|
||||
rv = sts->CreateTransport(hostName, port, nsnull, hostName, &transport);
|
||||
rv = sts->CreateTransport(hostName, port, hostName, &transport);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
transport->AsyncRead(0, -1, nsnull, new InputTestConsumer);
|
||||
|
||||
|
@ -281,7 +281,7 @@ TestConnection::TestConnection(const char* aHostName, PRInt32 aPort,
|
||||
// Create a socket transport...
|
||||
NS_WITH_SERVICE(nsISocketTransportService, sts, kSocketTransportServiceCID, &rv);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = sts->CreateTransport(aHostName, aPort, nsnull, aHostName, &mTransport);
|
||||
rv = sts->CreateTransport(aHostName, aPort, aHostName, &mTransport);
|
||||
}
|
||||
|
||||
|
||||
|
@ -40,10 +40,9 @@ INCS = $(INCS) \
|
||||
-I$(DEPTH)\dist\include \
|
||||
$(NULL)
|
||||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\gkgfxwin.lib \
|
||||
$(LIBNSPR) \
|
||||
LLIBS= \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(LIBNSPR) \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
@ -28,8 +28,11 @@
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsICapabilities.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#define NECKO_EXPORT(returnType) PR_PUBLIC_API(returnType)
|
||||
@ -48,15 +51,22 @@ extern nsresult
|
||||
NS_NewURI(nsIURI* *result, const nsString& spec, nsIURI* baseURI = nsnull);
|
||||
|
||||
extern nsresult
|
||||
NS_OpenURI(nsIChannel* *result, nsIURI* uri, nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter = nsnull);
|
||||
NS_OpenURI(nsIChannel* *result, nsIURI* uri,
|
||||
nsILoadGroup *aGroup = nsnull,
|
||||
nsICapabilities *notificationCallbacks = nsnull,
|
||||
nsLoadFlags loadAttributes = nsIChannel::LOAD_NORMAL);
|
||||
|
||||
extern nsresult
|
||||
NS_OpenURI(nsIInputStream* *result, nsIURI* uri);
|
||||
NS_OpenURI(nsIInputStream* *result, nsIURI* uri,
|
||||
nsILoadGroup *aGroup = nsnull,
|
||||
nsICapabilities *notificationCallbacks = nsnull,
|
||||
nsLoadFlags loadAttributes = nsIChannel::LOAD_NORMAL);
|
||||
|
||||
extern nsresult
|
||||
NS_OpenURI(nsIStreamListener* aConsumer, nsISupports* context, nsIURI* uri,
|
||||
nsILoadGroup *aGroup);
|
||||
nsILoadGroup *aGroup = nsnull,
|
||||
nsICapabilities *notificationCallbacks = nsnull,
|
||||
nsLoadFlags loadAttributes = nsIChannel::LOAD_NORMAL);
|
||||
|
||||
extern nsresult
|
||||
NS_MakeAbsoluteURI(const char* spec, nsIURI* baseURI, char* *result);
|
||||
@ -72,4 +82,30 @@ extern nsresult
|
||||
NS_NewPostDataStream(PRBool isFile, const char *data, PRUint32 encodeFlags,
|
||||
nsIInputStream **result);
|
||||
|
||||
inline nsresult
|
||||
NS_NewInputStreamChannel(nsIURI* uri,
|
||||
const char *contentType,
|
||||
PRInt32 contentLength,
|
||||
nsIInputStream *inStr,
|
||||
nsILoadGroup *aGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel **result)
|
||||
{
|
||||
nsresult rv;
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return serv->NewInputStreamChannel(uri,
|
||||
contentType,
|
||||
contentLength,
|
||||
inStr,
|
||||
aGroup,
|
||||
notificationCallbacks,
|
||||
loadAttributes,
|
||||
originalURI,
|
||||
result);
|
||||
}
|
||||
|
||||
#endif // nsNeckoUtil_h__
|
||||
|
@ -57,16 +57,18 @@ NS_NewURI(nsIURI* *result, const nsString& spec, nsIURI* baseURI)
|
||||
}
|
||||
|
||||
NECKO_EXPORT(nsresult)
|
||||
NS_OpenURI(nsIChannel* *result, nsIURI* uri, nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter *eventSinkGetter)
|
||||
NS_OpenURI(nsIChannel* *result, nsIURI* uri,
|
||||
nsILoadGroup *aGroup,
|
||||
nsICapabilities *notificationCallbacks,
|
||||
nsLoadFlags loadAttributes)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIChannel* channel;
|
||||
rv = serv->NewChannelFromURI("load", uri, aGroup, eventSinkGetter,
|
||||
nsnull, &channel);
|
||||
rv = serv->NewChannelFromURI("load", uri, aGroup, notificationCallbacks,
|
||||
loadAttributes, nsnull, &channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*result = channel;
|
||||
@ -74,12 +76,15 @@ NS_OpenURI(nsIChannel* *result, nsIURI* uri, nsILoadGroup *aGroup,
|
||||
}
|
||||
|
||||
NECKO_EXPORT(nsresult)
|
||||
NS_OpenURI(nsIInputStream* *result, nsIURI* uri)
|
||||
NS_OpenURI(nsIInputStream* *result, nsIURI* uri,
|
||||
nsILoadGroup *aGroup,
|
||||
nsICapabilities *notificationCallbacks,
|
||||
nsLoadFlags loadAttributes)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIChannel* channel;
|
||||
|
||||
rv = NS_OpenURI(&channel, uri, nsnull);
|
||||
rv = NS_OpenURI(&channel, uri, aGroup, notificationCallbacks, loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIInputStream* inStr;
|
||||
@ -93,12 +98,14 @@ NS_OpenURI(nsIInputStream* *result, nsIURI* uri)
|
||||
|
||||
NECKO_EXPORT(nsresult)
|
||||
NS_OpenURI(nsIStreamListener* aConsumer, nsISupports* context, nsIURI* uri,
|
||||
nsILoadGroup *aGroup)
|
||||
nsILoadGroup *aGroup,
|
||||
nsICapabilities *notificationCallbacks,
|
||||
nsLoadFlags loadAttributes)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIChannel* channel;
|
||||
|
||||
rv = NS_OpenURI(&channel, uri, aGroup);
|
||||
rv = NS_OpenURI(&channel, uri, aGroup, notificationCallbacks, loadAttributes);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->AsyncRead(0, -1, context, aConsumer);
|
||||
|
@ -355,7 +355,8 @@ int nsAccount::GetNCIValues(nsString MiddleValue)
|
||||
|
||||
nsIChannel *channel = nsnull;
|
||||
// XXX NECKO verb? loadgroup? getter?
|
||||
ret = service->NewChannel("load", Trial.ToNewCString(), nsnull, nsnull, nsnull, nsnull, &channel);
|
||||
ret = service->NewChannel("load", Trial.ToNewCString(), nsnull, nsnull, nsnull,
|
||||
nsIChannel::LOAD_NORMAL, nsnull, &channel);
|
||||
if (NS_FAILED(ret)) return ret;
|
||||
|
||||
|
||||
@ -444,7 +445,8 @@ int nsAccount::GetConfigValues(nsString fileName)
|
||||
|
||||
nsIChannel *channel = nsnull;
|
||||
// XXX NECKO verb? loadgroup? getter?
|
||||
ret = service->NewChannel("load", Trial.ToNewCString(), nsnull, nsnull, nsnull, nsnull, &channel);
|
||||
ret = service->NewChannel("load", Trial.ToNewCString(), nsnull, nsnull, nsnull,
|
||||
nsIChannel::LOAD_NORMAL, nsnull, &channel);
|
||||
if (NS_FAILED(ret)) return ret;
|
||||
|
||||
|
||||
|
@ -125,8 +125,9 @@ nsChromeProtocolHandler::NewURI(const char *aSpec, nsIURI *aBaseURI,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
nsILoadGroup *aGroup,
|
||||
nsIEventSinkGetter* eventSinkGetter,
|
||||
nsILoadGroup* aLoadGroup,
|
||||
nsICapabilities* notificationCallbacks,
|
||||
nsLoadFlags loadAttributes,
|
||||
nsIURI* originalURI,
|
||||
nsIChannel* *result)
|
||||
{
|
||||
@ -151,7 +152,10 @@ nsChromeProtocolHandler::NewChannel(const char* verb, nsIURI* uri,
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = serv->NewChannelFromURI(verb, chromeURI, aGroup, eventSinkGetter,
|
||||
rv = serv->NewChannelFromURI(verb, chromeURI,
|
||||
aLoadGroup,
|
||||
notificationCallbacks,
|
||||
loadAttributes,
|
||||
originalURI ? originalURI : uri, result);
|
||||
|
||||
// Get a system principal for chrome and set the owner property
|
||||
|
@ -4600,7 +4600,7 @@ nsXULDocument::LoadScript(nsIURI* aURI, const char* aVersion, PRBool* aBlock)
|
||||
|
||||
// N.B., the loader will be released in DoneLoadingScript()
|
||||
nsIUnicharStreamLoader* loader;
|
||||
rv = NS_NewUnicharStreamLoader(&loader, aURI, group, this);
|
||||
rv = NS_NewUnicharStreamLoader(&loader, aURI, this, group);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*aBlock = PR_TRUE;
|
||||
|
@ -1020,35 +1020,6 @@ nsDocumentBindInfo::QueryInterface(const nsIID& aIID,
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
class nsWebShellEventSinkGetter : public nsIEventSinkGetter {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsWebShellEventSinkGetter(nsIWebShell *aWebShell) {
|
||||
NS_INIT_REFCNT();
|
||||
mWebShell = aWebShell;
|
||||
NS_IF_ADDREF(mWebShell);
|
||||
}
|
||||
|
||||
virtual ~nsWebShellEventSinkGetter() {
|
||||
NS_IF_RELEASE(mWebShell);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetEventSink(const char* aVerb, const nsIID& anIID, nsISupports** aSink) {
|
||||
if (mWebShell) {
|
||||
if (nsCRT::strcmp(aVerb, "load") == 0) {
|
||||
return mWebShell->QueryInterface(anIID, (void**)aSink);
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
private:
|
||||
nsIWebShell* mWebShell;
|
||||
};
|
||||
|
||||
// XXXbe second arg is unnecessary given first; hidden static IID in macro... scc help!
|
||||
NS_IMPL_ISUPPORTS(nsWebShellEventSinkGetter, nsCOMTypeInfo<nsIEventSinkGetter>::GetIID())
|
||||
|
||||
nsresult nsDocumentBindInfo::Bind(nsIURI* aURL,
|
||||
nsILoadGroup *aLoadGroup,
|
||||
nsIInputStream *postDataStream,
|
||||
@ -1057,13 +1028,9 @@ nsresult nsDocumentBindInfo::Bind(nsIURI* aURL,
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// XXXbe this knows that m_Container implements nsIWebShell
|
||||
nsCOMPtr<nsIWebShell> webShell = do_QueryInterface(m_Container);
|
||||
nsCOMPtr<nsIEventSinkGetter> eventSinkGetter = new nsWebShellEventSinkGetter(webShell);
|
||||
if (!eventSinkGetter)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsICapabilities> capabilities = do_QueryInterface(m_Container);
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = NS_OpenURI(getter_AddRefs(channel), aURL, aLoadGroup, eventSinkGetter);
|
||||
rv = NS_OpenURI(getter_AddRefs(channel), aURL, aLoadGroup, capabilities);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (postDataStream || aReferrer)
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "nsweb.h"
|
||||
#include "prtypes.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsICapabilities.h"
|
||||
|
||||
class nsIContentViewer;
|
||||
class nsIURI;
|
||||
@ -38,7 +38,7 @@ class nsIChannel;
|
||||
* The primary container interface for objects that can contain
|
||||
* implementations of nsIContentViewer.
|
||||
*/
|
||||
class nsIContentViewerContainer : public nsISupports
|
||||
class nsIContentViewerContainer : public nsICapabilities
|
||||
{
|
||||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_ICONTENT_VIEWER_CONTAINER_IID; return iid; }
|
||||
|
@ -1020,35 +1020,6 @@ nsDocumentBindInfo::QueryInterface(const nsIID& aIID,
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
|
||||
class nsWebShellEventSinkGetter : public nsIEventSinkGetter {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
nsWebShellEventSinkGetter(nsIWebShell *aWebShell) {
|
||||
NS_INIT_REFCNT();
|
||||
mWebShell = aWebShell;
|
||||
NS_IF_ADDREF(mWebShell);
|
||||
}
|
||||
|
||||
virtual ~nsWebShellEventSinkGetter() {
|
||||
NS_IF_RELEASE(mWebShell);
|
||||
}
|
||||
|
||||
NS_IMETHOD GetEventSink(const char* aVerb, const nsIID& anIID, nsISupports** aSink) {
|
||||
if (mWebShell) {
|
||||
if (nsCRT::strcmp(aVerb, "load") == 0) {
|
||||
return mWebShell->QueryInterface(anIID, (void**)aSink);
|
||||
}
|
||||
}
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
private:
|
||||
nsIWebShell* mWebShell;
|
||||
};
|
||||
|
||||
// XXXbe second arg is unnecessary given first; hidden static IID in macro... scc help!
|
||||
NS_IMPL_ISUPPORTS(nsWebShellEventSinkGetter, nsCOMTypeInfo<nsIEventSinkGetter>::GetIID())
|
||||
|
||||
nsresult nsDocumentBindInfo::Bind(nsIURI* aURL,
|
||||
nsILoadGroup *aLoadGroup,
|
||||
nsIInputStream *postDataStream,
|
||||
@ -1057,13 +1028,9 @@ nsresult nsDocumentBindInfo::Bind(nsIURI* aURL,
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// XXXbe this knows that m_Container implements nsIWebShell
|
||||
nsCOMPtr<nsIWebShell> webShell = do_QueryInterface(m_Container);
|
||||
nsCOMPtr<nsIEventSinkGetter> eventSinkGetter = new nsWebShellEventSinkGetter(webShell);
|
||||
if (!eventSinkGetter)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
nsCOMPtr<nsICapabilities> capabilities = do_QueryInterface(m_Container);
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = NS_OpenURI(getter_AddRefs(channel), aURL, aLoadGroup, eventSinkGetter);
|
||||
rv = NS_OpenURI(getter_AddRefs(channel), aURL, aLoadGroup, capabilities);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (postDataStream || aReferrer)
|
||||
|
@ -169,6 +169,7 @@ public:
|
||||
|
||||
// nsISupports
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSICAPABILITIES
|
||||
|
||||
// nsIInterfaceRequestor
|
||||
NS_DECL_NSIINTERFACEREQUESTOR
|
||||
@ -780,6 +781,7 @@ NS_IMPL_QUERY_HEAD(nsWebShell)
|
||||
NS_IMPL_QUERY_BODY(nsIRefreshURI)
|
||||
NS_IMPL_QUERY_BODY(nsIClipboardCommands)
|
||||
NS_IMPL_QUERY_BODY(nsIInterfaceRequestor)
|
||||
NS_IMPL_QUERY_BODY(nsICapabilities)
|
||||
NS_IMPL_QUERY_TAIL(nsIWebShell)
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -802,7 +804,7 @@ nsWebShell::GetInterface(const nsIID &aIID, void** aInstancePtr)
|
||||
else if(mPluginManager) //XXX this seems a little wrong. MMP
|
||||
return mPluginManager->QueryInterface(aIID, aInstancePtr);
|
||||
|
||||
return NS_NOINTERFACE;
|
||||
return QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -4,3 +4,4 @@ nsIEnumerator.idl
|
||||
nsIObserver.idl
|
||||
nsIObserverService.idl
|
||||
nsISupportsArray.idl
|
||||
nsICapabilities.idl
|
||||
|
@ -102,6 +102,7 @@ XPIDLSRCS = \
|
||||
nsIObserverService.idl \
|
||||
nsISupportsArray.idl \
|
||||
nsISupportsPrimitives.idl \
|
||||
nsICapabilities.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
@ -68,6 +68,7 @@ XPIDLSRCS = \
|
||||
.\nsIObserverService.idl \
|
||||
.\nsISupportsArray.idl \
|
||||
.\nsISupportsPrimitives.idl \
|
||||
.\nsICapabilities.idl \
|
||||
$(NULL)
|
||||
|
||||
################################################################################
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user