mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Big changes for Necko load groups. Things are much happier now. Now images work (on pages, but not in chrome).
This commit is contained in:
parent
b3bdcb153e
commit
84bd74a4fd
@ -104,7 +104,6 @@ nsChromeProtocolHandler::MakeAbsolute(const char* aSpec,
|
||||
url->GetSpec(result);
|
||||
NS_RELEASE(url);
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -52,6 +52,7 @@ class nsIDOMDocumentFragment;
|
||||
class nsILineBreaker;
|
||||
class nsIWordBreaker;
|
||||
class nsIDOMSelection;
|
||||
class nsIChannel;
|
||||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
@ -85,10 +86,14 @@ public:
|
||||
// returns the arena associated with this document.
|
||||
virtual nsIArena* GetArena() = 0;
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI *aUrl,
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand) = 0;
|
||||
nsIStreamListener **aDocListener) = 0;
|
||||
|
||||
/**
|
||||
* Return the title of the document. May return null.
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsIURL.h"
|
||||
#ifdef NECKO
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIChannel.h"
|
||||
#else
|
||||
#include "nsIURLGroup.h"
|
||||
#endif
|
||||
@ -829,7 +830,11 @@ nsIArena* nsDocument::GetArena()
|
||||
}
|
||||
|
||||
nsresult
|
||||
#ifdef NECKO
|
||||
nsDocument::Reset(nsIChannel* aChannel)
|
||||
#else
|
||||
nsDocument::Reset(nsIURI *aURL)
|
||||
#endif
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@ -883,14 +888,16 @@ nsDocument::Reset(nsIURI *aURL)
|
||||
|
||||
NS_IF_RELEASE(mNameSpaceManager);
|
||||
|
||||
#ifdef NECKO
|
||||
(void)aChannel->GetURI(&mDocumentURL);
|
||||
(void)aChannel->GetLoadGroup(&mDocumentLoadGroup);
|
||||
#else
|
||||
mDocumentURL = aURL;
|
||||
if (nsnull != aURL) {
|
||||
NS_ADDREF(aURL);
|
||||
|
||||
#ifndef NECKO
|
||||
rv = aURL->GetLoadGroup(&mDocumentLoadGroup);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (NS_OK == rv) {
|
||||
rv = NS_NewNameSpaceManager(&mNameSpaceManager);
|
||||
@ -900,12 +907,20 @@ nsDocument::Reset(nsIURI *aURL)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::StartDocumentLoad(nsIURI *aURL,
|
||||
nsDocument::StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aURL,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
#ifdef NECKO
|
||||
return Reset(aChannel);
|
||||
#else
|
||||
return Reset(aURL);
|
||||
#endif
|
||||
}
|
||||
|
||||
const nsString* nsDocument::GetDocumentTitle() const
|
||||
|
@ -110,10 +110,14 @@ public:
|
||||
|
||||
virtual nsIArena* GetArena();
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI *aUrl,
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand);
|
||||
nsIStreamListener **aDocListener);
|
||||
|
||||
/**
|
||||
* Return the title of the document. May return null.
|
||||
@ -414,7 +418,11 @@ protected:
|
||||
nsIContent* FindContent(const nsIContent* aStartNode,
|
||||
const nsIContent* aTest1,
|
||||
const nsIContent* aTest2) const;
|
||||
#ifdef NECKO
|
||||
virtual nsresult Reset(nsIChannel* aChannel);
|
||||
#else
|
||||
virtual nsresult Reset(nsIURI* aURL);
|
||||
#endif
|
||||
|
||||
// this enum is temporary; there should be no knowledge of HTML in
|
||||
// nsDocument. That will be fixed when content sink stream factories
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
nsIDocumentViewer*& aResult);
|
||||
|
||||
// nsIDocumentLoaderObserver interface
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand){return NS_OK;}
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand) {return NS_OK;}
|
||||
|
||||
#ifndef NECKO
|
||||
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIURI *aUrl, PRInt32 aStatus,nsIDocumentLoaderObserver * aObserver){return NS_OK;}
|
||||
@ -111,7 +111,7 @@ public:
|
||||
#ifndef NECKO
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aContentType,nsIContentViewer* aViewer);
|
||||
#else
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, const char* aContentType,nsIContentViewer* aViewer){return NS_OK;}
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsIContentViewer* aViewer);
|
||||
#endif // NECKO
|
||||
|
||||
#ifndef NECKO
|
||||
@ -129,7 +129,7 @@ public:
|
||||
#ifndef NECKO
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, PRInt32 aStatus);
|
||||
#else
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus){return NS_OK;}
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus);
|
||||
#endif // NECKO
|
||||
|
||||
#ifndef NECKO
|
||||
@ -734,9 +734,12 @@ nsIContentViewer *viewer;
|
||||
* See documentation above in the DocumentViewerImpl class definition
|
||||
* @update 07/09/99 dwc
|
||||
*/
|
||||
#ifndef NECKO
|
||||
NS_IMETHODIMP
|
||||
#ifdef NECKO
|
||||
DocumentViewerImpl::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsIContentViewer* aViewer)
|
||||
#else
|
||||
DocumentViewerImpl::OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aContentType,nsIContentViewer* aViewer)
|
||||
#endif
|
||||
{
|
||||
mNumURLStarts++;
|
||||
return NS_OK;
|
||||
@ -747,11 +750,15 @@ DocumentViewerImpl::OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, cons
|
||||
* @update 07/09/99 dwc
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
#ifdef NECKO
|
||||
DocumentViewerImpl::OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus)
|
||||
#else
|
||||
DocumentViewerImpl::OnEndURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, PRInt32 aStatus)
|
||||
#endif // NECKO
|
||||
{
|
||||
nsIContentViewerContainer *containerResult;
|
||||
nsIWebShell *webContainer;
|
||||
nsresult rv;
|
||||
nsIContentViewerContainer *containerResult;
|
||||
nsIWebShell *webContainer;
|
||||
nsresult rv;
|
||||
|
||||
mNumURLStarts--;
|
||||
|
||||
@ -775,7 +782,6 @@ nsresult rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif // NECKO
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -258,9 +258,20 @@ nsrefcnt nsHTMLDocument::Release()
|
||||
}
|
||||
|
||||
nsresult
|
||||
#ifdef NECKO
|
||||
nsHTMLDocument::Reset(nsIChannel* aChannel)
|
||||
#else
|
||||
nsHTMLDocument::Reset(nsIURI *aURL)
|
||||
#endif
|
||||
{
|
||||
#ifdef NECKO
|
||||
nsresult result = nsDocument::Reset(aChannel);
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
result = aChannel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(result)) return result;
|
||||
#else
|
||||
nsresult result = nsDocument::Reset(aURL);
|
||||
#endif
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
@ -331,21 +342,35 @@ nsHTMLDocument::CreateShell(nsIPresContext* aContext,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::StartDocumentLoad(nsIURI *aURL,
|
||||
nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aURL,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aURL,
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
||||
#ifdef NECKO
|
||||
aChannel,
|
||||
#else
|
||||
aURL,
|
||||
#endif
|
||||
aContainer,
|
||||
aDocListener,
|
||||
aCommand);
|
||||
aDocListener);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIWebShell* webShell;
|
||||
|
||||
#ifdef NECKO
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
rv = aChannel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
@ -1413,7 +1438,11 @@ nsHTMLDocument::OpenCommon(nsIURI* aSourceURL)
|
||||
// The open occurred after the document finished loading.
|
||||
// So we reset the document and create a new one.
|
||||
if (nsnull == mParser) {
|
||||
#ifdef NECKO
|
||||
// XXX help!
|
||||
#else
|
||||
result = Reset(aSourceURL);
|
||||
#endif
|
||||
if (NS_OK == result) {
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
@ -59,10 +59,14 @@ public:
|
||||
nsIStyleSet* aStyleSet,
|
||||
nsIPresShell** aInstancePtrResult);
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI* aUrl,
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener** aDocListener,
|
||||
const char* aCommand);
|
||||
nsIStreamListener **aDocListener);
|
||||
|
||||
NS_IMETHOD EndLoad();
|
||||
|
||||
@ -182,7 +186,11 @@ protected:
|
||||
PRBool GetBodyContent();
|
||||
nsresult GetBodyElement(nsIDOMHTMLBodyElement** aBody);
|
||||
|
||||
#ifdef NECKO
|
||||
virtual nsresult Reset(nsIChannel* aChannel);
|
||||
#else
|
||||
virtual nsresult Reset(nsIURI *aURL);
|
||||
#endif
|
||||
nsresult WriteCommon(const nsString& aText,
|
||||
PRBool aNewlineTerminate);
|
||||
nsresult ScriptWriteCommon(JSContext *cx,
|
||||
|
@ -57,10 +57,14 @@ public:
|
||||
nsImageDocument();
|
||||
virtual ~nsImageDocument();
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI* aURL,
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener** aDocListener,
|
||||
const char* aCommand);
|
||||
nsIStreamListener **aDocListener);
|
||||
|
||||
nsresult CreateSyntheticDocument();
|
||||
|
||||
@ -247,15 +251,23 @@ nsImageDocument::~nsImageDocument()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageDocument::StartDocumentLoad(nsIURI* aURL,
|
||||
nsImageDocument::StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aURL,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener** aDocListener,
|
||||
const char* aCommand)
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aURL,
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
||||
#ifdef NECKO
|
||||
aChannel,
|
||||
#else
|
||||
aURL,
|
||||
#endif
|
||||
aContainer,
|
||||
aDocListener,
|
||||
aCommand);
|
||||
aDocListener);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -1282,11 +1282,13 @@ CSSLoaderImpl::LoadAgentSheet(nsIURI* aURL,
|
||||
if (urlClone) {
|
||||
#endif
|
||||
#ifdef NECKO
|
||||
#if 0
|
||||
nsILoadGroup* loadGroup = nsnull;
|
||||
if (mDocument) {
|
||||
loadGroup = mDocument->GetDocumentLoadGroup();
|
||||
}
|
||||
result = NS_OpenURI(&in, urlClone, loadGroup);
|
||||
#endif
|
||||
result = NS_OpenURI(&in, urlClone/*, loadGroup*/);
|
||||
#else
|
||||
result = NS_OpenURL(urlClone, &in);
|
||||
#endif
|
||||
|
@ -43,6 +43,10 @@
|
||||
#include "nsExpatDTD.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#ifdef NECKO
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIURI.h"
|
||||
#endif
|
||||
|
||||
// XXX The XML world depends on the html atoms
|
||||
#include "nsHTMLAtoms.h"
|
||||
@ -150,9 +154,20 @@ nsrefcnt nsXMLDocument::Release()
|
||||
}
|
||||
|
||||
nsresult
|
||||
#ifdef NECKO
|
||||
nsXMLDocument::Reset(nsIChannel* aChannel)
|
||||
#else
|
||||
nsXMLDocument::Reset(nsIURI* aURL)
|
||||
#endif
|
||||
{
|
||||
#ifdef NECKO
|
||||
nsresult result = nsDocument::Reset(aChannel);
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
result = aChannel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(result)) return result;
|
||||
#else
|
||||
nsresult result = nsDocument::Reset(aURL);
|
||||
#endif
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
@ -188,21 +203,35 @@ nsXMLDocument::GetContentType(nsString& aContentType) const
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::StartDocumentLoad(nsIURI *aUrl,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
nsXMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aUrl,
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
||||
#ifdef NECKO
|
||||
aChannel,
|
||||
#else
|
||||
aUrl,
|
||||
#endif
|
||||
aContainer,
|
||||
aDocListener,
|
||||
aCommand);
|
||||
aDocListener);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIWebShell* webShell;
|
||||
|
||||
#ifdef NECKO
|
||||
nsCOMPtr<nsIURI> aUrl;
|
||||
rv = aChannel->GetURI(getter_AddRefs(aUrl));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
|
@ -47,10 +47,14 @@ public:
|
||||
|
||||
NS_IMETHOD GetContentType(nsString& aContentType) const;
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI *aUrl,
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand);
|
||||
nsIStreamListener **aDocListener);
|
||||
|
||||
NS_IMETHOD EndLoad();
|
||||
|
||||
@ -79,7 +83,11 @@ public:
|
||||
protected:
|
||||
virtual void InternalAddStyleSheet(nsIStyleSheet* aSheet); // subclass hook for sheet ordering
|
||||
virtual void InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex);
|
||||
#ifdef NECKO
|
||||
virtual nsresult Reset(nsIChannel* aChannel);
|
||||
#else
|
||||
virtual nsresult Reset(nsIURI* aUrl);
|
||||
#endif
|
||||
|
||||
// For HTML elements in our content model
|
||||
nsIHTMLStyleSheet* mAttrStyleSheet;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
@ -423,10 +423,14 @@ public:
|
||||
|
||||
NS_IMETHOD GetContentType(nsString& aContentType) const;
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI *aUrl,
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand);
|
||||
nsIStreamListener **aDocListener);
|
||||
|
||||
NS_IMETHOD LoadFromStream(nsIInputStream& xulStream,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
@ -726,7 +730,12 @@ protected:
|
||||
nsresult PrepareToLoad( nsCOMPtr<nsIParser>* created_parser,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
const char* aCommand,
|
||||
nsIURI* aOptionalURL = 0 );
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel
|
||||
#else
|
||||
nsIURI* aOptionalURL = 0
|
||||
#endif
|
||||
);
|
||||
|
||||
protected:
|
||||
// pseudo constants
|
||||
@ -757,7 +766,7 @@ protected:
|
||||
nsVoidArray mObservers;
|
||||
nsAutoString mDocumentTitle;
|
||||
nsCOMPtr<nsIURI> mDocumentURL; // [OWNER] ??? compare with loader
|
||||
nsCOMPtr<nsILoadGroup> mDocumentLoadGroup; // [OWNER] leads to loader
|
||||
nsCOMPtr<nsILoadGroup> mDocumentLoadGroup; // [OWNER] leads to loader
|
||||
nsCOMPtr<nsIRDFResource> mRootResource; // [OWNER]
|
||||
nsCOMPtr<nsIContent> mRootContent; // [OWNER]
|
||||
nsIDocument* mParentDocument; // [WEAK]
|
||||
@ -1083,11 +1092,21 @@ nsresult
|
||||
XULDocumentImpl::PrepareToLoad( nsCOMPtr<nsIParser>* created_parser,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
const char* aCommand,
|
||||
nsIURI* aOptionalURL )
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel
|
||||
#else
|
||||
nsIURI* aOptionalURL
|
||||
#endif
|
||||
)
|
||||
{
|
||||
nsCOMPtr<nsIURI> syntheticURL;
|
||||
#ifdef NECKO
|
||||
if ( aChannel )
|
||||
(void)aChannel->GetURI(getter_AddRefs(syntheticURL));
|
||||
#else
|
||||
if ( aOptionalURL )
|
||||
syntheticURL = dont_QueryInterface(aOptionalURL);
|
||||
#endif
|
||||
else
|
||||
{
|
||||
nsAutoString seedString;
|
||||
@ -1114,7 +1133,7 @@ XULDocumentImpl::PrepareToLoad( nsCOMPtr<nsIParser>* created_parser,
|
||||
|
||||
mDocumentURL = syntheticURL;
|
||||
#ifdef NECKO
|
||||
// XXX help
|
||||
(void)aChannel->GetLoadGroup(getter_AddRefs(mDocumentLoadGroup));
|
||||
#else
|
||||
syntheticURL->GetLoadGroup(getter_AddRefs(mDocumentLoadGroup));
|
||||
#endif
|
||||
@ -1250,17 +1269,31 @@ XULDocumentImpl::SetDocumentURLAndGroup(nsIURI* anURL)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::StartDocumentLoad(nsIURI *aURL,
|
||||
XULDocumentImpl::StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aURL,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
nsresult status;
|
||||
nsCOMPtr<nsIParser> parser;
|
||||
#ifdef NECKO
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
status = aChannel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(status)) return status;
|
||||
#endif
|
||||
|
||||
do
|
||||
{
|
||||
if ( NS_FAILED(status = PrepareToLoad(&parser, aContainer, aCommand, aURL)) )
|
||||
#ifdef NECKO
|
||||
status = PrepareToLoad(&parser, aContainer, aCommand, aChannel);
|
||||
#else
|
||||
status = PrepareToLoad(&parser, aContainer, aCommand, aURL);
|
||||
#endif
|
||||
if ( NS_FAILED(status) )
|
||||
break;
|
||||
|
||||
{
|
||||
@ -1289,7 +1322,7 @@ XULDocumentImpl::LoadFromStream( nsIInputStream& xulStream,
|
||||
{
|
||||
nsresult status;
|
||||
nsCOMPtr<nsIParser> parser;
|
||||
if ( NS_SUCCEEDED(status = PrepareToLoad(&parser, aContainer, aCommand)) )
|
||||
if ( NS_SUCCEEDED(status = PrepareToLoad(&parser, aContainer, aCommand, nsnull)) )
|
||||
parser->Parse(xulStream);
|
||||
|
||||
return status;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "nsIStreamListener.h"
|
||||
#ifdef NECKO
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
#else
|
||||
#include "nsINetSupport.h"
|
||||
#include "nsIRefreshUrl.h"
|
||||
@ -310,9 +311,9 @@ public:
|
||||
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
PRInt32 aStatus,
|
||||
nsIDocumentLoaderObserver * );
|
||||
nsIDocumentLoaderObserver * );
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel, const char* aContentType,
|
||||
nsIChannel* channel,
|
||||
nsIContentViewer* aViewer);
|
||||
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel, PRUint32 aProgress,
|
||||
@ -1861,18 +1862,8 @@ nsWebShell::DoLoadURL(const nsString& aUrlSpec,
|
||||
nsCOMPtr<nsIURI> url;
|
||||
#ifndef NECKO
|
||||
rv = NS_NewURL(getter_AddRefs(url), aUrlSpec);
|
||||
#else
|
||||
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIURI *uri = nsnull;
|
||||
char *uriSpec = aUrlSpec.ToNewCString();
|
||||
rv = service->NewURI(uriSpec, nsnull, &uri);
|
||||
nsCRT::free(uriSpec);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = uri->QueryInterface(nsIURI::GetIID(), (void**)&url);
|
||||
NS_RELEASE(uri);
|
||||
#else
|
||||
rv = NS_NewURI(getter_AddRefs(url), aUrlSpec);
|
||||
#endif // NECKO
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (url && docURL && EqualBaseURLs(docURL, url)) {
|
||||
@ -1960,13 +1951,16 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
||||
#endif
|
||||
const PRUint32 aLocalIP)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
PRInt32 colon, fSlash;
|
||||
PRUnichar port;
|
||||
nsAutoString urlSpec;
|
||||
convertFileToURL(nsString(aURLSpec), urlSpec);
|
||||
|
||||
//#ifdef NECKO
|
||||
// nsCOMPtr<nsIURI> url;
|
||||
// rv = NS_NewURI(getter_AddRefs(url), urlSpec);
|
||||
// if (NS_FAILED(rv)) return rv;
|
||||
//#else
|
||||
PRInt32 colon, fSlash;
|
||||
PRUnichar port;
|
||||
fSlash=urlSpec.Find('/');
|
||||
|
||||
// if no scheme (protocol) is found, assume http.
|
||||
@ -2102,6 +2096,7 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
||||
nsAutoString newURL(urlString);
|
||||
|
||||
return DoLoadURL(newURL, aCommand, aPostData, aType, aLocalIP);
|
||||
//#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebShell::Stop(void)
|
||||
@ -3037,8 +3032,8 @@ nsWebShell::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
#endif
|
||||
nsIContentViewer* aViewer)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -3078,7 +3073,7 @@ nsWebShell::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
|
||||
{
|
||||
#ifdef NECKO
|
||||
mDocLoaderObserver->OnStartURLLoad(mDocLoader, channel, aContentType, aViewer);
|
||||
mDocLoaderObserver->OnStartURLLoad(mDocLoader, channel, aViewer);
|
||||
#else
|
||||
mDocLoaderObserver->OnStartURLLoad(mDocLoader, aURL, aContentType, aViewer);
|
||||
#endif
|
||||
@ -3772,8 +3767,8 @@ PRBool nsWebShellFactory::mStartedServices = PR_FALSE;
|
||||
void
|
||||
nsWebShellFactory::StartServices()
|
||||
{
|
||||
// XXX TEMPORARY Till we have real pluggable protocol handlers
|
||||
#ifndef NECKO
|
||||
// XXX TEMPORARY Till we have real pluggable protocol handlers
|
||||
NET_InitJavaScriptProtocol();
|
||||
#endif // NECKO
|
||||
mStartedServices = PR_TRUE;
|
||||
|
@ -2452,8 +2452,8 @@ nsEditorShell::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIContentViewer* aViewer)
|
||||
#else
|
||||
nsEditorShell::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel, const char* aContentType,
|
||||
nsIContentViewer* aViewer)
|
||||
nsIChannel* channel,
|
||||
nsIContentViewer* aViewer)
|
||||
#endif // NECKO
|
||||
{
|
||||
|
||||
|
@ -212,7 +212,7 @@ class nsEditorShell : public nsIEditorShell,
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aContentType,
|
||||
nsIContentViewer* aViewer);
|
||||
#else
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, const char* aContentType,
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel,
|
||||
nsIContentViewer* aViewer);
|
||||
#endif // NECKO
|
||||
|
||||
|
@ -2452,8 +2452,8 @@ nsEditorShell::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIContentViewer* aViewer)
|
||||
#else
|
||||
nsEditorShell::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel, const char* aContentType,
|
||||
nsIContentViewer* aViewer)
|
||||
nsIChannel* channel,
|
||||
nsIContentViewer* aViewer)
|
||||
#endif // NECKO
|
||||
{
|
||||
|
||||
|
@ -212,7 +212,7 @@ class nsEditorShell : public nsIEditorShell,
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aContentType,
|
||||
nsIContentViewer* aViewer);
|
||||
#else
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, const char* aContentType,
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel,
|
||||
nsIContentViewer* aViewer);
|
||||
#endif // NECKO
|
||||
|
||||
|
@ -147,7 +147,7 @@ public:
|
||||
#ifdef NECKO
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand);
|
||||
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus, nsIDocumentLoaderObserver* aObserver);
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, const char* aContentType, nsIContentViewer* aViewer);
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsIContentViewer* aViewer);
|
||||
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsString& aMsg);
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus);
|
||||
@ -753,8 +753,8 @@ nsPICS::ParsePICSLabel(char * label)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPICS::OnStartDocumentLoad(nsIDocumentLoader* loader,
|
||||
nsIURI* aURL,
|
||||
const char* aCommand)
|
||||
nsIURI* aURL,
|
||||
const char* aCommand)
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
@ -806,7 +806,6 @@ NS_IMETHODIMP
|
||||
#ifdef NECKO
|
||||
nsPICS::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
const char* aContentType,
|
||||
nsIContentViewer* aViewer)
|
||||
#else
|
||||
nsPICS::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
@ -815,18 +814,22 @@ nsPICS::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIContentViewer* aViewer)
|
||||
#endif
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
#ifdef NECKO
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
rv = channel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
char* aContentType;
|
||||
rv = channel->GetContentType(&aContentType);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif
|
||||
|
||||
nsIContentViewerContainer *cont;
|
||||
|
||||
if(!mPICSRatingsEnabled)
|
||||
return NS_OK;
|
||||
goto done;
|
||||
|
||||
PICS_URLData* urlData;
|
||||
nsVoidArray* currentURLList;
|
||||
@ -858,8 +861,10 @@ nsPICS::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
|
||||
if(mWebShellServicesURLTable == nsnull) {
|
||||
mWebShellServicesURLTable = new nsHashtable(256, PR_TRUE);
|
||||
if (mWebShellServicesURLTable == nsnull)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (mWebShellServicesURLTable == nsnull) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
if(mWebShellServicesURLTable->Exists(&key)) {
|
||||
@ -869,19 +874,27 @@ nsPICS::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
mWebShellServicesURLTable->Put(&key, currentURLList);
|
||||
} else {
|
||||
currentURLList = new nsVoidArray();
|
||||
if(!currentURLList)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if(!currentURLList) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
mWebShellServicesURLTable->Put(&key, currentURLList);
|
||||
}
|
||||
} else {
|
||||
currentURLList = new nsVoidArray();
|
||||
if(!currentURLList)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
if (!currentURLList) {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
mWebShellServicesURLTable->Put(&key, currentURLList);
|
||||
}
|
||||
|
||||
}
|
||||
return NS_OK;
|
||||
done:
|
||||
#ifdef NECKO
|
||||
nsCRT::free(aContentType);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -264,6 +264,10 @@ ImageConsumer::OnDataAvailable(nsIURI* aURL, nsIInputStream *pIStream, PRUint32
|
||||
|
||||
err = pIStream->Read(mBuffer,
|
||||
max_read, &nb);
|
||||
if (err == NS_BASE_STREAM_WOULD_BLOCK) {
|
||||
err = NS_OK;
|
||||
break;
|
||||
}
|
||||
if (err != NS_OK) {
|
||||
break;
|
||||
}
|
||||
|
@ -26,11 +26,8 @@
|
||||
#include "nsIURLGroup.h"
|
||||
#include "nsILoadAttribs.h"
|
||||
#else
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
#endif // NECKO
|
||||
#include "nsString.h"
|
||||
#include "il_strm.h"
|
||||
|
@ -522,7 +522,7 @@ nsExpatTokenizer::OpenInputStream(nsString2& aURLStr, nsIInputStream*& in)
|
||||
ret = NS_NewURI(&uri, aURLStr);
|
||||
if (NS_FAILED(ret)) return ret;
|
||||
|
||||
ret = NS_OpenURI(&in, uri, nsnull); // XXX need to pass the document's nsILoadGroup here!
|
||||
ret = NS_OpenURI(&in, uri);
|
||||
NS_RELEASE(uri);
|
||||
#endif // NECKO
|
||||
return ret;
|
||||
|
@ -36,14 +36,14 @@ NS_IMETHODIMP nsObserverBase::NotifyWebShell(
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
nsresult rv = NS_OK;
|
||||
// shoudl docLoader a memeber to increase performance ???
|
||||
// should docLoader a member to increase performance ???
|
||||
nsIDocumentLoader * docLoader = nsnull;
|
||||
nsIContentViewerContainer * cvc = nsnull;
|
||||
nsIWebShellServices* wss = nsnull;
|
||||
|
||||
if(NS_FAILED(rv =nsServiceManager::GetService(kDocLoaderServiceCID,
|
||||
kIDocumentLoaderIID,
|
||||
(nsISupports**)&docLoader)))
|
||||
kIDocumentLoaderIID,
|
||||
(nsISupports**)&docLoader)))
|
||||
goto done;
|
||||
|
||||
if(NS_FAILED(rv =docLoader->GetContentViewerContainer(aDocumentID, &cvc)))
|
||||
|
@ -141,7 +141,7 @@ nsStringBundle::nsStringBundle(nsIURI* aURL, nsILocale* aLocale,
|
||||
|
||||
#else // NECKO
|
||||
nsresult rv;
|
||||
rv = NS_OpenURI(&in, aURL, nsnull); // XXX need to pass the document's nsILoadGroup here!
|
||||
rv = NS_OpenURI(&in, aURL);
|
||||
if (NS_FAILED(rv)) {
|
||||
#ifdef NS_DEBUG
|
||||
printf("cannot open uri\n");
|
||||
@ -309,7 +309,7 @@ nsStringBundle::OpenInputStream(nsString2& aURLStr, nsIInputStream*& in)
|
||||
ret = NS_NewURI(&uri, aURLStr);
|
||||
if (NS_FAILED(ret)) return ret;
|
||||
|
||||
ret = NS_OpenURI(&in, uri, nsnull); // XXX need to pass the document's nsILoadGroup here!
|
||||
ret = NS_OpenURI(&in, uri);
|
||||
NS_RELEASE(uri);
|
||||
#endif // NECKO
|
||||
return ret;
|
||||
|
@ -57,7 +57,7 @@ nsURLProperties::nsURLProperties(nsString& aUrl)
|
||||
res = NS_NewURI(&url, aUrl, nsnull);
|
||||
if (NS_FAILED(res)) return;
|
||||
|
||||
res = NS_OpenURI(&in, url, nsnull); // XXX no nsILoadGroup here, so we can't cancel this load!
|
||||
res = NS_OpenURI(&in, url);
|
||||
NS_RELEASE(url);
|
||||
if (NS_FAILED(res)) return;
|
||||
#endif // NECKO
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
nsIDocumentViewer*& aResult);
|
||||
|
||||
// nsIDocumentLoaderObserver interface
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand){return NS_OK;}
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand) {return NS_OK;}
|
||||
|
||||
#ifndef NECKO
|
||||
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIURI *aUrl, PRInt32 aStatus,nsIDocumentLoaderObserver * aObserver){return NS_OK;}
|
||||
@ -111,7 +111,7 @@ public:
|
||||
#ifndef NECKO
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aContentType,nsIContentViewer* aViewer);
|
||||
#else
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, const char* aContentType,nsIContentViewer* aViewer){return NS_OK;}
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsIContentViewer* aViewer);
|
||||
#endif // NECKO
|
||||
|
||||
#ifndef NECKO
|
||||
@ -129,7 +129,7 @@ public:
|
||||
#ifndef NECKO
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, PRInt32 aStatus);
|
||||
#else
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus){return NS_OK;}
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus);
|
||||
#endif // NECKO
|
||||
|
||||
#ifndef NECKO
|
||||
@ -734,9 +734,12 @@ nsIContentViewer *viewer;
|
||||
* See documentation above in the DocumentViewerImpl class definition
|
||||
* @update 07/09/99 dwc
|
||||
*/
|
||||
#ifndef NECKO
|
||||
NS_IMETHODIMP
|
||||
#ifdef NECKO
|
||||
DocumentViewerImpl::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsIContentViewer* aViewer)
|
||||
#else
|
||||
DocumentViewerImpl::OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aContentType,nsIContentViewer* aViewer)
|
||||
#endif
|
||||
{
|
||||
mNumURLStarts++;
|
||||
return NS_OK;
|
||||
@ -747,11 +750,15 @@ DocumentViewerImpl::OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, cons
|
||||
* @update 07/09/99 dwc
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
#ifdef NECKO
|
||||
DocumentViewerImpl::OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus)
|
||||
#else
|
||||
DocumentViewerImpl::OnEndURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, PRInt32 aStatus)
|
||||
#endif // NECKO
|
||||
{
|
||||
nsIContentViewerContainer *containerResult;
|
||||
nsIWebShell *webContainer;
|
||||
nsresult rv;
|
||||
nsIContentViewerContainer *containerResult;
|
||||
nsIWebShell *webContainer;
|
||||
nsresult rv;
|
||||
|
||||
mNumURLStarts--;
|
||||
|
||||
@ -775,7 +782,6 @@ nsresult rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif // NECKO
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -52,6 +52,7 @@ class nsIDOMDocumentFragment;
|
||||
class nsILineBreaker;
|
||||
class nsIWordBreaker;
|
||||
class nsIDOMSelection;
|
||||
class nsIChannel;
|
||||
|
||||
// IID for the nsIDocument interface
|
||||
#define NS_IDOCUMENT_IID \
|
||||
@ -85,10 +86,14 @@ public:
|
||||
// returns the arena associated with this document.
|
||||
virtual nsIArena* GetArena() = 0;
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI *aUrl,
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand) = 0;
|
||||
nsIStreamListener **aDocListener) = 0;
|
||||
|
||||
/**
|
||||
* Return the title of the document. May return null.
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "nsIURL.h"
|
||||
#ifdef NECKO
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsIChannel.h"
|
||||
#else
|
||||
#include "nsIURLGroup.h"
|
||||
#endif
|
||||
@ -829,7 +830,11 @@ nsIArena* nsDocument::GetArena()
|
||||
}
|
||||
|
||||
nsresult
|
||||
#ifdef NECKO
|
||||
nsDocument::Reset(nsIChannel* aChannel)
|
||||
#else
|
||||
nsDocument::Reset(nsIURI *aURL)
|
||||
#endif
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@ -883,14 +888,16 @@ nsDocument::Reset(nsIURI *aURL)
|
||||
|
||||
NS_IF_RELEASE(mNameSpaceManager);
|
||||
|
||||
#ifdef NECKO
|
||||
(void)aChannel->GetURI(&mDocumentURL);
|
||||
(void)aChannel->GetLoadGroup(&mDocumentLoadGroup);
|
||||
#else
|
||||
mDocumentURL = aURL;
|
||||
if (nsnull != aURL) {
|
||||
NS_ADDREF(aURL);
|
||||
|
||||
#ifndef NECKO
|
||||
rv = aURL->GetLoadGroup(&mDocumentLoadGroup);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (NS_OK == rv) {
|
||||
rv = NS_NewNameSpaceManager(&mNameSpaceManager);
|
||||
@ -900,12 +907,20 @@ nsDocument::Reset(nsIURI *aURL)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocument::StartDocumentLoad(nsIURI *aURL,
|
||||
nsDocument::StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aURL,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
#ifdef NECKO
|
||||
return Reset(aChannel);
|
||||
#else
|
||||
return Reset(aURL);
|
||||
#endif
|
||||
}
|
||||
|
||||
const nsString* nsDocument::GetDocumentTitle() const
|
||||
|
@ -110,10 +110,14 @@ public:
|
||||
|
||||
virtual nsIArena* GetArena();
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI *aUrl,
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand);
|
||||
nsIStreamListener **aDocListener);
|
||||
|
||||
/**
|
||||
* Return the title of the document. May return null.
|
||||
@ -414,7 +418,11 @@ protected:
|
||||
nsIContent* FindContent(const nsIContent* aStartNode,
|
||||
const nsIContent* aTest1,
|
||||
const nsIContent* aTest2) const;
|
||||
#ifdef NECKO
|
||||
virtual nsresult Reset(nsIChannel* aChannel);
|
||||
#else
|
||||
virtual nsresult Reset(nsIURI* aURL);
|
||||
#endif
|
||||
|
||||
// this enum is temporary; there should be no knowledge of HTML in
|
||||
// nsDocument. That will be fixed when content sink stream factories
|
||||
|
@ -100,7 +100,7 @@ public:
|
||||
nsIDocumentViewer*& aResult);
|
||||
|
||||
// nsIDocumentLoaderObserver interface
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand){return NS_OK;}
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand) {return NS_OK;}
|
||||
|
||||
#ifndef NECKO
|
||||
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIURI *aUrl, PRInt32 aStatus,nsIDocumentLoaderObserver * aObserver){return NS_OK;}
|
||||
@ -111,7 +111,7 @@ public:
|
||||
#ifndef NECKO
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aContentType,nsIContentViewer* aViewer);
|
||||
#else
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, const char* aContentType,nsIContentViewer* aViewer){return NS_OK;}
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsIContentViewer* aViewer);
|
||||
#endif // NECKO
|
||||
|
||||
#ifndef NECKO
|
||||
@ -129,7 +129,7 @@ public:
|
||||
#ifndef NECKO
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, PRInt32 aStatus);
|
||||
#else
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus){return NS_OK;}
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus);
|
||||
#endif // NECKO
|
||||
|
||||
#ifndef NECKO
|
||||
@ -734,9 +734,12 @@ nsIContentViewer *viewer;
|
||||
* See documentation above in the DocumentViewerImpl class definition
|
||||
* @update 07/09/99 dwc
|
||||
*/
|
||||
#ifndef NECKO
|
||||
NS_IMETHODIMP
|
||||
#ifdef NECKO
|
||||
DocumentViewerImpl::OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsIContentViewer* aViewer)
|
||||
#else
|
||||
DocumentViewerImpl::OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aContentType,nsIContentViewer* aViewer)
|
||||
#endif
|
||||
{
|
||||
mNumURLStarts++;
|
||||
return NS_OK;
|
||||
@ -747,11 +750,15 @@ DocumentViewerImpl::OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, cons
|
||||
* @update 07/09/99 dwc
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
#ifdef NECKO
|
||||
DocumentViewerImpl::OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus)
|
||||
#else
|
||||
DocumentViewerImpl::OnEndURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, PRInt32 aStatus)
|
||||
#endif // NECKO
|
||||
{
|
||||
nsIContentViewerContainer *containerResult;
|
||||
nsIWebShell *webContainer;
|
||||
nsresult rv;
|
||||
nsIContentViewerContainer *containerResult;
|
||||
nsIWebShell *webContainer;
|
||||
nsresult rv;
|
||||
|
||||
mNumURLStarts--;
|
||||
|
||||
@ -775,7 +782,6 @@ nsresult rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
#endif // NECKO
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -22,10 +22,7 @@
|
||||
#include "nsIDocumentViewer.h"
|
||||
#include "nsIURL.h"
|
||||
#ifdef NECKO
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsIServiceManager.h"
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
#include "nsNeckoUtil.h"
|
||||
#endif // NECKO
|
||||
#include "nsICSSLoader.h"
|
||||
#include "nsICSSStyleSheet.h"
|
||||
@ -125,9 +122,13 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// for nsIDocumentLoaderFactory
|
||||
NS_IMETHOD CreateInstance(nsIURI* aURL,
|
||||
NS_IMETHOD CreateInstance(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
const char* aCommand,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsISupports* aExtraInfo,
|
||||
nsIStreamListener** aDocListener,
|
||||
@ -148,15 +149,24 @@ public:
|
||||
|
||||
nsresult InitUAStyleSheet();
|
||||
|
||||
nsresult CreateDocument(nsIURI* aURL,
|
||||
const char* aCommand,
|
||||
nsresult CreateDocument(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
const nsCID& aDocumentCID,
|
||||
nsIStreamListener** aDocListener,
|
||||
nsIContentViewer** aDocViewer);
|
||||
|
||||
nsresult CreateRDFDocument(const char* aContentType, nsIURI* aURL,
|
||||
const char* aCommand,
|
||||
nsresult CreateRDFDocument(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsISupports* aExtraInfo,
|
||||
nsIStreamListener** aDocListener,
|
||||
@ -230,9 +240,13 @@ nsLayoutDLF::QueryInterface(REFNSIID aIID, void** aInstancePtrResult)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutDLF::CreateInstance(nsIURI* aURL,
|
||||
nsLayoutDLF::CreateInstance(const char *aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
const char *aCommand,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsISupports* aExtraInfo,
|
||||
nsIStreamListener** aDocListener,
|
||||
@ -240,7 +254,6 @@ nsLayoutDLF::CreateInstance(nsIURI* aURL,
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
|
||||
// XXX vile hack
|
||||
if(0==PL_strcmp(aCommand,"view-source")) {
|
||||
if((0==PL_strcmp(gXMLTypes[0],aContentType)) ||
|
||||
@ -254,7 +267,13 @@ nsLayoutDLF::CreateInstance(nsIURI* aURL,
|
||||
int typeIndex=0;
|
||||
while(gHTMLTypes[typeIndex]) {
|
||||
if (0== PL_strcmp(gHTMLTypes[typeIndex++], aContentType)) {
|
||||
return CreateDocument(aURL, aCommand, aContainer, kHTMLDocumentCID,
|
||||
return CreateDocument(aCommand,
|
||||
#ifdef NECKO
|
||||
aChannel,
|
||||
#else
|
||||
aURL,
|
||||
#endif
|
||||
aContainer, kHTMLDocumentCID,
|
||||
aDocListener, aDocViewer);
|
||||
}
|
||||
}
|
||||
@ -263,7 +282,13 @@ nsLayoutDLF::CreateInstance(nsIURI* aURL,
|
||||
typeIndex = 0;
|
||||
while(gXMLTypes[typeIndex]) {
|
||||
if (0== PL_strcmp(gXMLTypes[typeIndex++], aContentType)) {
|
||||
return CreateDocument(aURL, aCommand, aContainer, kXMLDocumentCID,
|
||||
return CreateDocument(aCommand,
|
||||
#ifdef NECKO
|
||||
aChannel,
|
||||
#else
|
||||
aURL,
|
||||
#endif
|
||||
aContainer, kXMLDocumentCID,
|
||||
aDocListener, aDocViewer);
|
||||
}
|
||||
}
|
||||
@ -272,7 +297,13 @@ nsLayoutDLF::CreateInstance(nsIURI* aURL,
|
||||
typeIndex = 0;
|
||||
while (gRDFTypes[typeIndex]) {
|
||||
if (0 == PL_strcmp(gRDFTypes[typeIndex++], aContentType)) {
|
||||
return CreateRDFDocument(aContentType, aURL, aCommand, aContainer,
|
||||
return CreateRDFDocument(aCommand,
|
||||
#ifdef NECKO
|
||||
aChannel,
|
||||
#else
|
||||
aURL,
|
||||
#endif
|
||||
aContentType, aContainer,
|
||||
aExtraInfo, aDocListener, aDocViewer);
|
||||
}
|
||||
}
|
||||
@ -281,7 +312,13 @@ nsLayoutDLF::CreateInstance(nsIURI* aURL,
|
||||
typeIndex = 0;
|
||||
while(gImageTypes[typeIndex]) {
|
||||
if (0== PL_strcmp(gImageTypes[typeIndex++], aContentType)) {
|
||||
return CreateDocument(aURL, aCommand, aContainer, kImageDocumentCID,
|
||||
return CreateDocument(aCommand,
|
||||
#ifdef NECKO
|
||||
aChannel,
|
||||
#else
|
||||
aURL,
|
||||
#endif
|
||||
aContainer, kImageDocumentCID,
|
||||
aDocListener, aDocViewer);
|
||||
}
|
||||
}
|
||||
@ -329,8 +366,12 @@ nsLayoutDLF::CreateInstanceForDocument(nsIContentViewerContainer* aContainer,
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLayoutDLF::CreateDocument(nsIURI* aURL,
|
||||
const char* aCommand,
|
||||
nsLayoutDLF::CreateDocument(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
const nsCID& aDocumentCID,
|
||||
nsIStreamListener** aDocListener,
|
||||
@ -338,6 +379,12 @@ nsLayoutDLF::CreateDocument(nsIURI* aURL,
|
||||
{
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
#ifdef NECKO
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
rv = aChannel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif
|
||||
|
||||
#ifdef NOISY_CREATE_DOC
|
||||
if (nsnull != aURL) {
|
||||
nsAutoString tmp;
|
||||
@ -371,7 +418,11 @@ nsLayoutDLF::CreateDocument(nsIURI* aURL,
|
||||
// Initialize the document to begin loading the data. An
|
||||
// nsIStreamListener connected to the parser is returned in
|
||||
// aDocListener.
|
||||
rv = doc->StartDocumentLoad(aURL, aContainer, aDocListener, aCommand);
|
||||
#ifdef NECKO
|
||||
rv = doc->StartDocumentLoad(aCommand, aChannel, aContainer, aDocListener);
|
||||
#else
|
||||
rv = doc->StartDocumentLoad(aCommand, aURL, aContainer, aDocListener);
|
||||
#endif
|
||||
if (NS_FAILED(rv))
|
||||
break;
|
||||
|
||||
@ -476,9 +527,13 @@ nsLayoutDLF::CreateRDFDocument(nsISupports* aExtraInfo,
|
||||
|
||||
// ...note, this RDF document _may_ be XUL :-)
|
||||
nsresult
|
||||
nsLayoutDLF::CreateRDFDocument(const char* aContentType,
|
||||
nsLayoutDLF::CreateRDFDocument(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
const char* aCommand,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsISupports* aExtraInfo,
|
||||
nsIStreamListener** aDocListener,
|
||||
@ -491,13 +546,23 @@ nsLayoutDLF::CreateRDFDocument(const char* aContentType,
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef NECKO
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
rv = aChannel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Initialize the document to begin loading the data...
|
||||
*
|
||||
* An nsIStreamListener connected to the parser is returned in
|
||||
* aDocListener.
|
||||
*/
|
||||
rv = doc->StartDocumentLoad(aURL, aContainer, aDocListener, aCommand);
|
||||
#ifdef NECKO
|
||||
rv = doc->StartDocumentLoad(aCommand, aChannel, aContainer, aDocListener);
|
||||
#else
|
||||
rv = doc->StartDocumentLoad(aCommand, aURL, aContainer, aDocListener);
|
||||
#endif
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
/*
|
||||
* Bind the document to the Content Viewer...
|
||||
@ -554,15 +619,7 @@ nsLayoutDLF::InitUAStyleSheet()
|
||||
#ifndef NECKO
|
||||
rv = NS_NewURL(&uaURL, nsString(UA_CSS_URL)); // XXX this bites, fix it
|
||||
#else
|
||||
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIURI *uri = nsnull;
|
||||
rv = service->NewURI(UA_CSS_URL, nsnull, &uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = uri->QueryInterface(nsIURI::GetIID(), (void**)&uaURL);
|
||||
NS_RELEASE(uri);
|
||||
rv = NS_NewURI(&uaURL, UA_CSS_URL); // XXX this bites, fix it
|
||||
#endif // NECKO
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsICSSLoader* cssLoader;
|
||||
|
@ -258,9 +258,20 @@ nsrefcnt nsHTMLDocument::Release()
|
||||
}
|
||||
|
||||
nsresult
|
||||
#ifdef NECKO
|
||||
nsHTMLDocument::Reset(nsIChannel* aChannel)
|
||||
#else
|
||||
nsHTMLDocument::Reset(nsIURI *aURL)
|
||||
#endif
|
||||
{
|
||||
#ifdef NECKO
|
||||
nsresult result = nsDocument::Reset(aChannel);
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
result = aChannel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(result)) return result;
|
||||
#else
|
||||
nsresult result = nsDocument::Reset(aURL);
|
||||
#endif
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
@ -331,21 +342,35 @@ nsHTMLDocument::CreateShell(nsIPresContext* aContext,
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTMLDocument::StartDocumentLoad(nsIURI *aURL,
|
||||
nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aURL,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aURL,
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
||||
#ifdef NECKO
|
||||
aChannel,
|
||||
#else
|
||||
aURL,
|
||||
#endif
|
||||
aContainer,
|
||||
aDocListener,
|
||||
aCommand);
|
||||
aDocListener);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIWebShell* webShell;
|
||||
|
||||
#ifdef NECKO
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
rv = aChannel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
@ -1413,7 +1438,11 @@ nsHTMLDocument::OpenCommon(nsIURI* aSourceURL)
|
||||
// The open occurred after the document finished loading.
|
||||
// So we reset the document and create a new one.
|
||||
if (nsnull == mParser) {
|
||||
#ifdef NECKO
|
||||
// XXX help!
|
||||
#else
|
||||
result = Reset(aSourceURL);
|
||||
#endif
|
||||
if (NS_OK == result) {
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
@ -59,10 +59,14 @@ public:
|
||||
nsIStyleSet* aStyleSet,
|
||||
nsIPresShell** aInstancePtrResult);
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI* aUrl,
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener** aDocListener,
|
||||
const char* aCommand);
|
||||
nsIStreamListener **aDocListener);
|
||||
|
||||
NS_IMETHOD EndLoad();
|
||||
|
||||
@ -182,7 +186,11 @@ protected:
|
||||
PRBool GetBodyContent();
|
||||
nsresult GetBodyElement(nsIDOMHTMLBodyElement** aBody);
|
||||
|
||||
#ifdef NECKO
|
||||
virtual nsresult Reset(nsIChannel* aChannel);
|
||||
#else
|
||||
virtual nsresult Reset(nsIURI *aURL);
|
||||
#endif
|
||||
nsresult WriteCommon(const nsString& aText,
|
||||
PRBool aNewlineTerminate);
|
||||
nsresult ScriptWriteCommon(JSContext *cx,
|
||||
|
@ -57,10 +57,14 @@ public:
|
||||
nsImageDocument();
|
||||
virtual ~nsImageDocument();
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI* aURL,
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener** aDocListener,
|
||||
const char* aCommand);
|
||||
nsIStreamListener **aDocListener);
|
||||
|
||||
nsresult CreateSyntheticDocument();
|
||||
|
||||
@ -247,15 +251,23 @@ nsImageDocument::~nsImageDocument()
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsImageDocument::StartDocumentLoad(nsIURI* aURL,
|
||||
nsImageDocument::StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aURL,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener** aDocListener,
|
||||
const char* aCommand)
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aURL,
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
||||
#ifdef NECKO
|
||||
aChannel,
|
||||
#else
|
||||
aURL,
|
||||
#endif
|
||||
aContainer,
|
||||
aDocListener,
|
||||
aCommand);
|
||||
aDocListener);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
@ -537,20 +537,14 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame)
|
||||
href.Append(data);
|
||||
}
|
||||
nsAutoString absURLSpec;
|
||||
nsAutoString base;
|
||||
#ifndef NECKO
|
||||
NS_MakeAbsoluteURL(docURL, base, href, absURLSpec);
|
||||
nsAutoString base;
|
||||
result = NS_MakeAbsoluteURL(docURL, base, href, absURLSpec);
|
||||
#else
|
||||
|
||||
nsIURI *baseUri = nsnull;
|
||||
result = docURL->QueryInterface(nsIURI::GetIID(), (void**)&baseUri);
|
||||
if (NS_FAILED(result)) return result;
|
||||
|
||||
NS_MakeAbsoluteURI(href, baseUri, absURLSpec);
|
||||
|
||||
NS_RELEASE(baseUri);
|
||||
result = NS_MakeAbsoluteURI(href, docURL, absURLSpec);
|
||||
#endif // NECKO
|
||||
NS_IF_RELEASE(docURL);
|
||||
if (NS_FAILED(result)) return result;
|
||||
|
||||
// Now pass on absolute url to the click handler
|
||||
nsIPostData* postData = nsnull;
|
||||
|
@ -1282,11 +1282,13 @@ CSSLoaderImpl::LoadAgentSheet(nsIURI* aURL,
|
||||
if (urlClone) {
|
||||
#endif
|
||||
#ifdef NECKO
|
||||
#if 0
|
||||
nsILoadGroup* loadGroup = nsnull;
|
||||
if (mDocument) {
|
||||
loadGroup = mDocument->GetDocumentLoadGroup();
|
||||
}
|
||||
result = NS_OpenURI(&in, urlClone, loadGroup);
|
||||
#endif
|
||||
result = NS_OpenURI(&in, urlClone/*, loadGroup*/);
|
||||
#else
|
||||
result = NS_OpenURL(urlClone, &in);
|
||||
#endif
|
||||
|
@ -171,10 +171,14 @@ void testStrings(nsIDocument* aDoc) {
|
||||
class MyDocument : public nsMarkupDocument {
|
||||
public:
|
||||
MyDocument();
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI *aUrl,
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ int main(int argc, char** argv)
|
||||
#ifndef NECKO
|
||||
rv = NS_OpenURL(url, &in);
|
||||
#else
|
||||
rv = NS_OpenURI(&in, url, nsnull);
|
||||
rv = NS_OpenURI(&in, url);
|
||||
#endif // NECKO
|
||||
if (rv != NS_OK) {
|
||||
printf("open of url('%s') failed: error=%x\n", urlName, rv);
|
||||
|
@ -63,7 +63,7 @@ int main(int argc, char** argv)
|
||||
#ifndef NECKO
|
||||
rv = NS_OpenURL(url, &in);
|
||||
#else
|
||||
rv = NS_OpenURI(&in, url, nsnull);
|
||||
rv = NS_OpenURI(&in, url);
|
||||
#endif // NECKO
|
||||
if (rv != NS_OK) {
|
||||
printf("open of url('%s') failed: error=%x\n", urlName, rv);
|
||||
|
@ -39,10 +39,14 @@ static NS_DEFINE_IID(kIContentDelegateIID, NS_ICONTENTDELEGATE_IID);
|
||||
class MyDocument : public nsDocument {
|
||||
public:
|
||||
MyDocument();
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI *aUrl,
|
||||
nsIWebShell* aShell,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -1282,11 +1282,13 @@ CSSLoaderImpl::LoadAgentSheet(nsIURI* aURL,
|
||||
if (urlClone) {
|
||||
#endif
|
||||
#ifdef NECKO
|
||||
#if 0
|
||||
nsILoadGroup* loadGroup = nsnull;
|
||||
if (mDocument) {
|
||||
loadGroup = mDocument->GetDocumentLoadGroup();
|
||||
}
|
||||
result = NS_OpenURI(&in, urlClone, loadGroup);
|
||||
#endif
|
||||
result = NS_OpenURI(&in, urlClone/*, loadGroup*/);
|
||||
#else
|
||||
result = NS_OpenURL(urlClone, &in);
|
||||
#endif
|
||||
|
@ -43,6 +43,10 @@
|
||||
#include "nsExpatDTD.h"
|
||||
#include "nsINameSpaceManager.h"
|
||||
#include "nsICSSLoader.h"
|
||||
#ifdef NECKO
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIURI.h"
|
||||
#endif
|
||||
|
||||
// XXX The XML world depends on the html atoms
|
||||
#include "nsHTMLAtoms.h"
|
||||
@ -150,9 +154,20 @@ nsrefcnt nsXMLDocument::Release()
|
||||
}
|
||||
|
||||
nsresult
|
||||
#ifdef NECKO
|
||||
nsXMLDocument::Reset(nsIChannel* aChannel)
|
||||
#else
|
||||
nsXMLDocument::Reset(nsIURI* aURL)
|
||||
#endif
|
||||
{
|
||||
#ifdef NECKO
|
||||
nsresult result = nsDocument::Reset(aChannel);
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
result = aChannel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(result)) return result;
|
||||
#else
|
||||
nsresult result = nsDocument::Reset(aURL);
|
||||
#endif
|
||||
if (NS_FAILED(result)) {
|
||||
return result;
|
||||
}
|
||||
@ -188,21 +203,35 @@ nsXMLDocument::GetContentType(nsString& aContentType) const
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXMLDocument::StartDocumentLoad(nsIURI *aUrl,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
nsXMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aUrl,
|
||||
nsresult rv = nsDocument::StartDocumentLoad(aCommand,
|
||||
#ifdef NECKO
|
||||
aChannel,
|
||||
#else
|
||||
aUrl,
|
||||
#endif
|
||||
aContainer,
|
||||
aDocListener,
|
||||
aCommand);
|
||||
aDocListener);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIWebShell* webShell;
|
||||
|
||||
#ifdef NECKO
|
||||
nsCOMPtr<nsIURI> aUrl;
|
||||
rv = aChannel->GetURI(getter_AddRefs(aUrl));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kCParserIID, NS_IPARSER_IID);
|
||||
static NS_DEFINE_IID(kCParserCID, NS_PARSER_IID);
|
||||
|
||||
|
@ -47,10 +47,14 @@ public:
|
||||
|
||||
NS_IMETHOD GetContentType(nsString& aContentType) const;
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI *aUrl,
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand);
|
||||
nsIStreamListener **aDocListener);
|
||||
|
||||
NS_IMETHOD EndLoad();
|
||||
|
||||
@ -79,7 +83,11 @@ public:
|
||||
protected:
|
||||
virtual void InternalAddStyleSheet(nsIStyleSheet* aSheet); // subclass hook for sheet ordering
|
||||
virtual void InternalInsertStyleSheetAt(nsIStyleSheet* aSheet, PRInt32 aIndex);
|
||||
#ifdef NECKO
|
||||
virtual nsresult Reset(nsIChannel* aChannel);
|
||||
#else
|
||||
virtual nsresult Reset(nsIURI* aUrl);
|
||||
#endif
|
||||
|
||||
// For HTML elements in our content model
|
||||
nsIHTMLStyleSheet* mAttrStyleSheet;
|
||||
|
@ -23,6 +23,7 @@ interface nsIInputStream;
|
||||
interface nsIOutputStream;
|
||||
interface nsIStreamObserver;
|
||||
interface nsIStreamListener;
|
||||
interface nsILoadGroup;
|
||||
|
||||
typedef unsigned long nsLoadFlags;
|
||||
|
||||
@ -69,7 +70,8 @@ interface nsIChannel : nsIRequest
|
||||
void AsyncRead(in unsigned long startPosition,
|
||||
in long readCount,
|
||||
in nsISupports ctxt,
|
||||
in nsIStreamListener listener);
|
||||
in nsIStreamListener listener,
|
||||
in nsILoadGroup group);
|
||||
|
||||
/**
|
||||
* Writes asynchronously to the URL's specified destination. Notifications
|
||||
@ -84,7 +86,8 @@ interface nsIChannel : nsIRequest
|
||||
in unsigned long startPosition,
|
||||
in long writeCount,
|
||||
in nsISupports ctxt,
|
||||
in nsIStreamObserver observer);
|
||||
in nsIStreamObserver observer,
|
||||
in nsILoadGroup group);
|
||||
|
||||
/**
|
||||
* Load attribute flags. These may be or'd together.
|
||||
@ -94,13 +97,17 @@ interface nsIChannel : nsIRequest
|
||||
* overlap. Otherwise, users won't be able to create a single flag word
|
||||
* of load attributes that applies to a number of different channel types.
|
||||
*/
|
||||
const unsigned long LOAD_NORMAL = 0; /* no special load attributes -- use defaults */
|
||||
const unsigned long LOAD_QUIET = 1 << 0; /* don't deliver status notifications to the nsIProgressEventSink */
|
||||
const unsigned long LOAD_NORMAL = 0; /* no special load attributes -- use defaults */
|
||||
const unsigned long LOAD_BACKGROUND = 1 << 0; /* don't deliver status notifications to the
|
||||
* nsIProgressEventSink, or keep this load from
|
||||
* completing the nsILoadGroup it may belong to */
|
||||
|
||||
/**
|
||||
* Accesses the load attributes for the channel. E.g. setting the load
|
||||
* attributes with the LOAD_QUIET bit set causes the loading process to
|
||||
* not deliver status notifications to the program performing the load.
|
||||
* not deliver status notifications to the program performing the load,
|
||||
* and to not contribute to keeping any nsILoadGroup it may be contained
|
||||
* in from firing its OnLoadComplete notification.
|
||||
*/
|
||||
attribute nsLoadFlags LoadAttributes;
|
||||
|
||||
@ -111,5 +118,11 @@ interface nsIChannel : nsIRequest
|
||||
* most likely wants to verify with the actual data.
|
||||
*/
|
||||
readonly attribute string ContentType;
|
||||
|
||||
/**
|
||||
* Returns the load group in which the channel is a currently a member.
|
||||
*/
|
||||
readonly attribute nsILoadGroup LoadGroup;
|
||||
|
||||
};
|
||||
|
||||
|
@ -139,8 +139,9 @@ interface nsIIOService : nsISupports
|
||||
* their use is not required by other parts of the system, they are primarily
|
||||
* a convenience for the caller. The outer parameter can be used for aggregation.
|
||||
*/
|
||||
nsILoadGroup NewLoadGroup(in nsILoadGroup parent,
|
||||
in nsISupports outer);
|
||||
nsILoadGroup NewLoadGroup(in nsISupports outer,
|
||||
in nsIStreamObserver observer,
|
||||
in nsILoadGroup parent);
|
||||
|
||||
/**
|
||||
* Returns a simple channel implementation that uses the given input
|
||||
|
@ -30,6 +30,9 @@ interface nsIInputStream;
|
||||
[scriptable, uuid(19845248-29ab-11d3-8cce-0060b0fc14a3)]
|
||||
interface nsILoadGroup : nsIRequest
|
||||
{
|
||||
void Init(in nsIStreamObserver observer,
|
||||
in nsILoadGroup parent);
|
||||
|
||||
/**
|
||||
* Accesses the default load attributes for the group, returned as
|
||||
* a flag word. Setting the default load attributes will cause them
|
||||
@ -38,27 +41,23 @@ interface nsILoadGroup : nsIRequest
|
||||
attribute unsigned long DefaultLoadAttributes;
|
||||
|
||||
/**
|
||||
* Adds the channel to the group, and performs and AsyncRead on the
|
||||
* channel (see nsIChannel for details). The channel is automatically
|
||||
* removed from the group when the async operation completes.
|
||||
* Adds a new channel to the group. This will cause the default load
|
||||
* attributes to be applied to that channel. If the channel added is
|
||||
* the first channel in the group, the group's observer's OnStartRequest
|
||||
* method is called.
|
||||
*/
|
||||
void AsyncRead(in nsIChannel channel,
|
||||
in unsigned long startPosition,
|
||||
in long readCount,
|
||||
in nsISupports ctxt,
|
||||
in nsIStreamListener listener);
|
||||
void AddChannel(in nsIChannel channel,
|
||||
in nsISupports ctxt);
|
||||
|
||||
/**
|
||||
* Adds the channel to the group, and performs and AsyncWrite on the
|
||||
* channel (see nsIChannel for details). The channel is automatically
|
||||
* removed from the group when the async operation completes.
|
||||
* Removes a channel from the group. If the channel removed is
|
||||
* the last channel in the group, the group's observer's OnStopRequest
|
||||
* method is called.
|
||||
*/
|
||||
void AsyncWrite(in nsIChannel channel,
|
||||
in nsIInputStream fromStream,
|
||||
in unsigned long startPosition,
|
||||
in long writeCount,
|
||||
in nsISupports ctxt,
|
||||
in nsIStreamObserver observer);
|
||||
void RemoveChannel(in nsIChannel channel,
|
||||
in nsISupports ctxt,
|
||||
in nsresult status,
|
||||
in wstring errorMsg);
|
||||
|
||||
/**
|
||||
* Returns the channels contained directly in this group.
|
||||
@ -66,23 +65,6 @@ interface nsILoadGroup : nsIRequest
|
||||
*/
|
||||
readonly attribute nsISimpleEnumerator Channels;
|
||||
|
||||
/**
|
||||
* Adds an observer to the group. The observer's methods will be
|
||||
* called for each channel in the group.
|
||||
*/
|
||||
void AddObserver(in nsIStreamObserver observer);
|
||||
|
||||
/**
|
||||
* Removes an observer from the group.
|
||||
*/
|
||||
void RemoveObserver(in nsIStreamObserver observer);
|
||||
|
||||
/**
|
||||
* Returns the observers contained directly in this group.
|
||||
* Enumerator element type: nsIStreamObserver.
|
||||
*/
|
||||
readonly attribute nsISimpleEnumerator Observers;
|
||||
|
||||
/**
|
||||
* Adds a new sub-group to the group.
|
||||
*/
|
||||
|
@ -38,6 +38,10 @@
|
||||
* | PreHost
|
||||
* Scheme
|
||||
*
|
||||
* The subclass nsIURL provides a means to open an input or output
|
||||
* stream to a URI as a source/destination, as well as providing additional
|
||||
* accessors to destructure the path, query and reference portions typically
|
||||
* associated with URLs.
|
||||
*/
|
||||
|
||||
%{C++
|
||||
@ -135,9 +139,9 @@ interface nsIURI : nsISupports
|
||||
* *** What you most likely will want is NS_STANDARDURL_CID which is much more
|
||||
* full featured. Look at nsIURL.idl for more details.
|
||||
*/
|
||||
|
||||
#define NS_SIMPLEURI_CID \
|
||||
{ /* e0da1d70-2f7b-11d3-8cd0-0060b0fc14a3 */ \
|
||||
|
||||
#define NS_SIMPLEURI_CID \
|
||||
{ /* e0da1d70-2f7b-11d3-8cd0-0060b0fc14a3 */ \
|
||||
0xe0da1d70, \
|
||||
0x2f7b, \
|
||||
0x11d3, \
|
||||
|
@ -180,7 +180,8 @@ nsAsyncStreamObserver::~nsAsyncStreamObserver()
|
||||
NS_IF_RELEASE(mEventQueue);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsAsyncStreamObserver, nsCOMTypeInfo<nsIStreamObserver>::GetIID());
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS(nsAsyncStreamObserver,
|
||||
nsCOMTypeInfo<nsIStreamObserver>::GetIID());
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED(nsAsyncStreamListener,
|
||||
nsAsyncStreamObserver,
|
||||
|
@ -328,8 +328,8 @@ nsIOService::NewChannelFromNativePath(const char *nativePath, nsIFileChannel **r
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsIOService::NewLoadGroup(nsILoadGroup* parent, nsISupports* outer,
|
||||
nsILoadGroup **result)
|
||||
nsIOService::NewLoadGroup(nsISupports* outer, nsIStreamObserver* observer,
|
||||
nsILoadGroup* parent, nsILoadGroup **result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsILoadGroup* group;
|
||||
@ -337,12 +337,10 @@ nsIOService::NewLoadGroup(nsILoadGroup* parent, nsISupports* outer,
|
||||
(void**)&group);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (parent) {
|
||||
rv = parent->AddSubGroup(group);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(group);
|
||||
return rv;
|
||||
}
|
||||
rv = group->Init(observer, parent);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(group);
|
||||
return rv;
|
||||
}
|
||||
|
||||
*result = group;
|
||||
|
@ -52,7 +52,7 @@ public:
|
||||
NS_IMETHOD NewAsyncStreamListener(nsIStreamListener *receiver, nsIEventQueue *eventQueue, nsIStreamListener **_retval);
|
||||
NS_IMETHOD NewSyncStreamListener(nsIInputStream **inStream, nsIBufferOutputStream **outStream, nsIStreamListener **_retval);
|
||||
NS_IMETHOD NewChannelFromNativePath(const char *nativePath, nsIFileChannel **_retval);
|
||||
NS_IMETHOD NewLoadGroup(nsILoadGroup* parent, nsISupports* outer, nsILoadGroup **result);
|
||||
NS_IMETHOD NewLoadGroup(nsISupports* outer, nsIStreamObserver* observer, nsILoadGroup* parent, nsILoadGroup **result);
|
||||
NS_IMETHOD NewInputStreamChannel(nsIURI* uri, const char *contentType, nsIInputStream *inStr, nsIChannel **result);
|
||||
|
||||
// nsIOService methods:
|
||||
|
@ -18,13 +18,14 @@
|
||||
|
||||
#include "nsInputStreamChannel.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsInputStreamChannel methods:
|
||||
|
||||
nsInputStreamChannel::nsInputStreamChannel()
|
||||
: mURI(nsnull), mContentType(nsnull), mInputStream(nsnull)
|
||||
: mURI(nsnull), mContentType(nsnull), mInputStream(nsnull), mLoadGroup(nsnull)
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
@ -123,7 +124,8 @@ nsInputStreamChannel::OpenOutputStream(PRUint32 startPosition, nsIOutputStream *
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
nsISupports *ctxt, nsIStreamListener *listener)
|
||||
nsISupports *ctxt, nsIStreamListener *listener,
|
||||
nsILoadGroup* group)
|
||||
{
|
||||
// currently this happens before AsyncRead returns -- hope that's ok
|
||||
nsresult rv;
|
||||
@ -132,6 +134,14 @@ nsInputStreamChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
// the listener prematurely.
|
||||
nsCOMPtr<nsIStreamListener> l(listener);
|
||||
|
||||
NS_ASSERTION(mLoadGroup == nsnull, "recursively entered AsyncRead?");
|
||||
mLoadGroup = group;
|
||||
NS_ADDREF(mLoadGroup);
|
||||
|
||||
if (group) {
|
||||
(void)group->AddChannel(this, ctxt);
|
||||
}
|
||||
|
||||
rv = listener->OnStartRequest(this, ctxt);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
@ -151,16 +161,20 @@ nsInputStreamChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
if (NS_FAILED(rv)) break;
|
||||
}
|
||||
|
||||
rv = listener->OnStopRequest(this, ctxt, rv, nsnull); // XXX error message
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = listener->OnStopRequest(this, ctxt, rv, nsnull); // XXX error message
|
||||
|
||||
if (group) {
|
||||
(void)group->RemoveChannel(this, ctxt, rv, nsnull); // XXX error message
|
||||
}
|
||||
NS_RELEASE(mLoadGroup);
|
||||
|
||||
return NS_OK;
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::AsyncWrite(nsIInputStream *fromStream, PRUint32 startPosition,
|
||||
PRInt32 writeCount, nsISupports *ctxt,
|
||||
nsIStreamObserver *observer)
|
||||
nsIStreamObserver *observer, nsILoadGroup* group)
|
||||
{
|
||||
// we don't do output
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -187,4 +201,12 @@ nsInputStreamChannel::GetContentType(char * *aContentType)
|
||||
return *aContentType ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsInputStreamChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -41,13 +41,15 @@ public:
|
||||
nsIInputStream **_retval);
|
||||
NS_IMETHOD OpenOutputStream(PRUint32 startPosition, nsIOutputStream **_retval);
|
||||
NS_IMETHOD AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
nsISupports *ctxt, nsIStreamListener *listener);
|
||||
nsISupports *ctxt, nsIStreamListener *listener,
|
||||
nsILoadGroup* group);
|
||||
NS_IMETHOD AsyncWrite(nsIInputStream *fromStream, PRUint32 startPosition,
|
||||
PRInt32 writeCount, nsISupports *ctxt,
|
||||
nsIStreamObserver *observer);
|
||||
nsIStreamObserver *observer, nsILoadGroup* group);
|
||||
NS_IMETHOD GetLoadAttributes(nsLoadFlags *aLoadAttributes);
|
||||
NS_IMETHOD SetLoadAttributes(nsLoadFlags aLoadAttributes);
|
||||
NS_IMETHOD GetContentType(char * *aContentType);
|
||||
NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup);
|
||||
|
||||
// nsInputStreamChannel methods:
|
||||
nsInputStreamChannel();
|
||||
@ -62,6 +64,7 @@ protected:
|
||||
nsIURI* mURI;
|
||||
char* mContentType;
|
||||
nsIInputStream* mInputStream;
|
||||
nsILoadGroup* mLoadGroup;
|
||||
};
|
||||
|
||||
#define NS_INPUTSTREAMCHANNEL_CID \
|
||||
|
@ -17,150 +17,23 @@
|
||||
*/
|
||||
|
||||
#include "nsLoadGroup.h"
|
||||
#include "nsIIOService.h"
|
||||
#include "nsIStreamObserver.h"
|
||||
#include "nsIChannel.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupportsArray.h"
|
||||
#include "nsEnumeratorUtils.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
static NS_DEFINE_CID(kLoadGroupCID, NS_LOADGROUP_CID);
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class nsLoadGroupEntry : public nsIStreamListener
|
||||
{
|
||||
protected:
|
||||
typedef nsresult (*PropagateUpFun)(nsIStreamObserver* obs, void* closure);
|
||||
|
||||
nsresult PropagateUp(PropagateUpFun fun, void* closure) {
|
||||
nsresult rv;
|
||||
PRUint32 i;
|
||||
|
||||
for (nsLoadGroup* group = mGroup; group != nsnull; group = group->mParent) {
|
||||
PRUint32 count = 0;
|
||||
if (group->mObservers) {
|
||||
rv = group->mObservers->Count(&count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
for (i = 0; i < count; i++) {
|
||||
nsIStreamObserver* obs =
|
||||
NS_STATIC_CAST(nsIStreamObserver*, group->mObservers->ElementAt(i));
|
||||
if (obs == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
rv = fun(obs, closure);
|
||||
NS_RELEASE(obs);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
struct OnStartRequestArgs {
|
||||
nsIChannel* channel;
|
||||
nsISupports* context;
|
||||
};
|
||||
|
||||
static nsresult
|
||||
OnStartRequestFun(nsIStreamObserver* obs, void* closure) {
|
||||
OnStartRequestArgs* args = (OnStartRequestArgs*)closure;
|
||||
return obs->OnStartRequest(args->channel, args->context);
|
||||
}
|
||||
|
||||
struct OnStopRequestArgs {
|
||||
nsIChannel* channel;
|
||||
nsISupports* ctxt;
|
||||
nsresult status;
|
||||
const PRUnichar* errorMsg;
|
||||
};
|
||||
|
||||
static nsresult
|
||||
OnStopRequestFun(nsIStreamObserver* obs, void* closure) {
|
||||
OnStopRequestArgs* args = (OnStopRequestArgs*)closure;
|
||||
return obs->OnStopRequest(args->channel, args->ctxt,
|
||||
args->status, args->errorMsg);
|
||||
}
|
||||
|
||||
struct OnDataAvailableArgs {
|
||||
nsIChannel* channel;
|
||||
nsISupports* ctxt;
|
||||
nsIInputStream *inStr;
|
||||
PRUint32 sourceOffset;
|
||||
PRUint32 count;
|
||||
};
|
||||
|
||||
static nsresult
|
||||
OnDataAvailableFun(nsIStreamObserver* obs, void* closure) {
|
||||
OnDataAvailableArgs* args = (OnDataAvailableArgs*)closure;
|
||||
nsIStreamListener* l = NS_STATIC_CAST(nsIStreamListener*, obs);
|
||||
return l->OnDataAvailable(args->channel, args->ctxt, args->inStr,
|
||||
args->sourceOffset, args->count);
|
||||
}
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIStreamObserver methods:
|
||||
NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt) {
|
||||
OnStartRequestArgs args;
|
||||
args.channel = channel;
|
||||
args.context = ctxt;
|
||||
return PropagateUp(OnStartRequestFun, &args);
|
||||
}
|
||||
|
||||
NS_IMETHOD OnStopRequest(nsIChannel* channel, nsISupports *ctxt, nsresult status,
|
||||
const PRUnichar *errorMsg) {
|
||||
OnStopRequestArgs args;
|
||||
args.channel = channel;
|
||||
args.ctxt = ctxt;
|
||||
args.status = status;
|
||||
args.errorMsg = errorMsg;
|
||||
return PropagateUp(OnStartRequestFun, &args);
|
||||
}
|
||||
|
||||
// nsIStreamListener methods:
|
||||
NS_IMETHOD OnDataAvailable(nsIChannel* channel, nsISupports *ctxt, nsIInputStream *inStr,
|
||||
PRUint32 sourceOffset, PRUint32 count) {
|
||||
OnDataAvailableArgs args;
|
||||
args.channel = channel;
|
||||
args.ctxt = ctxt;
|
||||
args.inStr = inStr;
|
||||
args.sourceOffset = sourceOffset;
|
||||
args.count = count;
|
||||
return PropagateUp(OnDataAvailableFun, &args);
|
||||
}
|
||||
|
||||
// nsLoadGroupEntry methods:
|
||||
nsLoadGroupEntry(nsLoadGroup* group, nsIChannel* channel, nsISupports* ctxt)
|
||||
: mGroup(group), mChannel(channel), mContext(ctxt) {
|
||||
NS_INIT_REFCNT();
|
||||
NS_ADDREF(mGroup);
|
||||
NS_ADDREF(mChannel);
|
||||
NS_IF_ADDREF(mContext);
|
||||
}
|
||||
|
||||
virtual ~nsLoadGroupEntry() {
|
||||
NS_RELEASE(mGroup);
|
||||
NS_RELEASE(mChannel);
|
||||
NS_IF_RELEASE(mContext);
|
||||
}
|
||||
|
||||
protected:
|
||||
nsLoadGroup* mGroup;
|
||||
nsIChannel* mChannel;
|
||||
nsISupports* mContext;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsLoadGroupEntry, nsCOMTypeInfo<nsIStreamListener>::GetIID());
|
||||
static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
nsLoadGroup::nsLoadGroup(nsISupports* outer)
|
||||
: mChannels(nsnull), mSubGroups(nsnull), mObservers(nsnull),
|
||||
: mChannels(nsnull), mSubGroups(nsnull),
|
||||
mDefaultLoadAttributes(nsIChannel::LOAD_NORMAL),
|
||||
mParent(nsnull), mObserver(nsnull)
|
||||
mObserver(nsnull), mParent(nsnull), mForegroundCount(0)
|
||||
{
|
||||
NS_INIT_AGGREGATED(outer);
|
||||
}
|
||||
@ -171,7 +44,6 @@ nsLoadGroup::~nsLoadGroup()
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "Cancel failed");
|
||||
NS_IF_RELEASE(mChannels);
|
||||
NS_IF_RELEASE(mSubGroups);
|
||||
NS_IF_RELEASE(mObservers);
|
||||
NS_IF_RELEASE(mObserver);
|
||||
NS_IF_RELEASE(mParent);
|
||||
}
|
||||
@ -219,9 +91,12 @@ nsLoadGroup::PropagateDown(PropagateDownFun fun)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
for (i = 0; i < count; i++) {
|
||||
nsIRequest* req = NS_STATIC_CAST(nsIRequest*, mChannels->ElementAt(i));
|
||||
// Operate the elements from back to front so that if items get
|
||||
// get removed from the list it won't affect our iteration
|
||||
nsIRequest* req =
|
||||
NS_STATIC_CAST(nsIRequest*, mChannels->ElementAt(count - 1 - i));
|
||||
if (req == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
continue;
|
||||
rv = fun(req);
|
||||
NS_RELEASE(req);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -233,9 +108,12 @@ nsLoadGroup::PropagateDown(PropagateDownFun fun)
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
for (i = 0; i < count; i++) {
|
||||
nsIRequest* req = NS_STATIC_CAST(nsIRequest*, mSubGroups->ElementAt(i));
|
||||
// Operate the elements from back to front so that if items get
|
||||
// get removed from the list it won't affect our iteration
|
||||
nsIRequest* req =
|
||||
NS_STATIC_CAST(nsIRequest*, mSubGroups->ElementAt(count - 1 - i));
|
||||
if (req == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
continue;
|
||||
rv = fun(req);
|
||||
NS_RELEASE(req);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -247,18 +125,14 @@ NS_IMETHODIMP
|
||||
nsLoadGroup::IsPending(PRBool *result)
|
||||
{
|
||||
nsresult rv;
|
||||
PRUint32 count = 0;
|
||||
if (mChannels) {
|
||||
rv = mChannels->Count(&count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
if (count > 0) {
|
||||
*result = PR_FALSE;
|
||||
if (mForegroundCount > 0) {
|
||||
*result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// else check whether any of our sub-groups are pending
|
||||
PRUint32 i;
|
||||
count = 0;
|
||||
PRUint32 count = 0;
|
||||
if (mSubGroups) {
|
||||
rv = mSubGroups->Count(&count);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
@ -266,18 +140,18 @@ nsLoadGroup::IsPending(PRBool *result)
|
||||
for (i = 0; i < count; i++) {
|
||||
nsIRequest* req = NS_STATIC_CAST(nsIRequest*, mSubGroups->ElementAt(i));
|
||||
if (req == nsnull)
|
||||
return NS_ERROR_FAILURE;
|
||||
continue;
|
||||
PRBool pending;
|
||||
rv = req->IsPending(&pending);
|
||||
NS_RELEASE(req);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (pending) {
|
||||
*result = PR_FALSE;
|
||||
*result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
*result = PR_TRUE;
|
||||
*result = PR_FALSE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -320,6 +194,36 @@ nsLoadGroup::Resume()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsILoadGroup methods:
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroup::Init(nsIStreamObserver *observer, nsILoadGroup *parent)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_IF_RELEASE(mObserver);
|
||||
if (observer) {
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueService, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = eventQService->GetThreadEventQueue(PR_CurrentThread(),
|
||||
getter_AddRefs(eventQueue));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIStreamObserver> asyncObserver;
|
||||
rv = NS_NewAsyncStreamObserver(getter_AddRefs(asyncObserver),
|
||||
eventQueue, observer);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
mObserver = asyncObserver;
|
||||
NS_ADDREF(mObserver);
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
rv = parent->AddSubGroup(this);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroup::GetDefaultLoadAttributes(PRUint32 *aDefaultLoadAttributes)
|
||||
{
|
||||
@ -335,49 +239,61 @@ nsLoadGroup::SetDefaultLoadAttributes(PRUint32 aDefaultLoadAttributes)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroup::AsyncRead(nsIChannel *channel,
|
||||
PRUint32 startPosition,
|
||||
PRInt32 readCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamListener *listener)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroup::AsyncWrite(nsIChannel *channel,
|
||||
nsIInputStream *fromStream,
|
||||
PRUint32 startPosition,
|
||||
PRInt32 writeCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamObserver *observer)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#if 0
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroup::AddChannel(nsIChannel *channel)
|
||||
nsLoadGroup::AddChannel(nsIChannel *channel, nsISupports* ctxt)
|
||||
{
|
||||
nsresult rv;
|
||||
if (mChannels == nsnull) {
|
||||
rv = NS_NewISupportsArray(&mChannels);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
rv = mChannels->AppendElement(channel);
|
||||
rv = mChannels->AppendElement(channel) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->SetLoadAttributes(mDefaultLoadAttributes);
|
||||
return NS_OK;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsLoadFlags flags;
|
||||
rv = channel->GetLoadAttributes(&flags);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (!(flags & nsIChannel::LOAD_BACKGROUND)) {
|
||||
mForegroundCount++;
|
||||
if (mForegroundCount == 1 && mObserver) {
|
||||
rv = mObserver->OnStartRequest(channel, ctxt);
|
||||
// return with rv, below
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroup::RemoveChannel(nsIChannel *channel)
|
||||
nsLoadGroup::RemoveChannel(nsIChannel *channel, nsISupports* ctxt,
|
||||
nsresult status, const PRUnichar *errorMsg)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_ASSERTION(mChannels, "Forgot to call AddChannel");
|
||||
return mChannels->RemoveElement(channel);
|
||||
|
||||
nsLoadFlags flags;
|
||||
rv = channel->GetLoadAttributes(&flags);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (!(flags & nsIChannel::LOAD_BACKGROUND)) {
|
||||
NS_ASSERTION(mForegroundCount > 0, "mForegroundCount messed up");
|
||||
--mForegroundCount;
|
||||
if (mObserver) {
|
||||
PRBool pending;
|
||||
rv = IsPending(&pending);
|
||||
if (NS_SUCCEEDED(rv) && !pending) {
|
||||
rv = mObserver->OnStopRequest(channel, ctxt, status, errorMsg);
|
||||
// return with rv, below
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv2 = mChannels->RemoveElement(channel) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool
|
||||
return rv || rv2;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroup::GetChannels(nsISimpleEnumerator * *aChannels)
|
||||
@ -390,35 +306,6 @@ nsLoadGroup::GetChannels(nsISimpleEnumerator * *aChannels)
|
||||
return NS_NewArrayEnumerator(aChannels, mChannels);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroup::AddObserver(nsIStreamObserver *observer)
|
||||
{
|
||||
nsresult rv;
|
||||
if (mObservers == nsnull) {
|
||||
rv = NS_NewISupportsArray(&mObservers);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return mObservers->AppendElement(observer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroup::RemoveObserver(nsIStreamObserver *observer)
|
||||
{
|
||||
NS_ASSERTION(mObservers, "Forgot to call AddObserver");
|
||||
return mObservers->RemoveElement(observer);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroup::GetObservers(nsISimpleEnumerator * *aObservers)
|
||||
{
|
||||
nsresult rv;
|
||||
if (mObservers == nsnull) {
|
||||
rv = NS_NewISupportsArray(&mObservers);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return NS_NewArrayEnumerator(aObservers, mObservers);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLoadGroup::AddSubGroup(nsILoadGroup *group)
|
||||
{
|
||||
@ -435,7 +322,7 @@ nsLoadGroup::AddSubGroup(nsILoadGroup *group)
|
||||
rv = NS_NewISupportsArray(&mSubGroups);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
return mSubGroups->AppendElement(group);
|
||||
return mSubGroups->AppendElement(group) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
@ -452,7 +339,7 @@ nsLoadGroup::RemoveSubGroup(nsILoadGroup *group)
|
||||
subGroup->mParent = nsnull; // weak ref -- don't Release
|
||||
NS_RELEASE(subGroup);
|
||||
|
||||
return mSubGroups->RemoveElement(group);
|
||||
return mSubGroups->RemoveElement(group) ? NS_OK : NS_ERROR_FAILURE; // XXX this method incorrectly returns a bool
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "nsAgg.h"
|
||||
|
||||
class nsISupportsArray;
|
||||
class nsLoadGroupEntry;
|
||||
|
||||
class nsLoadGroup : public nsILoadGroup
|
||||
{
|
||||
@ -48,37 +49,23 @@ public:
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsILoadGroup methods:
|
||||
|
||||
/* void Init (in nsIStreamObserver observer, in nsILoadGroup parent); */
|
||||
NS_IMETHOD Init(nsIStreamObserver *observer, nsILoadGroup *parent);
|
||||
|
||||
/* attribute unsigned long DefaultLoadAttributes; */
|
||||
NS_IMETHOD GetDefaultLoadAttributes(PRUint32 *aDefaultLoadAttributes);
|
||||
NS_IMETHOD SetDefaultLoadAttributes(PRUint32 aDefaultLoadAttributes);
|
||||
|
||||
/* void AsyncRead (in nsIChannel channel, in unsigned long startPosition, in long readCount, in nsISupports ctxt, in nsIStreamListener listener); */
|
||||
NS_IMETHOD AsyncRead(nsIChannel *channel,
|
||||
PRUint32 startPosition,
|
||||
PRInt32 readCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamListener *listener);
|
||||
/* void AddChannel (in nsIChannel channel, in nsISupports ctxt); */
|
||||
NS_IMETHOD AddChannel(nsIChannel *channel, nsISupports* ctxt);
|
||||
|
||||
/* void AsyncWrite (in nsIChannel channel, in nsIInputStream fromStream, in unsigned long startPosition, in long writeCount, in nsISupports ctxt, in nsIStreamObserver observer); */
|
||||
NS_IMETHOD AsyncWrite(nsIChannel *channel,
|
||||
nsIInputStream *fromStream,
|
||||
PRUint32 startPosition,
|
||||
PRInt32 writeCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamObserver *observer);
|
||||
/* void RemoveChannel (in nsIChannel channel, in nsISupports ctxt); */
|
||||
NS_IMETHOD RemoveChannel(nsIChannel *channel, nsISupports* ctxt,
|
||||
nsresult status, const PRUnichar *errorMsg);
|
||||
|
||||
/* readonly attribute nsISimpleEnumerator Channels; */
|
||||
NS_IMETHOD GetChannels(nsISimpleEnumerator * *aChannels);
|
||||
|
||||
/* void AddObserver (in nsIStreamObserver observer); */
|
||||
NS_IMETHOD AddObserver(nsIStreamObserver *observer);
|
||||
|
||||
/* void RemoveObserver (in nsIStreamObserver observer); */
|
||||
NS_IMETHOD RemoveObserver(nsIStreamObserver *observer);
|
||||
|
||||
/* readonly attribute nsISimpleEnumerator Observers; */
|
||||
NS_IMETHOD GetObservers(nsISimpleEnumerator * *aObservers);
|
||||
|
||||
/* void AddSubGroup (in nsILoadGroup group); */
|
||||
NS_IMETHOD AddSubGroup(nsILoadGroup *group);
|
||||
|
||||
@ -97,7 +84,7 @@ public:
|
||||
static NS_METHOD
|
||||
Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
|
||||
|
||||
friend class nsLoadGroupEntry;
|
||||
friend nsLoadGroupEntry;
|
||||
|
||||
protected:
|
||||
typedef nsresult (*PropagateDownFun)(nsIRequest* request);
|
||||
@ -106,10 +93,10 @@ protected:
|
||||
protected:
|
||||
PRUint32 mDefaultLoadAttributes;
|
||||
nsISupportsArray* mChannels;
|
||||
nsISupportsArray* mObservers;
|
||||
nsISupportsArray* mSubGroups;
|
||||
nsIStreamObserver* mObserver;
|
||||
nsLoadGroup* mParent; // weak ref
|
||||
nsIStreamObserver* mObserver; // might be an nsIStreamListener too
|
||||
PRUint32 mForegroundCount;
|
||||
};
|
||||
|
||||
#endif // nsLoadGroup_h__
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "nsSocketTransportService.h"
|
||||
#include "nsIBufferOutputStream.h"
|
||||
#include "nsAutoLock.h"
|
||||
#include "nsILoadGroup.h"
|
||||
|
||||
static NS_DEFINE_CID(kEventQueueService, NS_EVENTQUEUESERVICE_CID);
|
||||
|
||||
@ -1211,7 +1212,8 @@ nsSocketTransport::GetURI(nsIURI * *aURL)
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
nsISupports* aContext,
|
||||
nsIStreamListener* aListener)
|
||||
nsIStreamListener* aListener,
|
||||
nsILoadGroup* group)
|
||||
{
|
||||
// XXX deal with startPosition and readCount parameters
|
||||
nsresult rv = NS_OK;
|
||||
@ -1266,6 +1268,8 @@ nsSocketTransport::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
mOperation = eSocketOperation_ReadWrite;
|
||||
SetReadType(eSocketRead_Async);
|
||||
|
||||
mLoadGroup = group; // might be null
|
||||
|
||||
rv = mService->AddToWorkQ(this);
|
||||
}
|
||||
|
||||
@ -1281,7 +1285,8 @@ NS_IMETHODIMP
|
||||
nsSocketTransport::AsyncWrite(nsIInputStream* aFromStream,
|
||||
PRUint32 startPosition, PRInt32 writeCount,
|
||||
nsISupports* aContext,
|
||||
nsIStreamObserver* aObserver)
|
||||
nsIStreamObserver* aObserver,
|
||||
nsILoadGroup* group)
|
||||
{
|
||||
// XXX deal with startPosition and writeCount parameters
|
||||
nsresult rv = NS_OK;
|
||||
@ -1326,6 +1331,8 @@ nsSocketTransport::AsyncWrite(nsIInputStream* aFromStream,
|
||||
mOperation = eSocketOperation_ReadWrite;
|
||||
SetWriteType(eSocketWrite_Async);
|
||||
|
||||
mLoadGroup = group; // might be null
|
||||
|
||||
rv = mService->AddToWorkQ(this);
|
||||
}
|
||||
|
||||
@ -1471,3 +1478,10 @@ nsSocketTransport::GetContentType(char * *aContentType)
|
||||
return NS_ERROR_FAILURE; // XXX doesn't make sense for transports
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsSocketTransport::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -120,14 +120,17 @@ public:
|
||||
NS_IMETHOD OpenOutputStream(PRUint32 startPosition, nsIOutputStream **_retval);
|
||||
NS_IMETHOD AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamListener *listener);
|
||||
nsIStreamListener *listener,
|
||||
nsILoadGroup* group);
|
||||
NS_IMETHOD AsyncWrite(nsIInputStream *fromStream,
|
||||
PRUint32 startPosition, PRInt32 writeCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamObserver *observer);
|
||||
nsIStreamObserver *observer,
|
||||
nsILoadGroup* group);
|
||||
NS_IMETHOD GetLoadAttributes(PRUint32 *aLoadAttributes);
|
||||
NS_IMETHOD SetLoadAttributes(PRUint32 aLoadAttributes);
|
||||
NS_IMETHOD GetContentType(char * *aContentType);
|
||||
NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup);
|
||||
|
||||
// nsIBufferObserver methods:
|
||||
NS_IMETHOD OnFull (nsIBuffer* aBuffer);
|
||||
@ -219,6 +222,7 @@ protected:
|
||||
|
||||
nsSocketTransportService* mService;
|
||||
PRUint32 mLoadAttributes;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
};
|
||||
|
||||
|
||||
|
@ -37,6 +37,7 @@ nsAboutBlank::NewChannel(const char *verb,
|
||||
nsresult rv;
|
||||
nsIChannel* channel;
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsISupports* s;
|
||||
rv = NS_NewStringInputStream(&s, kBlankPage);
|
||||
|
@ -90,7 +90,7 @@ nsFileChannel::Init(nsFileProtocolHandler* handler,
|
||||
|
||||
mEventQueue = queue;
|
||||
NS_IF_ADDREF(mEventQueue);
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -407,7 +407,8 @@ nsFileChannel::OpenOutputStream(PRUint32 startPosition, nsIOutputStream **result
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamListener *listener)
|
||||
nsIStreamListener *listener,
|
||||
nsILoadGroup* group)
|
||||
{
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
|
||||
@ -446,6 +447,7 @@ nsFileChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
NS_ASSERTION(mContext == nsnull, "context not released");
|
||||
mContext = ctxt;
|
||||
NS_IF_ADDREF(mContext);
|
||||
mLoadGroup = group;
|
||||
|
||||
mState = START_READ;
|
||||
mSourceOffset = startPosition;
|
||||
@ -461,7 +463,8 @@ NS_IMETHODIMP
|
||||
nsFileChannel::AsyncWrite(nsIInputStream *fromStream,
|
||||
PRUint32 startPosition, PRInt32 writeCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamObserver *observer)
|
||||
nsIStreamObserver *observer,
|
||||
nsILoadGroup* group)
|
||||
{
|
||||
nsAutoMonitor mon(mMonitor);
|
||||
|
||||
@ -524,6 +527,14 @@ nsFileChannel::GetContentType(char * *aContentType)
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFileChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_IF_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIRunnable methods:
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@ -560,6 +571,8 @@ nsFileChannel::Process(void)
|
||||
NS_ASSERTION(mSourceOffset == 0, "implement seek");
|
||||
|
||||
if (mListener) {
|
||||
if (mLoadGroup)
|
||||
(void)mLoadGroup->AddChannel(this, mContext);
|
||||
mStatus = mListener->OnStartRequest(this, mContext); // always send the start notification
|
||||
if (NS_FAILED(mStatus)) goto error;
|
||||
}
|
||||
@ -644,6 +657,11 @@ nsFileChannel::Process(void)
|
||||
if (mListener) {
|
||||
// XXX where do we get the error message?
|
||||
(void)mListener->OnStopRequest(this, mContext, mStatus, nsnull);
|
||||
if (mLoadGroup) {
|
||||
(void)mLoadGroup->RemoveChannel(this, mContext, mStatus, nsnull);
|
||||
mLoadGroup = null_nsCOMPtr();
|
||||
}
|
||||
NS_RELEASE(mListener);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE(mBufferOutputStream);
|
||||
|
@ -25,6 +25,8 @@
|
||||
#include "prlock.h"
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIBuffer.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsIEventSinkGetter;
|
||||
class nsIStreamListener;
|
||||
@ -69,11 +71,11 @@ public:
|
||||
/* nsIOutputStream OpenOutputStream (); */
|
||||
NS_IMETHOD OpenOutputStream(PRUint32 startPosition, nsIOutputStream **_retval);
|
||||
|
||||
/* void AsyncRead (in unsigned long startPosition, in long readCount, in nsISupports ctxt, in nsIStreamListener listener); */
|
||||
NS_IMETHOD AsyncRead(PRUint32 startPosition, PRInt32 readCount, nsISupports *ctxt, nsIStreamListener *listener);
|
||||
/* void AsyncRead (in unsigned long startPosition, in long readCount, in nsISupports ctxt, in nsIStreamListener listener, in nsILoadGroup group); */
|
||||
NS_IMETHOD AsyncRead(PRUint32 startPosition, PRInt32 readCount, nsISupports *ctxt, nsIStreamListener *listener, nsILoadGroup *group);
|
||||
|
||||
/* void AsyncWrite (in nsIInputStream fromStream, in unsigned long startPosition, in long writeCount, in nsISupports ctxt, in nsIStreamObserver observer); */
|
||||
NS_IMETHOD AsyncWrite(nsIInputStream *fromStream, PRUint32 startPosition, PRInt32 writeCount, nsISupports *ctxt, nsIStreamObserver *observer);
|
||||
/* void AsyncWrite (in nsIInputStream fromStream, in unsigned long startPosition, in long writeCount, in nsISupports ctxt, in nsIStreamObserver observer, in nsILoadGroup group); */
|
||||
NS_IMETHOD AsyncWrite(nsIInputStream *fromStream, PRUint32 startPosition, PRInt32 writeCount, nsISupports *ctxt, nsIStreamObserver *observer, nsILoadGroup *group);
|
||||
|
||||
/* attribute boolean LoadQuiet; */
|
||||
NS_IMETHOD GetLoadAttributes(PRUint32 *aLoadAttributes);
|
||||
@ -82,6 +84,8 @@ public:
|
||||
/* readonly attribute string ContentType; */
|
||||
NS_IMETHOD GetContentType(char * *aContentType);
|
||||
|
||||
NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// from nsIFileChannel:
|
||||
|
||||
@ -199,6 +203,7 @@ protected:
|
||||
|
||||
PRMonitor* mMonitor;
|
||||
PRUint32 mLoadAttributes;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
};
|
||||
|
||||
#define NS_FILE_TRANSPORT_SEGMENT_SIZE (4*1024)
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "nsIEventQueueService.h"
|
||||
#include "nsIProgressEventSink.h"
|
||||
#include "nsIEventSinkGetter.h"
|
||||
#include "nsILoadGroup.h"
|
||||
|
||||
#include "prprf.h" // PR_sscanf
|
||||
|
||||
@ -176,7 +177,8 @@ nsFTPChannel::OpenOutputStream(PRUint32 startPosition, nsIOutputStream **_retval
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamListener *listener)
|
||||
nsIStreamListener *listener,
|
||||
nsILoadGroup* group)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@ -186,7 +188,8 @@ nsFTPChannel::AsyncWrite(nsIInputStream *fromStream,
|
||||
PRUint32 startPosition,
|
||||
PRInt32 writeCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamObserver *observer)
|
||||
nsIStreamObserver *observer,
|
||||
nsILoadGroup* group)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@ -213,6 +216,14 @@ nsFTPChannel::GetContentType(char* *contentType) {
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsFTPChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIFTPChannel methods:
|
||||
|
||||
|
@ -46,17 +46,21 @@ public:
|
||||
NS_IMETHOD GetURI(nsIURI * *aURL);
|
||||
NS_IMETHOD OpenInputStream(PRUint32 startPosition, PRInt32 readCount, nsIInputStream **_retval);
|
||||
NS_IMETHOD OpenOutputStream(PRUint32 startPosition, nsIOutputStream **_retval);
|
||||
NS_IMETHOD AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
NS_IMETHOD AsyncRead(PRUint32 startPosition,
|
||||
PRInt32 readCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamListener *listener);
|
||||
nsIStreamListener *listener,
|
||||
nsILoadGroup *group);
|
||||
NS_IMETHOD AsyncWrite(nsIInputStream *fromStream,
|
||||
PRUint32 startPosition,
|
||||
PRInt32 writeCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamObserver *observer);
|
||||
nsIStreamObserver *observer,
|
||||
nsILoadGroup *group);
|
||||
NS_IMETHOD GetLoadAttributes(PRUint32 *aLoadAttributes);
|
||||
NS_IMETHOD SetLoadAttributes(PRUint32 aLoadAttributes);
|
||||
NS_IMETHOD GetContentType(char * *aContentType);
|
||||
NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup);
|
||||
|
||||
// nsIFTPChannel methods:
|
||||
NS_IMETHOD Get(void);
|
||||
@ -94,6 +98,7 @@ protected:
|
||||
PRBool mConnected;
|
||||
nsIStreamListener* mListener;
|
||||
PRUint32 mLoadAttributes;
|
||||
nsILoadGroup* mLoadGroup;
|
||||
};
|
||||
|
||||
#endif /* nsFTPChannel_h___ */
|
||||
|
@ -168,7 +168,8 @@ nsHTTPChannel::OpenOutputStream(PRUint32 startPosition, nsIOutputStream **_retva
|
||||
NS_IMETHODIMP
|
||||
nsHTTPChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
nsISupports *aContext,
|
||||
nsIStreamListener *listener)
|
||||
nsIStreamListener *listener,
|
||||
nsILoadGroup* group)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
@ -186,6 +187,7 @@ nsHTTPChannel::AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
NS_ADDREF(m_pResponseDataListener);
|
||||
|
||||
mResponseContext = aContext;
|
||||
mLoadGroup = group;
|
||||
|
||||
rv = Open();
|
||||
}
|
||||
@ -198,7 +200,8 @@ nsHTTPChannel::AsyncWrite(nsIInputStream *fromStream,
|
||||
PRUint32 startPosition,
|
||||
PRInt32 writeCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamObserver *observer)
|
||||
nsIStreamObserver *observer,
|
||||
nsILoadGroup* group)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
@ -272,6 +275,14 @@ nsHTTPChannel::GetContentType(char * *aContentType)
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHTTPChannel::GetLoadGroup(nsILoadGroup * *aLoadGroup)
|
||||
{
|
||||
*aLoadGroup = mLoadGroup;
|
||||
NS_ADDREF(*aLoadGroup);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// nsIHTTPChannel methods:
|
||||
|
||||
@ -528,7 +539,7 @@ nsHTTPChannel::Open(void)
|
||||
|
||||
// Write the request to the server...
|
||||
rv = stream->GetLength(&count);
|
||||
rv = channel->AsyncWrite(stream, 0, count, this , m_pRequest);
|
||||
rv = channel->AsyncWrite(stream, 0, count, this , m_pRequest, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
m_State = HS_WAITING_FOR_RESPONSE;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "nsHTTPHandler.h"
|
||||
#include "nsIEventQueue.h"
|
||||
#include "nsIHttpEventSink.h"
|
||||
#include "nsILoadGroup.h"
|
||||
|
||||
class nsHTTPRequest;
|
||||
class nsHTTPResponse;
|
||||
@ -66,15 +67,18 @@ public:
|
||||
NS_IMETHOD OpenOutputStream(PRUint32 startPosition, nsIOutputStream **_retval);
|
||||
NS_IMETHOD AsyncRead(PRUint32 startPosition, PRInt32 readCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamListener *listener);
|
||||
nsIStreamListener *listener,
|
||||
nsILoadGroup* group);
|
||||
NS_IMETHOD AsyncWrite(nsIInputStream *fromStream,
|
||||
PRUint32 startPosition,
|
||||
PRInt32 writeCount,
|
||||
nsISupports *ctxt,
|
||||
nsIStreamObserver *observer);
|
||||
nsIStreamObserver *observer,
|
||||
nsILoadGroup* group);
|
||||
NS_IMETHOD GetLoadAttributes(PRUint32 *aLoadAttributes);
|
||||
NS_IMETHOD SetLoadAttributes(PRUint32 aLoadAttributes);
|
||||
NS_IMETHOD GetContentType(char * *aContentType);
|
||||
NS_IMETHOD GetLoadGroup(nsILoadGroup * *aLoadGroup);
|
||||
|
||||
// nsIHTTPChannel methods:
|
||||
NS_IMETHOD GetRequestHeader(const char *headerName, char **_retval);
|
||||
@ -91,6 +95,8 @@ public:
|
||||
nsresult Open();
|
||||
nsresult SetResponse(nsHTTPResponse* i_pResp);
|
||||
nsresult GetResponseContext(nsISupports** aContext);
|
||||
|
||||
nsILoadGroup* GetLoadGroup() { return mLoadGroup; }
|
||||
|
||||
protected:
|
||||
nsCOMPtr<nsIURI> m_URI;
|
||||
@ -104,6 +110,7 @@ protected:
|
||||
PRUint32 mLoadAttributes;
|
||||
|
||||
nsCOMPtr<nsISupports> mResponseContext;
|
||||
nsCOMPtr<nsILoadGroup> mLoadGroup;
|
||||
};
|
||||
|
||||
#endif /* _nsHTTPChannel_h_ */
|
||||
|
@ -959,6 +959,12 @@ nsHTTPRequest::OnStartRequest(nsIChannel* channel, nsISupports* i_pContext)
|
||||
("nsHTTPRequest [this=%x]. Starting to write request to server.\n",
|
||||
this));
|
||||
|
||||
if (m_pConnection->GetLoadGroup()) {
|
||||
nsCOMPtr<nsISupports> context;
|
||||
m_pConnection->GetResponseContext(getter_AddRefs(context));
|
||||
m_pConnection->GetLoadGroup()->AddChannel(m_pConnection, context);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -983,7 +989,8 @@ nsHTTPRequest::OnStopRequest(nsIChannel* channel, nsISupports* i_pContext,
|
||||
NS_ADDREF(pListener);
|
||||
rv = m_pTransport->AsyncRead(0, -1,
|
||||
i_pContext,
|
||||
pListener);
|
||||
pListener,
|
||||
nsnull);
|
||||
NS_RELEASE(pListener);
|
||||
} else {
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
@ -214,7 +214,10 @@ nsHTTPResponseListener::OnStopRequest(nsIChannel* channel,
|
||||
// Pass the notification out to the consumer...
|
||||
if (m_pConsumer) {
|
||||
rv = m_pConsumer->OnStopRequest(m_pConnection, m_ResponseContext, i_Status, i_pMsg);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_pConnection->GetLoadGroup())
|
||||
m_pConnection->GetLoadGroup()->RemoveChannel(m_pConnection, m_ResponseContext, i_Status, i_pMsg);
|
||||
|
||||
// The Consumer is no longer needed...
|
||||
NS_IF_RELEASE(m_pConsumer);
|
||||
@ -697,7 +700,7 @@ nsresult nsHTTPResponseListener::ProcessRedirection(PRInt32 aStatusCode)
|
||||
nsIChannel* channel;
|
||||
rv = serv->NewChannelFromURI("load", newURL, nsnull, &channel);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = channel->AsyncRead(0, -1, m_ResponseContext, m_pConsumer);
|
||||
rv = channel->AsyncRead(0, -1, m_ResponseContext, m_pConsumer, nsnull);
|
||||
NS_RELEASE(channel);
|
||||
}
|
||||
#endif
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
class nsIBuffer;
|
||||
class nsHTTPResponse;
|
||||
class nsIHTTPChannel;
|
||||
class nsHTTPChannel;
|
||||
|
||||
/*
|
||||
The nsHTTPResponseListener class is the response reader listener that
|
||||
@ -85,7 +85,7 @@ protected:
|
||||
PRBool m_bHeadersDone;
|
||||
PRBool m_bFirstLineParsed;
|
||||
nsHTTPResponse* m_pResponse;
|
||||
nsIHTTPChannel* m_pConnection;
|
||||
nsHTTPChannel* m_pConnection;
|
||||
nsIStreamListener* m_pConsumer;
|
||||
PRUint32 m_ReadLength; // Already read
|
||||
|
||||
|
@ -344,7 +344,7 @@ ParallelReadTest(char* dirName, nsIFileTransportService* fts)
|
||||
rv = fts->CreateTransport(spec, &trans);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "create failed");
|
||||
|
||||
rv = trans->AsyncRead(0, -1, nsnull, listener);
|
||||
rv = trans->AsyncRead(0, -1, nsnull, listener, nsnull);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "AsyncRead failed");
|
||||
|
||||
// the reader thread will hang on to these objects until it quits
|
||||
|
@ -421,7 +421,8 @@ nsresult StartLoadingURL(const char* aUrlString)
|
||||
rv = pChannel->AsyncRead(0, // staring position
|
||||
-1, // number of bytes to read
|
||||
info, // ISupports context
|
||||
listener); // IStreamListener consumer
|
||||
listener, // IStreamListener consumer
|
||||
nsnull); // load group
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
gKeepRunning += 1;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ TestWriteObserver::OnStopRequest(nsIChannel* channel, nsISupports* context,
|
||||
printf("\n+++ TestWriteObserver::OnStopRequest (status = %x) +++\n", aStatus);
|
||||
|
||||
if (NS_SUCCEEDED(aStatus)) {
|
||||
mTransport->AsyncRead(0, -1, nsnull, new InputTestConsumer);
|
||||
mTransport->AsyncRead(0, -1, nsnull, new InputTestConsumer, nsnull);
|
||||
} else {
|
||||
gKeepRunning = 0;
|
||||
}
|
||||
@ -259,7 +259,7 @@ main(int argc, char* argv[])
|
||||
TestWriteObserver* observer = new TestWriteObserver(transport);
|
||||
|
||||
gElapsedTime = PR_Now();
|
||||
transport->AsyncWrite(stream, 0, bytesWritten, nsnull, observer);
|
||||
transport->AsyncWrite(stream, 0, bytesWritten, nsnull, observer, nsnull);
|
||||
|
||||
NS_RELEASE(transport);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ main(int argc, char* argv[])
|
||||
|
||||
rv = sts->CreateTransport(hostName, port, &transport);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
transport->AsyncRead(0, -1, nsnull, new InputTestConsumer);
|
||||
transport->AsyncRead(0, -1, nsnull, new InputTestConsumer, nsnull);
|
||||
|
||||
NS_RELEASE(transport);
|
||||
}
|
||||
|
@ -295,7 +295,7 @@ TestConnection::Run(void)
|
||||
//
|
||||
// Initiate an async read...
|
||||
//
|
||||
rv = mTransport->AsyncRead(0, -1, mTransport, this);
|
||||
rv = mTransport->AsyncRead(0, -1, mTransport, this, nsnull);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
printf("Error: AsyncRead failed...");
|
||||
@ -358,7 +358,8 @@ nsresult TestConnection::WriteBuffer(void)
|
||||
|
||||
// Write the buffer to the server...
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = mTransport->AsyncWrite(mStream, 0, bytesWritten, mTransport, /* mOutputObserver */ nsnull);
|
||||
rv = mTransport->AsyncWrite(mStream, 0, bytesWritten, mTransport,
|
||||
/* mOutputObserver */ nsnull, nsnull);
|
||||
}
|
||||
// Wait for the write to complete...
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -38,10 +38,10 @@ extern nsresult
|
||||
NS_NewURI(nsIURI* *result, const nsString& spec, nsIURI* baseURI = nsnull);
|
||||
|
||||
extern nsresult
|
||||
NS_OpenURI(nsIChannel* *result, nsIURI* uri, nsILoadGroup* group);
|
||||
NS_OpenURI(nsIChannel* *result, nsIURI* uri);
|
||||
|
||||
extern nsresult
|
||||
NS_OpenURI(nsIInputStream* *result, nsIURI* uri, nsILoadGroup* group);
|
||||
NS_OpenURI(nsIInputStream* *result, nsIURI* uri);
|
||||
|
||||
extern nsresult
|
||||
NS_OpenURI(nsIStreamListener* aConsumer, nsISupports* context,
|
||||
@ -54,6 +54,7 @@ extern nsresult
|
||||
NS_MakeAbsoluteURI(const nsString& spec, nsIURI* baseURI, nsString& result);
|
||||
|
||||
extern nsresult
|
||||
NS_NewLoadGroup(nsILoadGroup* parent, nsISupports* outer, nsILoadGroup* *result);
|
||||
NS_NewLoadGroup(nsISupports* outer, nsIStreamObserver* observer,
|
||||
nsILoadGroup* parent, nsILoadGroup* *result);
|
||||
|
||||
#endif // nsNeckoUtil_h__
|
||||
|
@ -50,7 +50,7 @@ NS_NewURI(nsIURI* *result, const nsString& spec, nsIURI* baseURI)
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_OpenURI(nsIChannel* *result, nsIURI* uri, nsILoadGroup* group)
|
||||
NS_OpenURI(nsIChannel* *result, nsIURI* uri)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
@ -59,26 +59,18 @@ NS_OpenURI(nsIChannel* *result, nsIURI* uri, nsILoadGroup* group)
|
||||
nsIChannel* channel;
|
||||
rv = serv->NewChannelFromURI("load", uri, nsnull, &channel);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#if 0
|
||||
if (group) {
|
||||
rv = group->AddChannel(channel);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
*result = channel;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_OpenURI(nsIInputStream* *result, nsIURI* uri, nsILoadGroup* group)
|
||||
NS_OpenURI(nsIInputStream* *result, nsIURI* uri)
|
||||
{
|
||||
nsresult rv;
|
||||
nsIChannel* channel;
|
||||
|
||||
rv = NS_OpenURI(&channel, uri, group);
|
||||
rv = NS_OpenURI(&channel, uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIInputStream* inStr;
|
||||
@ -97,10 +89,10 @@ NS_OpenURI(nsIStreamListener* aConsumer, nsISupports* context,
|
||||
nsresult rv;
|
||||
nsIChannel* channel;
|
||||
|
||||
rv = NS_OpenURI(&channel, uri, group);
|
||||
rv = NS_OpenURI(&channel, uri);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = channel->AsyncRead(0, -1, context, aConsumer);
|
||||
rv = channel->AsyncRead(0, -1, context, aConsumer, group);
|
||||
NS_RELEASE(channel);
|
||||
return rv;
|
||||
}
|
||||
@ -132,13 +124,14 @@ NS_MakeAbsoluteURI(const nsString& spec, nsIURI* baseURI, nsString& result)
|
||||
}
|
||||
|
||||
nsresult
|
||||
NS_NewLoadGroup(nsILoadGroup* parent, nsISupports* outer, nsILoadGroup* *result)
|
||||
NS_NewLoadGroup(nsISupports* outer, nsIStreamObserver* observer,
|
||||
nsILoadGroup* parent, nsILoadGroup* *result)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIIOService, serv, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return serv->NewLoadGroup(parent, outer, result);
|
||||
return serv->NewLoadGroup(outer, observer, parent, result);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -522,7 +522,7 @@ nsExpatTokenizer::OpenInputStream(nsString2& aURLStr, nsIInputStream*& in)
|
||||
ret = NS_NewURI(&uri, aURLStr);
|
||||
if (NS_FAILED(ret)) return ret;
|
||||
|
||||
ret = NS_OpenURI(&in, uri, nsnull); // XXX need to pass the document's nsILoadGroup here!
|
||||
ret = NS_OpenURI(&in, uri);
|
||||
NS_RELEASE(uri);
|
||||
#endif // NECKO
|
||||
return ret;
|
||||
|
@ -544,7 +544,7 @@ rdf_BlockingParse(nsIURI* aURL, nsIStreamListener* aConsumer)
|
||||
|
||||
#ifdef NECKO
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = NS_OpenURI(getter_AddRefs(channel), aURL, nsnull); // XXX need the nsILoadGroup here!
|
||||
rv = NS_OpenURI(getter_AddRefs(channel), aURL);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
NS_ERROR("unable to open channel");
|
||||
|
@ -104,7 +104,6 @@ nsChromeProtocolHandler::MakeAbsolute(const char* aSpec,
|
||||
url->GetSpec(result);
|
||||
NS_RELEASE(url);
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "License"); you may not use this file except in
|
||||
@ -423,10 +423,14 @@ public:
|
||||
|
||||
NS_IMETHOD GetContentType(nsString& aContentType) const;
|
||||
|
||||
NS_IMETHOD StartDocumentLoad(nsIURI *aUrl,
|
||||
NS_IMETHOD StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand);
|
||||
nsIStreamListener **aDocListener);
|
||||
|
||||
NS_IMETHOD LoadFromStream(nsIInputStream& xulStream,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
@ -726,7 +730,12 @@ protected:
|
||||
nsresult PrepareToLoad( nsCOMPtr<nsIParser>* created_parser,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
const char* aCommand,
|
||||
nsIURI* aOptionalURL = 0 );
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel
|
||||
#else
|
||||
nsIURI* aOptionalURL = 0
|
||||
#endif
|
||||
);
|
||||
|
||||
protected:
|
||||
// pseudo constants
|
||||
@ -757,7 +766,7 @@ protected:
|
||||
nsVoidArray mObservers;
|
||||
nsAutoString mDocumentTitle;
|
||||
nsCOMPtr<nsIURI> mDocumentURL; // [OWNER] ??? compare with loader
|
||||
nsCOMPtr<nsILoadGroup> mDocumentLoadGroup; // [OWNER] leads to loader
|
||||
nsCOMPtr<nsILoadGroup> mDocumentLoadGroup; // [OWNER] leads to loader
|
||||
nsCOMPtr<nsIRDFResource> mRootResource; // [OWNER]
|
||||
nsCOMPtr<nsIContent> mRootContent; // [OWNER]
|
||||
nsIDocument* mParentDocument; // [WEAK]
|
||||
@ -1083,11 +1092,21 @@ nsresult
|
||||
XULDocumentImpl::PrepareToLoad( nsCOMPtr<nsIParser>* created_parser,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
const char* aCommand,
|
||||
nsIURI* aOptionalURL )
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel
|
||||
#else
|
||||
nsIURI* aOptionalURL
|
||||
#endif
|
||||
)
|
||||
{
|
||||
nsCOMPtr<nsIURI> syntheticURL;
|
||||
#ifdef NECKO
|
||||
if ( aChannel )
|
||||
(void)aChannel->GetURI(getter_AddRefs(syntheticURL));
|
||||
#else
|
||||
if ( aOptionalURL )
|
||||
syntheticURL = dont_QueryInterface(aOptionalURL);
|
||||
#endif
|
||||
else
|
||||
{
|
||||
nsAutoString seedString;
|
||||
@ -1114,7 +1133,7 @@ XULDocumentImpl::PrepareToLoad( nsCOMPtr<nsIParser>* created_parser,
|
||||
|
||||
mDocumentURL = syntheticURL;
|
||||
#ifdef NECKO
|
||||
// XXX help
|
||||
(void)aChannel->GetLoadGroup(getter_AddRefs(mDocumentLoadGroup));
|
||||
#else
|
||||
syntheticURL->GetLoadGroup(getter_AddRefs(mDocumentLoadGroup));
|
||||
#endif
|
||||
@ -1250,17 +1269,31 @@ XULDocumentImpl::SetDocumentURLAndGroup(nsIURI* anURL)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::StartDocumentLoad(nsIURI *aURL,
|
||||
XULDocumentImpl::StartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aURL,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener,
|
||||
const char* aCommand)
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
nsresult status;
|
||||
nsCOMPtr<nsIParser> parser;
|
||||
#ifdef NECKO
|
||||
nsCOMPtr<nsIURI> aURL;
|
||||
status = aChannel->GetURI(getter_AddRefs(aURL));
|
||||
if (NS_FAILED(status)) return status;
|
||||
#endif
|
||||
|
||||
do
|
||||
{
|
||||
if ( NS_FAILED(status = PrepareToLoad(&parser, aContainer, aCommand, aURL)) )
|
||||
#ifdef NECKO
|
||||
status = PrepareToLoad(&parser, aContainer, aCommand, aChannel);
|
||||
#else
|
||||
status = PrepareToLoad(&parser, aContainer, aCommand, aURL);
|
||||
#endif
|
||||
if ( NS_FAILED(status) )
|
||||
break;
|
||||
|
||||
{
|
||||
@ -1289,7 +1322,7 @@ XULDocumentImpl::LoadFromStream( nsIInputStream& xulStream,
|
||||
{
|
||||
nsresult status;
|
||||
nsCOMPtr<nsIParser> parser;
|
||||
if ( NS_SUCCEEDED(status = PrepareToLoad(&parser, aContainer, aCommand)) )
|
||||
if ( NS_SUCCEEDED(status = PrepareToLoad(&parser, aContainer, aCommand, nsnull)) )
|
||||
parser->Parse(xulStream);
|
||||
|
||||
return status;
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "nsINetService.h"
|
||||
#include "nsIPostToServer.h"
|
||||
#else
|
||||
#include "nsIIOService.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
#include "nsIURL.h"
|
||||
@ -89,6 +90,8 @@ static NS_DEFINE_IID(kRefreshURLIID, NS_IREFRESHURL_IID);
|
||||
static NS_DEFINE_IID(kILoadGroupIID, NS_ILOADGROUP_IID);
|
||||
static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
|
||||
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
|
||||
#else
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
#endif // NECKO
|
||||
static NS_DEFINE_IID(kIContentViewerContainerIID, NS_ICONTENT_VIEWER_CONTAINER_IID);
|
||||
static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID);
|
||||
@ -128,8 +131,6 @@ public:
|
||||
|
||||
nsresult Bind(nsIURI* aURL, nsIStreamListener* aListener);
|
||||
|
||||
nsresult Stop(void);
|
||||
|
||||
#ifdef NECKO
|
||||
// nsIStreamObserver methods:
|
||||
NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt);
|
||||
@ -144,6 +145,8 @@ public:
|
||||
NS_IMETHOD OnProgress(nsIChannel* channel, nsISupports *ctxt, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
NS_IMETHOD OnStatus(nsIChannel* channel, nsISupports *ctxt, const PRUnichar *aMsg);
|
||||
#else
|
||||
nsresult Stop(void);
|
||||
|
||||
/* nsIStreamListener interface methods... */
|
||||
NS_IMETHOD GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo);
|
||||
NS_IMETHOD OnProgress(nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
@ -164,7 +167,9 @@ protected:
|
||||
|
||||
protected:
|
||||
char* m_Command;
|
||||
#ifndef NECKO
|
||||
nsIURI* m_Url;
|
||||
#endif
|
||||
nsIContentViewerContainer* m_Container;
|
||||
nsISupports* m_ExtraInfo;
|
||||
nsIStreamObserver* m_Observer;
|
||||
@ -183,7 +188,7 @@ protected:
|
||||
#ifndef NECKO
|
||||
class nsDocLoaderImpl : public nsIDocumentLoader, public nsILoadGroup
|
||||
#else
|
||||
class nsDocLoaderImpl : public nsIDocumentLoader
|
||||
class nsDocLoaderImpl : public nsIDocumentLoader, public nsIStreamObserver
|
||||
#endif // NECKO
|
||||
{
|
||||
public:
|
||||
@ -267,8 +272,8 @@ public:
|
||||
nsIChannel* channel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
#endif
|
||||
nsIContentViewer* aViewer);
|
||||
|
||||
void FireOnProgressURLLoad(nsIDocumentLoader* aLoadInitiator,
|
||||
@ -309,12 +314,21 @@ public:
|
||||
#endif
|
||||
|
||||
#ifdef NECKO
|
||||
// nsIStreamObserver methods: (for observing the load group)
|
||||
NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt);
|
||||
NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt,
|
||||
nsresult status, const PRUnichar *errorMsg);
|
||||
|
||||
nsILoadGroup* GetLoadGroup() { return mLoadGroup; }
|
||||
#endif
|
||||
|
||||
nsresult CreateContentViewer(nsIURI* aURL,
|
||||
nsresult CreateContentViewer(const char *aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* channel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
const char *aCommand,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsISupports* aExtraInfo,
|
||||
nsIStreamListener** aDocListener,
|
||||
@ -327,11 +341,12 @@ protected:
|
||||
nsIDocumentLoader* aLoadInitiator,
|
||||
PRInt32 aStatus);
|
||||
|
||||
|
||||
#ifndef NECKO
|
||||
private:
|
||||
static PRBool StopBindInfoEnumerator (nsISupports* aElement, void* aData);
|
||||
static PRBool StopDocLoaderEnumerator(void* aElement, void* aData);
|
||||
static PRBool IsBusyEnumerator(void* aElement, void* aData);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
@ -345,27 +360,23 @@ protected:
|
||||
nsIChannel* mDocumentChannel; // [OWNER] ???compare with document
|
||||
#else
|
||||
nsIURI* mDocumentUrl; // [OWNER] ???compare with document
|
||||
#endif
|
||||
nsCOMPtr<nsISupportsArray> m_LoadingDocsList;
|
||||
|
||||
nsVoidArray mChildGroupList;
|
||||
nsVoidArray mDocObservers;
|
||||
#ifdef NECKO
|
||||
nsLoadFlags m_LoadAttrib;
|
||||
#else
|
||||
nsCOMPtr<nsILoadAttribs> m_LoadAttrib;
|
||||
#endif
|
||||
nsCOMPtr<nsIStreamObserver> mStreamObserver; // ??? unclear what to do here
|
||||
nsIContentViewerContainer* mContainer; // [WEAK] it owns me!
|
||||
|
||||
nsDocLoaderImpl* mParent; // [OWNER] but upside down ownership model
|
||||
// needs to be fixed***
|
||||
/*
|
||||
* The following counts are for the current document loader only. They
|
||||
* do not take into account URLs being loaded by child document loaders.
|
||||
*/
|
||||
PRInt32 mForegroundURLs;
|
||||
PRInt32 mTotalURLs;
|
||||
nsCOMPtr<nsISupportsArray> m_LoadingDocsList;
|
||||
#endif
|
||||
|
||||
nsVoidArray mDocObservers;
|
||||
nsCOMPtr<nsIStreamObserver> mStreamObserver; // ??? unclear what to do here
|
||||
nsIContentViewerContainer* mContainer; // [WEAK] it owns me!
|
||||
|
||||
nsDocLoaderImpl* mParent; // [OWNER] but upside down ownership model
|
||||
// needs to be fixed***
|
||||
/*
|
||||
* This flag indicates that the loader is loading a document. It is set
|
||||
* from the call to LoadDocument(...) until the OnConnectionsComplete(...)
|
||||
@ -393,17 +404,20 @@ nsDocLoaderImpl::nsDocLoaderImpl()
|
||||
mDocumentChannel = nsnull;
|
||||
#else
|
||||
mDocumentUrl = nsnull;
|
||||
mForegroundURLs = 0;
|
||||
mTotalURLs = 0;
|
||||
#endif
|
||||
mParent = nsnull;
|
||||
mContainer = nsnull;
|
||||
mForegroundURLs = 0;
|
||||
mTotalURLs = 0;
|
||||
|
||||
mIsLoadingDocument = PR_FALSE;
|
||||
|
||||
#ifdef NECKO
|
||||
m_LoadAttrib = nsIChannel::LOAD_NORMAL;
|
||||
#endif
|
||||
// XXX I wanted to pull this initialization code out of this constructor
|
||||
// because it could fail... but the web shell uses this implementation
|
||||
// as a service too. Since it's a service, it really can't have any
|
||||
// initialization. We're sort of screwed here.
|
||||
nsresult rv = Init();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsDocLoaderImpl::Init failed");
|
||||
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
("DocLoader:%p: created.\n", this));
|
||||
@ -414,12 +428,12 @@ nsDocLoaderImpl::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(m_LoadingDocsList));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#ifdef NECKO
|
||||
rv = NS_NewLoadGroup(nsnull, nsnull, getter_AddRefs(mLoadGroup));
|
||||
rv = NS_NewLoadGroup(nsnull, this, nsnull, getter_AddRefs(mLoadGroup));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#else
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(m_LoadingDocsList));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_NewLoadAttribs(getter_AddRefs(m_LoadAttrib));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif
|
||||
@ -446,8 +460,9 @@ nsDocLoaderImpl::~nsDocLoaderImpl()
|
||||
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
("DocLoader:%p: deleted.\n", this));
|
||||
|
||||
#ifndef NECKO
|
||||
NS_PRECONDITION((0 == mChildGroupList.Count()), "Document loader has children...");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -473,6 +488,12 @@ nsDocLoaderImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
#else
|
||||
if (aIID.Equals(kIStreamObserverIID)) {
|
||||
*aInstancePtr = (void*)(nsIStreamObserver*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
#endif // NECKO
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
@ -495,8 +516,6 @@ nsDocLoaderImpl::CreateDocumentLoader(nsIDocumentLoader** anInstance)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
rv = newLoader->Init();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = newLoader->QueryInterface(kIDocumentLoaderIID, (void**)anInstance);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
@ -513,9 +532,13 @@ nsDocLoaderImpl::CreateDocumentLoader(nsIDocumentLoader** anInstance)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocLoaderImpl::CreateContentViewer(nsIURI* aURL,
|
||||
nsDocLoaderImpl::CreateContentViewer(const char *aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* channel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
const char *aCommand,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsISupports* aExtraInfo,
|
||||
nsIStreamListener** aDocListenerResult,
|
||||
@ -543,7 +566,14 @@ nsDocLoaderImpl::CreateContentViewer(nsIURI* aURL,
|
||||
}
|
||||
|
||||
// Now create an instance of the content viewer
|
||||
rv = factory->CreateInstance(aURL, aContentType, aCommand, aContainer,
|
||||
rv = factory->CreateInstance(aCommand,
|
||||
#ifdef NECKO
|
||||
channel,
|
||||
#else
|
||||
aURL,
|
||||
#endif
|
||||
aContentType,
|
||||
aContainer,
|
||||
aExtraInfo, aDocListenerResult,
|
||||
aDocViewerResult);
|
||||
NS_RELEASE(factory);
|
||||
@ -590,18 +620,19 @@ nsDocLoaderImpl::LoadDocument(const nsString& aURLSpec,
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
NS_ADDREF(loader);
|
||||
loader->Init(this, // DocLoader
|
||||
aCommand, // Command
|
||||
aContainer, // Viewer Container
|
||||
aExtraInfo, // Extra Info
|
||||
anObserver); // Observer
|
||||
|
||||
#ifndef NECKO
|
||||
/* The DocumentBindInfo reference is only held by the Array... */
|
||||
m_LoadingDocsList->AppendElement((nsIStreamListener *)loader);
|
||||
|
||||
/* Initialize the URL counters... */
|
||||
NS_PRECONDITION(((mTotalURLs == 0) && (mForegroundURLs == 0)), "DocuemntLoader is busy...");
|
||||
#ifndef NECKO
|
||||
NS_PRECONDITION(((mTotalURLs == 0) && (mForegroundURLs == 0)), "DocumentLoader is busy...");
|
||||
rv = m_LoadAttrib->GetLoadType(&loadType);
|
||||
if (NS_FAILED(rv)) {
|
||||
loadType = nsURLLoadNormal;
|
||||
@ -609,8 +640,8 @@ nsDocLoaderImpl::LoadDocument(const nsString& aURLSpec,
|
||||
if (nsURLLoadBackground != loadType) {
|
||||
mForegroundURLs = 1;
|
||||
}
|
||||
#endif
|
||||
mTotalURLs = 1;
|
||||
#endif
|
||||
/*
|
||||
* Set the flag indicating that the document loader is in the process of
|
||||
* loading a document. This flag will remain set until the
|
||||
@ -618,9 +649,7 @@ nsDocLoaderImpl::LoadDocument(const nsString& aURLSpec,
|
||||
*/
|
||||
mIsLoadingDocument = PR_TRUE;
|
||||
|
||||
#ifdef NECKO
|
||||
m_LoadAttrib = aType;
|
||||
#else
|
||||
#ifndef NECKO
|
||||
m_LoadAttrib->SetReloadType(aType);
|
||||
// If we've got special loading instructions, mind them.
|
||||
if ((aType == nsURLReloadBypassProxy) ||
|
||||
@ -637,6 +666,7 @@ nsDocLoaderImpl::LoadDocument(const nsString& aURLSpec,
|
||||
rv = loader->Bind(aURLSpec, aPostData, nsnull);
|
||||
|
||||
done:
|
||||
NS_RELEASE(loader);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -667,21 +697,24 @@ nsDocLoaderImpl::LoadSubDocument(const nsString& aURLSpec,
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
return rv;
|
||||
}
|
||||
NS_ADDREF(loader);
|
||||
loader->Init(this, // DocLoader
|
||||
nsnull, // Command
|
||||
nsnull, // Viewer Container
|
||||
aExtraInfo, // Extra Info
|
||||
mStreamObserver); // Observer
|
||||
|
||||
#ifndef NECKO
|
||||
/* The DocumentBindInfo reference is only held by the Array... */
|
||||
m_LoadingDocsList->AppendElement((nsIStreamListener *)loader);
|
||||
|
||||
/* Increment the URL counters... */
|
||||
mForegroundURLs++;
|
||||
mTotalURLs++;
|
||||
|
||||
rv = loader->Bind(aURLSpec, nsnull, nsnull);
|
||||
#endif
|
||||
|
||||
rv = loader->Bind(aURLSpec, nsnull, nsnull);
|
||||
NS_RELEASE(loader);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -710,10 +743,10 @@ nsDocLoaderImpl::Stop(void)
|
||||
*/
|
||||
mChildGroupList.EnumerateForwards(nsDocLoaderImpl::StopDocLoaderEnumerator, nsnull);
|
||||
|
||||
#endif
|
||||
/* Reset the URL counters... */
|
||||
mForegroundURLs = 0;
|
||||
mTotalURLs = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Release the Stream Observer...
|
||||
@ -728,6 +761,9 @@ nsDocLoaderImpl::Stop(void)
|
||||
NS_IMETHODIMP
|
||||
nsDocLoaderImpl::IsBusy(PRBool& aResult)
|
||||
{
|
||||
#ifdef NECKO
|
||||
return mLoadGroup->IsPending(&aResult);
|
||||
#else
|
||||
aResult = PR_FALSE;
|
||||
|
||||
/* If this document loader is busy? */
|
||||
@ -741,6 +777,7 @@ nsDocLoaderImpl::IsBusy(PRBool& aResult)
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -838,15 +875,13 @@ nsDocLoaderImpl::CreateURL(nsIURI** aInstancePtrResult,
|
||||
rv = NS_NewURI(&url, aURLSpec, aBaseURL);
|
||||
#else
|
||||
rv = NS_NewURL(&url, aURLSpec, aBaseURL, aContainer, this);
|
||||
#endif
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
#ifndef NECKO // set later after we open the channel
|
||||
nsCOMPtr<nsILoadAttribs> loadAttributes;
|
||||
rv = url->GetLoadAttribs(getter_AddRefs(loadAttributes));
|
||||
if (loadAttributes)
|
||||
loadAttributes->Clone(m_LoadAttrib);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
*aInstancePtrResult = url;
|
||||
}
|
||||
|
||||
@ -884,17 +919,18 @@ nsDocLoaderImpl::OpenStream(nsIURI *aUrl, nsIStreamListener *aConsumer)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
NS_ADDREF(loader);
|
||||
loader->Init(this, // DocLoader
|
||||
nsnull, // Command
|
||||
mContainer, // Viewer Container
|
||||
nsnull, // Extra Info
|
||||
mStreamObserver); // Observer
|
||||
|
||||
#ifndef NECKO // done in the load group now
|
||||
/* The DocumentBindInfo reference is only held by the Array... */
|
||||
m_LoadingDocsList->AppendElement(((nsISupports*)(nsIStreamObserver*)loader));
|
||||
|
||||
/* Update the URL counters... */
|
||||
#ifndef NECKO // do later after we call NS_OpenURI
|
||||
nsILoadAttribs* loadAttributes;
|
||||
|
||||
rv = aUrl->GetLoadAttribs(&loadAttributes);
|
||||
@ -909,11 +945,12 @@ nsDocLoaderImpl::OpenStream(nsIURI *aUrl, nsIStreamListener *aConsumer)
|
||||
if (nsURLLoadBackground != loadType) {
|
||||
mForegroundURLs += 1;
|
||||
}
|
||||
#endif
|
||||
mTotalURLs += 1;
|
||||
#endif
|
||||
|
||||
rv = loader->Bind(aUrl, aConsumer);
|
||||
done:
|
||||
NS_RELEASE(loader);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -926,7 +963,7 @@ nsDocLoaderImpl::GetDefaultLoadAttributes(nsILoadAttribs*& aLoadAttribs)
|
||||
#endif
|
||||
{
|
||||
#ifdef NECKO
|
||||
*aLoadAttribs = m_LoadAttrib;
|
||||
return mLoadGroup->GetDefaultLoadAttributes(aLoadAttribs);
|
||||
#else
|
||||
aLoadAttribs = m_LoadAttrib;
|
||||
NS_IF_ADDREF(aLoadAttribs);
|
||||
@ -944,10 +981,9 @@ nsDocLoaderImpl::SetDefaultLoadAttributes(nsILoadAttribs* aLoadAttribs)
|
||||
#endif
|
||||
{
|
||||
#ifdef NECKO
|
||||
m_LoadAttrib = aLoadAttribs;
|
||||
return mLoadGroup->SetDefaultLoadAttributes(aLoadAttribs);
|
||||
#else
|
||||
m_LoadAttrib->Clone(aLoadAttribs);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Now set the default attributes for all child DocumentLoaders...
|
||||
@ -959,28 +995,57 @@ nsDocLoaderImpl::SetDefaultLoadAttributes(nsILoadAttribs* aLoadAttribs)
|
||||
nsILoadGroup* child = (nsILoadGroup*)mChildGroupList.ElementAt(index);
|
||||
child->SetDefaultLoadAttributes(m_LoadAttrib);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef NECKO
|
||||
NS_IMETHODIMP
|
||||
nsDocLoaderImpl::OnStartRequest(nsIChannel *channel, nsISupports *ctxt)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = channel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// FireOnStartDocumentLoad(this, uri, "load"); // XXX fix command
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocLoaderImpl::OnStopRequest(nsIChannel *channel, nsISupports *ctxt,
|
||||
nsresult status, const PRUnichar *errorMsg)
|
||||
{
|
||||
FireOnEndDocumentLoad(this, status);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocLoaderImpl::AddChildGroup(nsILoadGroup* aGroup)
|
||||
{
|
||||
#ifdef NECKO
|
||||
return mLoadGroup->AddSubGroup(aGroup);
|
||||
#else
|
||||
mChildGroupList.AppendElement(aGroup);
|
||||
return NS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocLoaderImpl::RemoveChildGroup(nsILoadGroup* aGroup)
|
||||
{
|
||||
#ifdef NECKO
|
||||
return mLoadGroup->RemoveSubGroup(aGroup);
|
||||
#else
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (PR_FALSE == mChildGroupList.RemoveElement(aGroup)) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
return rv;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1057,8 +1122,8 @@ void nsDocLoaderImpl::FireOnStartURLLoad(nsIDocumentLoader* aLoadInitiator,
|
||||
nsIChannel* channel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
#endif
|
||||
nsIContentViewer* aViewer)
|
||||
{
|
||||
PRInt32 count = mDocObservers.Count();
|
||||
@ -1070,7 +1135,7 @@ void nsDocLoaderImpl::FireOnStartURLLoad(nsIDocumentLoader* aLoadInitiator,
|
||||
for (index = 0; index < count; index++) {
|
||||
nsIDocumentLoaderObserver* observer = (nsIDocumentLoaderObserver*)mDocObservers.ElementAt(index);
|
||||
#ifdef NECKO
|
||||
observer->OnStartURLLoad(aLoadInitiator, channel, aContentType, aViewer);
|
||||
observer->OnStartURLLoad(aLoadInitiator, channel, aViewer);
|
||||
#else
|
||||
observer->OnStartURLLoad(aLoadInitiator, aURL, aContentType, aViewer);
|
||||
#endif
|
||||
@ -1081,7 +1146,7 @@ void nsDocLoaderImpl::FireOnStartURLLoad(nsIDocumentLoader* aLoadInitiator,
|
||||
*/
|
||||
if (nsnull != mParent) {
|
||||
#ifdef NECKO
|
||||
mParent->FireOnStartURLLoad(aLoadInitiator, channel, aContentType, aViewer);
|
||||
mParent->FireOnStartURLLoad(aLoadInitiator, channel, aViewer);
|
||||
#else
|
||||
mParent->FireOnStartURLLoad(aLoadInitiator, aURL, aContentType, aViewer);
|
||||
#endif
|
||||
@ -1208,19 +1273,24 @@ void nsDocLoaderImpl::LoadURLComplete(nsIURI* aURL, nsISupports* aBindInfo, PRIn
|
||||
* If the entry is not found in the list, then it must have been cancelled
|
||||
* via Stop(...). So ignore just it...
|
||||
*/
|
||||
#ifdef NECKO
|
||||
#if defined(DEBUG)
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = channel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
char* buffer;
|
||||
rv = uri->GetSpec(&buffer);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
("DocLoader:%p: LoadURLComplete(...) called for %s\n",
|
||||
this, buffer));
|
||||
nsCRT::free(buffer);
|
||||
}
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
#else
|
||||
PRBool removed = m_LoadingDocsList->RemoveElement(aBindInfo);
|
||||
if (removed) {
|
||||
#ifdef NECKO
|
||||
PRUint32 loadAttribs;
|
||||
nsresult rv;
|
||||
rv = channel->GetLoadAttributes(&loadAttribs);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (loadAttribs & nsIChannel::LOAD_QUIET) {
|
||||
mForegroundURLs--;
|
||||
isForegroundURL = PR_TRUE;
|
||||
}
|
||||
}
|
||||
#else
|
||||
nsILoadAttribs* loadAttributes;
|
||||
nsURLLoadType loadType = nsURLLoadNormal;
|
||||
|
||||
@ -1236,36 +1306,21 @@ void nsDocLoaderImpl::LoadURLComplete(nsIURI* aURL, nsISupports* aBindInfo, PRIn
|
||||
mForegroundURLs--;
|
||||
isForegroundURL = PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
mTotalURLs -= 1;
|
||||
|
||||
NS_ASSERTION(mTotalURLs >= mForegroundURLs,
|
||||
"Foreground URL count is wrong.");
|
||||
|
||||
#if defined(DEBUG)
|
||||
#ifdef NECKO
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = channel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
char* buffer;
|
||||
rv = uri->GetSpec(&buffer);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
("DocLoader:%p: LoadURLComplete(...) called for %s; Foreground URLs: %d; Total URLs: %d\n",
|
||||
this, buffer, mForegroundURLs, mTotalURLs));
|
||||
nsCRT::free(buffer);
|
||||
}
|
||||
}
|
||||
#else
|
||||
const char* buffer;
|
||||
|
||||
aURL->GetSpec(&buffer);
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
("DocLoader:%p: LoadURLComplete(...) called for %s; Foreground URLs: %d; Total URLs: %d\n",
|
||||
this, buffer, mForegroundURLs, mTotalURLs));
|
||||
#endif
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fire the OnEndURLLoad notification to any observers...
|
||||
@ -1328,6 +1383,7 @@ void nsDocLoaderImpl::SetDocumentUrl(nsIURI* aUrl)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NECKO
|
||||
PRBool nsDocLoaderImpl::StopBindInfoEnumerator(nsISupports* aElement, void* aData)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -1372,6 +1428,7 @@ PRBool nsDocLoaderImpl::IsBusyEnumerator(void* aElement, void* aData)
|
||||
|
||||
return !(*result);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* nsDocumentBindInfo implementation...
|
||||
@ -1382,7 +1439,9 @@ nsDocumentBindInfo::nsDocumentBindInfo()
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
m_Command = nsnull;
|
||||
#ifndef NECKO
|
||||
m_Url = nsnull;
|
||||
#endif
|
||||
m_Container = nsnull;
|
||||
m_ExtraInfo = nsnull;
|
||||
m_Observer = nsnull;
|
||||
@ -1398,8 +1457,9 @@ nsDocumentBindInfo::Init(nsDocLoaderImpl* aDocLoader,
|
||||
nsISupports* aExtraInfo,
|
||||
nsIStreamObserver* anObserver)
|
||||
{
|
||||
|
||||
#ifndef NECKO
|
||||
m_Url = nsnull;
|
||||
#endif
|
||||
m_NextStream = nsnull;
|
||||
m_Command = (nsnull != aCommand) ? PL_strdup(aCommand) : nsnull;
|
||||
|
||||
@ -1427,7 +1487,9 @@ nsDocumentBindInfo::~nsDocumentBindInfo()
|
||||
m_Command = nsnull;
|
||||
|
||||
NS_RELEASE (m_DocLoader);
|
||||
#ifndef NECKO
|
||||
NS_IF_RELEASE(m_Url);
|
||||
#endif
|
||||
NS_IF_RELEASE(m_NextStream);
|
||||
NS_IF_RELEASE(m_Container);
|
||||
NS_IF_RELEASE(m_Observer);
|
||||
@ -1519,10 +1581,7 @@ nsresult nsDocumentBindInfo::Bind(const nsString& aURLSpec,
|
||||
/*
|
||||
* Set the URL has the current "document" being loaded...
|
||||
*/
|
||||
#ifdef NECKO
|
||||
// m_DocLoader->SetDocumentChannel(channel);
|
||||
//NS_ASSERTION(0, "help");
|
||||
#else
|
||||
#ifndef NECKO
|
||||
m_DocLoader->SetDocumentUrl(url);
|
||||
#endif
|
||||
/*
|
||||
@ -1544,8 +1603,10 @@ nsresult nsDocumentBindInfo::Bind(nsIURI* aURL, nsIStreamListener* aListener)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
#ifndef NECKO
|
||||
m_Url = aURL;
|
||||
NS_ADDREF(m_Url);
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG)
|
||||
#ifdef NECKO
|
||||
@ -1586,13 +1647,21 @@ nsresult nsDocumentBindInfo::Bind(nsIURI* aURL, nsIStreamListener* aListener)
|
||||
if (m_DocLoader) {
|
||||
loadGroup = m_DocLoader->GetLoadGroup();
|
||||
}
|
||||
rv = NS_OpenURI(this, nsnull, m_Url, loadGroup);
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = NS_OpenURI(getter_AddRefs(channel), aURL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
m_DocLoader->SetDocumentChannel(channel);
|
||||
|
||||
rv = channel->AsyncRead(0, -1, nsnull, this, loadGroup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif // NECKO
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
#ifndef NECKO
|
||||
nsresult nsDocumentBindInfo::Stop(void)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -1638,7 +1707,6 @@ nsresult nsDocumentBindInfo::Stop(void)
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifndef NECKO
|
||||
NS_METHOD nsDocumentBindInfo::GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
@ -1808,9 +1876,13 @@ nsDocumentBindInfo::OnStartRequest(nsIURI* aURL, const char *aContentType)
|
||||
* (and viewer) of the appropriate type...
|
||||
*/
|
||||
if (m_DocLoader) {
|
||||
rv = m_DocLoader->CreateContentViewer(m_Url,
|
||||
rv = m_DocLoader->CreateContentViewer(m_Command,
|
||||
#ifdef NECKO
|
||||
channel,
|
||||
#else
|
||||
m_Url,
|
||||
#endif
|
||||
aContentType,
|
||||
m_Command,
|
||||
m_Container,
|
||||
m_ExtraInfo,
|
||||
&m_NextStream,
|
||||
@ -1867,7 +1939,7 @@ nsDocumentBindInfo::OnStartRequest(nsIURI* aURL, const char *aContentType)
|
||||
m_Container->GetContentViewer(&viewer);
|
||||
}
|
||||
#ifdef NECKO
|
||||
m_DocLoader->FireOnStartURLLoad((nsIDocumentLoader *)m_DocLoader, channel, aContentType, viewer);
|
||||
m_DocLoader->FireOnStartURLLoad((nsIDocumentLoader *)m_DocLoader, channel, viewer);
|
||||
#else
|
||||
m_DocLoader->FireOnStartURLLoad((nsIDocumentLoader *)m_DocLoader, m_Url, aContentType, viewer);
|
||||
#endif
|
||||
@ -1885,7 +1957,9 @@ nsDocumentBindInfo::OnStartRequest(nsIURI* aURL, const char *aContentType)
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(viewer);
|
||||
|
||||
#ifdef NECKO
|
||||
nsCRT::free(aContentType);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -1985,15 +2059,14 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIURI* aURL, nsresult aStatus, cons
|
||||
nsCRT::free(spec);
|
||||
#endif
|
||||
|
||||
#ifdef NECKO
|
||||
if (NS_FAILED(aStatus)) {
|
||||
#ifdef NECKO
|
||||
char *url;
|
||||
if (NS_SUCCEEDED(rv))
|
||||
aURL->GetSpec(&url);
|
||||
else
|
||||
url = nsCRT::strdup("");
|
||||
#else
|
||||
if (NS_FAILED(aStatus)) {
|
||||
const char *url;
|
||||
if (nsnull != aURL)
|
||||
aURL->GetSpec(&url);
|
||||
@ -2001,7 +2074,7 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIURI* aURL, nsresult aStatus, cons
|
||||
url = "";
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_pnunn
|
||||
#if DEBUG
|
||||
cerr << "nsDocumentBindInfo::OnStopRequest: Load of URL '" << url << "' failed. Error code: "
|
||||
<< NS_ERROR_GET_CODE(aStatus) << "\n";
|
||||
#endif
|
||||
@ -2157,3 +2230,4 @@ nsresult NS_NewDocLoaderServiceFactory(nsIFactory** aResult)
|
||||
*aResult = factory;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,14 @@ CWebShellContainer::OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, n
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
CWebShellContainer::OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURI, const char* aCommand)
|
||||
CWebShellContainer::OnStartDocumentLoad(const char* aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI *aUrl,
|
||||
#endif
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -94,7 +94,9 @@ public:
|
||||
NS_IMETHOD OnStopRequest(nsIChannel* aChannel, nsISupports* aContext, nsresult aStatus, const PRUnichar* aMsg);
|
||||
|
||||
// nsIDocumentLoaderObserver
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand);
|
||||
NS_IMETHOD OnStartDocumentLoad(const char* aCommand, nsIChannel* aChannel,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus, nsIDocumentLoaderObserver* aObserver);
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, const char* aContentType, nsIContentViewer* aViewer);
|
||||
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
@ -108,7 +110,9 @@ public:
|
||||
NS_IMETHOD OnStatus(nsIURI* aURL, const PRUnichar* aMsg);
|
||||
NS_IMETHOD OnStopRequest(nsIURI* aURL, nsresult aStatus, const PRUnichar* aMsg);
|
||||
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand);
|
||||
NS_IMETHOD OnStartDocumentLoad(const char* aCommand, nsIURI *aUrl,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsIStreamListener **aDocListener);
|
||||
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIURI *aUrl, PRInt32 aStatus, nsIDocumentLoaderObserver* aObserver);
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aContentType, nsIContentViewer* aViewer);
|
||||
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
|
@ -20,8 +20,7 @@
|
||||
#include "nsIWebShell.h"
|
||||
#include "nsIURL.h"
|
||||
#ifdef NECKO
|
||||
#include "nsIIOService.h"
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
#include "nsNeckoUtil.h"
|
||||
#endif // NECKO
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsIDocumentLoader.h"
|
||||
@ -412,18 +411,7 @@ GtkMozillaContainer::StartStream(const char *base_url, const char *action,
|
||||
#ifndef NECKO
|
||||
rv = NS_NewURL(&url, url_str, NULL, mWebShell);
|
||||
#else
|
||||
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIURI *uri = nsnull;
|
||||
char *uriStr = url_str.ToNewCString();
|
||||
if (!uriStr) return NS_ERROR_OUT_OF_MEMORY;
|
||||
rv = service->NewURI(uriStr, nsnull, &uri);
|
||||
nsCRT::uriStr);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = uri->QueryInterface(nsIURI::GetIID(), (void**)&url);
|
||||
NS_RELEASE(uri);
|
||||
rv = NS_NewURI(&url, url_str, NULL); // XXX where should the container go? (mWebShell)
|
||||
#endif // NECKO
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
@ -39,6 +39,7 @@ class nsIStreamListener;
|
||||
class nsIStreamObserver;
|
||||
class nsIDocumentLoaderObserver;
|
||||
class nsIDocument;
|
||||
class nsIChannel;
|
||||
|
||||
/* f43ba260-0737-11d2-beb9-00805f8a66dc */
|
||||
#define NS_IDOCUMENTLOADERFACTORY_IID \
|
||||
@ -65,9 +66,13 @@ class nsIDocumentLoaderFactory : public nsISupports
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IDOCUMENTLOADERFACTORY_IID)
|
||||
|
||||
NS_IMETHOD CreateInstance(nsIURI* aURL,
|
||||
NS_IMETHOD CreateInstance(const char *aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* aChannel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
const char *aCommand,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsISupports* aExtraInfo,
|
||||
nsIStreamListener** aDocListenerResult,
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
* server has been established.
|
||||
*/
|
||||
#ifdef NECKO
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, const char* aContentType,
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel,
|
||||
nsIContentViewer* aViewer) = 0;
|
||||
#else
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aContentType,
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include "nsINetService.h"
|
||||
#include "nsIPostToServer.h"
|
||||
#else
|
||||
#include "nsIIOService.h"
|
||||
#include "nsILoadGroup.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
#include "nsIURL.h"
|
||||
@ -89,6 +90,8 @@ static NS_DEFINE_IID(kRefreshURLIID, NS_IREFRESHURL_IID);
|
||||
static NS_DEFINE_IID(kILoadGroupIID, NS_ILOADGROUP_IID);
|
||||
static NS_DEFINE_IID(kINetServiceIID, NS_INETSERVICE_IID);
|
||||
static NS_DEFINE_IID(kNetServiceCID, NS_NETSERVICE_CID);
|
||||
#else
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
#endif // NECKO
|
||||
static NS_DEFINE_IID(kIContentViewerContainerIID, NS_ICONTENT_VIEWER_CONTAINER_IID);
|
||||
static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID);
|
||||
@ -128,8 +131,6 @@ public:
|
||||
|
||||
nsresult Bind(nsIURI* aURL, nsIStreamListener* aListener);
|
||||
|
||||
nsresult Stop(void);
|
||||
|
||||
#ifdef NECKO
|
||||
// nsIStreamObserver methods:
|
||||
NS_IMETHOD OnStartRequest(nsIChannel* channel, nsISupports *ctxt);
|
||||
@ -144,6 +145,8 @@ public:
|
||||
NS_IMETHOD OnProgress(nsIChannel* channel, nsISupports *ctxt, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
NS_IMETHOD OnStatus(nsIChannel* channel, nsISupports *ctxt, const PRUnichar *aMsg);
|
||||
#else
|
||||
nsresult Stop(void);
|
||||
|
||||
/* nsIStreamListener interface methods... */
|
||||
NS_IMETHOD GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo);
|
||||
NS_IMETHOD OnProgress(nsIURI* aURL, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
@ -164,7 +167,9 @@ protected:
|
||||
|
||||
protected:
|
||||
char* m_Command;
|
||||
#ifndef NECKO
|
||||
nsIURI* m_Url;
|
||||
#endif
|
||||
nsIContentViewerContainer* m_Container;
|
||||
nsISupports* m_ExtraInfo;
|
||||
nsIStreamObserver* m_Observer;
|
||||
@ -183,7 +188,7 @@ protected:
|
||||
#ifndef NECKO
|
||||
class nsDocLoaderImpl : public nsIDocumentLoader, public nsILoadGroup
|
||||
#else
|
||||
class nsDocLoaderImpl : public nsIDocumentLoader
|
||||
class nsDocLoaderImpl : public nsIDocumentLoader, public nsIStreamObserver
|
||||
#endif // NECKO
|
||||
{
|
||||
public:
|
||||
@ -267,8 +272,8 @@ public:
|
||||
nsIChannel* channel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
#endif
|
||||
nsIContentViewer* aViewer);
|
||||
|
||||
void FireOnProgressURLLoad(nsIDocumentLoader* aLoadInitiator,
|
||||
@ -309,12 +314,21 @@ public:
|
||||
#endif
|
||||
|
||||
#ifdef NECKO
|
||||
// nsIStreamObserver methods: (for observing the load group)
|
||||
NS_IMETHOD OnStartRequest(nsIChannel *channel, nsISupports *ctxt);
|
||||
NS_IMETHOD OnStopRequest(nsIChannel *channel, nsISupports *ctxt,
|
||||
nsresult status, const PRUnichar *errorMsg);
|
||||
|
||||
nsILoadGroup* GetLoadGroup() { return mLoadGroup; }
|
||||
#endif
|
||||
|
||||
nsresult CreateContentViewer(nsIURI* aURL,
|
||||
nsresult CreateContentViewer(const char *aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* channel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
const char *aCommand,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsISupports* aExtraInfo,
|
||||
nsIStreamListener** aDocListener,
|
||||
@ -327,11 +341,12 @@ protected:
|
||||
nsIDocumentLoader* aLoadInitiator,
|
||||
PRInt32 aStatus);
|
||||
|
||||
|
||||
#ifndef NECKO
|
||||
private:
|
||||
static PRBool StopBindInfoEnumerator (nsISupports* aElement, void* aData);
|
||||
static PRBool StopDocLoaderEnumerator(void* aElement, void* aData);
|
||||
static PRBool IsBusyEnumerator(void* aElement, void* aData);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
@ -345,27 +360,23 @@ protected:
|
||||
nsIChannel* mDocumentChannel; // [OWNER] ???compare with document
|
||||
#else
|
||||
nsIURI* mDocumentUrl; // [OWNER] ???compare with document
|
||||
#endif
|
||||
nsCOMPtr<nsISupportsArray> m_LoadingDocsList;
|
||||
|
||||
nsVoidArray mChildGroupList;
|
||||
nsVoidArray mDocObservers;
|
||||
#ifdef NECKO
|
||||
nsLoadFlags m_LoadAttrib;
|
||||
#else
|
||||
nsCOMPtr<nsILoadAttribs> m_LoadAttrib;
|
||||
#endif
|
||||
nsCOMPtr<nsIStreamObserver> mStreamObserver; // ??? unclear what to do here
|
||||
nsIContentViewerContainer* mContainer; // [WEAK] it owns me!
|
||||
|
||||
nsDocLoaderImpl* mParent; // [OWNER] but upside down ownership model
|
||||
// needs to be fixed***
|
||||
/*
|
||||
* The following counts are for the current document loader only. They
|
||||
* do not take into account URLs being loaded by child document loaders.
|
||||
*/
|
||||
PRInt32 mForegroundURLs;
|
||||
PRInt32 mTotalURLs;
|
||||
nsCOMPtr<nsISupportsArray> m_LoadingDocsList;
|
||||
#endif
|
||||
|
||||
nsVoidArray mDocObservers;
|
||||
nsCOMPtr<nsIStreamObserver> mStreamObserver; // ??? unclear what to do here
|
||||
nsIContentViewerContainer* mContainer; // [WEAK] it owns me!
|
||||
|
||||
nsDocLoaderImpl* mParent; // [OWNER] but upside down ownership model
|
||||
// needs to be fixed***
|
||||
/*
|
||||
* This flag indicates that the loader is loading a document. It is set
|
||||
* from the call to LoadDocument(...) until the OnConnectionsComplete(...)
|
||||
@ -393,17 +404,20 @@ nsDocLoaderImpl::nsDocLoaderImpl()
|
||||
mDocumentChannel = nsnull;
|
||||
#else
|
||||
mDocumentUrl = nsnull;
|
||||
mForegroundURLs = 0;
|
||||
mTotalURLs = 0;
|
||||
#endif
|
||||
mParent = nsnull;
|
||||
mContainer = nsnull;
|
||||
mForegroundURLs = 0;
|
||||
mTotalURLs = 0;
|
||||
|
||||
mIsLoadingDocument = PR_FALSE;
|
||||
|
||||
#ifdef NECKO
|
||||
m_LoadAttrib = nsIChannel::LOAD_NORMAL;
|
||||
#endif
|
||||
// XXX I wanted to pull this initialization code out of this constructor
|
||||
// because it could fail... but the web shell uses this implementation
|
||||
// as a service too. Since it's a service, it really can't have any
|
||||
// initialization. We're sort of screwed here.
|
||||
nsresult rv = Init();
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv), "nsDocLoaderImpl::Init failed");
|
||||
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
("DocLoader:%p: created.\n", this));
|
||||
@ -414,12 +428,12 @@ nsDocLoaderImpl::Init()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(m_LoadingDocsList));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#ifdef NECKO
|
||||
rv = NS_NewLoadGroup(nsnull, nsnull, getter_AddRefs(mLoadGroup));
|
||||
rv = NS_NewLoadGroup(nsnull, this, nsnull, getter_AddRefs(mLoadGroup));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#else
|
||||
rv = NS_NewISupportsArray(getter_AddRefs(m_LoadingDocsList));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = NS_NewLoadAttribs(getter_AddRefs(m_LoadAttrib));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif
|
||||
@ -446,8 +460,9 @@ nsDocLoaderImpl::~nsDocLoaderImpl()
|
||||
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
("DocLoader:%p: deleted.\n", this));
|
||||
|
||||
#ifndef NECKO
|
||||
NS_PRECONDITION((0 == mChildGroupList.Count()), "Document loader has children...");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@ -473,6 +488,12 @@ nsDocLoaderImpl::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
#else
|
||||
if (aIID.Equals(kIStreamObserverIID)) {
|
||||
*aInstancePtr = (void*)(nsIStreamObserver*)this;
|
||||
NS_ADDREF_THIS();
|
||||
return NS_OK;
|
||||
}
|
||||
#endif // NECKO
|
||||
return NS_NOINTERFACE;
|
||||
}
|
||||
@ -495,8 +516,6 @@ nsDocLoaderImpl::CreateDocumentLoader(nsIDocumentLoader** anInstance)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
rv = newLoader->Init();
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = newLoader->QueryInterface(kIDocumentLoaderIID, (void**)anInstance);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
@ -513,9 +532,13 @@ nsDocLoaderImpl::CreateDocumentLoader(nsIDocumentLoader** anInstance)
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsDocLoaderImpl::CreateContentViewer(nsIURI* aURL,
|
||||
nsDocLoaderImpl::CreateContentViewer(const char *aCommand,
|
||||
#ifdef NECKO
|
||||
nsIChannel* channel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
const char *aCommand,
|
||||
nsIContentViewerContainer* aContainer,
|
||||
nsISupports* aExtraInfo,
|
||||
nsIStreamListener** aDocListenerResult,
|
||||
@ -543,7 +566,14 @@ nsDocLoaderImpl::CreateContentViewer(nsIURI* aURL,
|
||||
}
|
||||
|
||||
// Now create an instance of the content viewer
|
||||
rv = factory->CreateInstance(aURL, aContentType, aCommand, aContainer,
|
||||
rv = factory->CreateInstance(aCommand,
|
||||
#ifdef NECKO
|
||||
channel,
|
||||
#else
|
||||
aURL,
|
||||
#endif
|
||||
aContentType,
|
||||
aContainer,
|
||||
aExtraInfo, aDocListenerResult,
|
||||
aDocViewerResult);
|
||||
NS_RELEASE(factory);
|
||||
@ -590,18 +620,19 @@ nsDocLoaderImpl::LoadDocument(const nsString& aURLSpec,
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
NS_ADDREF(loader);
|
||||
loader->Init(this, // DocLoader
|
||||
aCommand, // Command
|
||||
aContainer, // Viewer Container
|
||||
aExtraInfo, // Extra Info
|
||||
anObserver); // Observer
|
||||
|
||||
#ifndef NECKO
|
||||
/* The DocumentBindInfo reference is only held by the Array... */
|
||||
m_LoadingDocsList->AppendElement((nsIStreamListener *)loader);
|
||||
|
||||
/* Initialize the URL counters... */
|
||||
NS_PRECONDITION(((mTotalURLs == 0) && (mForegroundURLs == 0)), "DocuemntLoader is busy...");
|
||||
#ifndef NECKO
|
||||
NS_PRECONDITION(((mTotalURLs == 0) && (mForegroundURLs == 0)), "DocumentLoader is busy...");
|
||||
rv = m_LoadAttrib->GetLoadType(&loadType);
|
||||
if (NS_FAILED(rv)) {
|
||||
loadType = nsURLLoadNormal;
|
||||
@ -609,8 +640,8 @@ nsDocLoaderImpl::LoadDocument(const nsString& aURLSpec,
|
||||
if (nsURLLoadBackground != loadType) {
|
||||
mForegroundURLs = 1;
|
||||
}
|
||||
#endif
|
||||
mTotalURLs = 1;
|
||||
#endif
|
||||
/*
|
||||
* Set the flag indicating that the document loader is in the process of
|
||||
* loading a document. This flag will remain set until the
|
||||
@ -618,9 +649,7 @@ nsDocLoaderImpl::LoadDocument(const nsString& aURLSpec,
|
||||
*/
|
||||
mIsLoadingDocument = PR_TRUE;
|
||||
|
||||
#ifdef NECKO
|
||||
m_LoadAttrib = aType;
|
||||
#else
|
||||
#ifndef NECKO
|
||||
m_LoadAttrib->SetReloadType(aType);
|
||||
// If we've got special loading instructions, mind them.
|
||||
if ((aType == nsURLReloadBypassProxy) ||
|
||||
@ -637,6 +666,7 @@ nsDocLoaderImpl::LoadDocument(const nsString& aURLSpec,
|
||||
rv = loader->Bind(aURLSpec, aPostData, nsnull);
|
||||
|
||||
done:
|
||||
NS_RELEASE(loader);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -667,21 +697,24 @@ nsDocLoaderImpl::LoadSubDocument(const nsString& aURLSpec,
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
return rv;
|
||||
}
|
||||
NS_ADDREF(loader);
|
||||
loader->Init(this, // DocLoader
|
||||
nsnull, // Command
|
||||
nsnull, // Viewer Container
|
||||
aExtraInfo, // Extra Info
|
||||
mStreamObserver); // Observer
|
||||
|
||||
#ifndef NECKO
|
||||
/* The DocumentBindInfo reference is only held by the Array... */
|
||||
m_LoadingDocsList->AppendElement((nsIStreamListener *)loader);
|
||||
|
||||
/* Increment the URL counters... */
|
||||
mForegroundURLs++;
|
||||
mTotalURLs++;
|
||||
|
||||
rv = loader->Bind(aURLSpec, nsnull, nsnull);
|
||||
#endif
|
||||
|
||||
rv = loader->Bind(aURLSpec, nsnull, nsnull);
|
||||
NS_RELEASE(loader);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -710,10 +743,10 @@ nsDocLoaderImpl::Stop(void)
|
||||
*/
|
||||
mChildGroupList.EnumerateForwards(nsDocLoaderImpl::StopDocLoaderEnumerator, nsnull);
|
||||
|
||||
#endif
|
||||
/* Reset the URL counters... */
|
||||
mForegroundURLs = 0;
|
||||
mTotalURLs = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Release the Stream Observer...
|
||||
@ -728,6 +761,9 @@ nsDocLoaderImpl::Stop(void)
|
||||
NS_IMETHODIMP
|
||||
nsDocLoaderImpl::IsBusy(PRBool& aResult)
|
||||
{
|
||||
#ifdef NECKO
|
||||
return mLoadGroup->IsPending(&aResult);
|
||||
#else
|
||||
aResult = PR_FALSE;
|
||||
|
||||
/* If this document loader is busy? */
|
||||
@ -741,6 +777,7 @@ nsDocLoaderImpl::IsBusy(PRBool& aResult)
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -838,15 +875,13 @@ nsDocLoaderImpl::CreateURL(nsIURI** aInstancePtrResult,
|
||||
rv = NS_NewURI(&url, aURLSpec, aBaseURL);
|
||||
#else
|
||||
rv = NS_NewURL(&url, aURLSpec, aBaseURL, aContainer, this);
|
||||
#endif
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
#ifndef NECKO // set later after we open the channel
|
||||
nsCOMPtr<nsILoadAttribs> loadAttributes;
|
||||
rv = url->GetLoadAttribs(getter_AddRefs(loadAttributes));
|
||||
if (loadAttributes)
|
||||
loadAttributes->Clone(m_LoadAttrib);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
*aInstancePtrResult = url;
|
||||
}
|
||||
|
||||
@ -884,17 +919,18 @@ nsDocLoaderImpl::OpenStream(nsIURI *aUrl, nsIStreamListener *aConsumer)
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
goto done;
|
||||
}
|
||||
NS_ADDREF(loader);
|
||||
loader->Init(this, // DocLoader
|
||||
nsnull, // Command
|
||||
mContainer, // Viewer Container
|
||||
nsnull, // Extra Info
|
||||
mStreamObserver); // Observer
|
||||
|
||||
#ifndef NECKO // done in the load group now
|
||||
/* The DocumentBindInfo reference is only held by the Array... */
|
||||
m_LoadingDocsList->AppendElement(((nsISupports*)(nsIStreamObserver*)loader));
|
||||
|
||||
/* Update the URL counters... */
|
||||
#ifndef NECKO // do later after we call NS_OpenURI
|
||||
nsILoadAttribs* loadAttributes;
|
||||
|
||||
rv = aUrl->GetLoadAttribs(&loadAttributes);
|
||||
@ -909,11 +945,12 @@ nsDocLoaderImpl::OpenStream(nsIURI *aUrl, nsIStreamListener *aConsumer)
|
||||
if (nsURLLoadBackground != loadType) {
|
||||
mForegroundURLs += 1;
|
||||
}
|
||||
#endif
|
||||
mTotalURLs += 1;
|
||||
#endif
|
||||
|
||||
rv = loader->Bind(aUrl, aConsumer);
|
||||
done:
|
||||
NS_RELEASE(loader);
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -926,7 +963,7 @@ nsDocLoaderImpl::GetDefaultLoadAttributes(nsILoadAttribs*& aLoadAttribs)
|
||||
#endif
|
||||
{
|
||||
#ifdef NECKO
|
||||
*aLoadAttribs = m_LoadAttrib;
|
||||
return mLoadGroup->GetDefaultLoadAttributes(aLoadAttribs);
|
||||
#else
|
||||
aLoadAttribs = m_LoadAttrib;
|
||||
NS_IF_ADDREF(aLoadAttribs);
|
||||
@ -944,10 +981,9 @@ nsDocLoaderImpl::SetDefaultLoadAttributes(nsILoadAttribs* aLoadAttribs)
|
||||
#endif
|
||||
{
|
||||
#ifdef NECKO
|
||||
m_LoadAttrib = aLoadAttribs;
|
||||
return mLoadGroup->SetDefaultLoadAttributes(aLoadAttribs);
|
||||
#else
|
||||
m_LoadAttrib->Clone(aLoadAttribs);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Now set the default attributes for all child DocumentLoaders...
|
||||
@ -959,28 +995,57 @@ nsDocLoaderImpl::SetDefaultLoadAttributes(nsILoadAttribs* aLoadAttribs)
|
||||
nsILoadGroup* child = (nsILoadGroup*)mChildGroupList.ElementAt(index);
|
||||
child->SetDefaultLoadAttributes(m_LoadAttrib);
|
||||
}
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#ifdef NECKO
|
||||
NS_IMETHODIMP
|
||||
nsDocLoaderImpl::OnStartRequest(nsIChannel *channel, nsISupports *ctxt)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = channel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// FireOnStartDocumentLoad(this, uri, "load"); // XXX fix command
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocLoaderImpl::OnStopRequest(nsIChannel *channel, nsISupports *ctxt,
|
||||
nsresult status, const PRUnichar *errorMsg)
|
||||
{
|
||||
FireOnEndDocumentLoad(this, status);
|
||||
return NS_OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocLoaderImpl::AddChildGroup(nsILoadGroup* aGroup)
|
||||
{
|
||||
#ifdef NECKO
|
||||
return mLoadGroup->AddSubGroup(aGroup);
|
||||
#else
|
||||
mChildGroupList.AppendElement(aGroup);
|
||||
return NS_OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocLoaderImpl::RemoveChildGroup(nsILoadGroup* aGroup)
|
||||
{
|
||||
#ifdef NECKO
|
||||
return mLoadGroup->RemoveSubGroup(aGroup);
|
||||
#else
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (PR_FALSE == mChildGroupList.RemoveElement(aGroup)) {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
return rv;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@ -1057,8 +1122,8 @@ void nsDocLoaderImpl::FireOnStartURLLoad(nsIDocumentLoader* aLoadInitiator,
|
||||
nsIChannel* channel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
#endif
|
||||
nsIContentViewer* aViewer)
|
||||
{
|
||||
PRInt32 count = mDocObservers.Count();
|
||||
@ -1070,7 +1135,7 @@ void nsDocLoaderImpl::FireOnStartURLLoad(nsIDocumentLoader* aLoadInitiator,
|
||||
for (index = 0; index < count; index++) {
|
||||
nsIDocumentLoaderObserver* observer = (nsIDocumentLoaderObserver*)mDocObservers.ElementAt(index);
|
||||
#ifdef NECKO
|
||||
observer->OnStartURLLoad(aLoadInitiator, channel, aContentType, aViewer);
|
||||
observer->OnStartURLLoad(aLoadInitiator, channel, aViewer);
|
||||
#else
|
||||
observer->OnStartURLLoad(aLoadInitiator, aURL, aContentType, aViewer);
|
||||
#endif
|
||||
@ -1081,7 +1146,7 @@ void nsDocLoaderImpl::FireOnStartURLLoad(nsIDocumentLoader* aLoadInitiator,
|
||||
*/
|
||||
if (nsnull != mParent) {
|
||||
#ifdef NECKO
|
||||
mParent->FireOnStartURLLoad(aLoadInitiator, channel, aContentType, aViewer);
|
||||
mParent->FireOnStartURLLoad(aLoadInitiator, channel, aViewer);
|
||||
#else
|
||||
mParent->FireOnStartURLLoad(aLoadInitiator, aURL, aContentType, aViewer);
|
||||
#endif
|
||||
@ -1208,19 +1273,24 @@ void nsDocLoaderImpl::LoadURLComplete(nsIURI* aURL, nsISupports* aBindInfo, PRIn
|
||||
* If the entry is not found in the list, then it must have been cancelled
|
||||
* via Stop(...). So ignore just it...
|
||||
*/
|
||||
#ifdef NECKO
|
||||
#if defined(DEBUG)
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
nsresult rv = channel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
char* buffer;
|
||||
rv = uri->GetSpec(&buffer);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
("DocLoader:%p: LoadURLComplete(...) called for %s\n",
|
||||
this, buffer));
|
||||
nsCRT::free(buffer);
|
||||
}
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
#else
|
||||
PRBool removed = m_LoadingDocsList->RemoveElement(aBindInfo);
|
||||
if (removed) {
|
||||
#ifdef NECKO
|
||||
PRUint32 loadAttribs;
|
||||
nsresult rv;
|
||||
rv = channel->GetLoadAttributes(&loadAttribs);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
if (loadAttribs & nsIChannel::LOAD_QUIET) {
|
||||
mForegroundURLs--;
|
||||
isForegroundURL = PR_TRUE;
|
||||
}
|
||||
}
|
||||
#else
|
||||
nsILoadAttribs* loadAttributes;
|
||||
nsURLLoadType loadType = nsURLLoadNormal;
|
||||
|
||||
@ -1236,36 +1306,21 @@ void nsDocLoaderImpl::LoadURLComplete(nsIURI* aURL, nsISupports* aBindInfo, PRIn
|
||||
mForegroundURLs--;
|
||||
isForegroundURL = PR_TRUE;
|
||||
}
|
||||
#endif
|
||||
mTotalURLs -= 1;
|
||||
|
||||
NS_ASSERTION(mTotalURLs >= mForegroundURLs,
|
||||
"Foreground URL count is wrong.");
|
||||
|
||||
#if defined(DEBUG)
|
||||
#ifdef NECKO
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
rv = channel->GetURI(getter_AddRefs(uri));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
char* buffer;
|
||||
rv = uri->GetSpec(&buffer);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
("DocLoader:%p: LoadURLComplete(...) called for %s; Foreground URLs: %d; Total URLs: %d\n",
|
||||
this, buffer, mForegroundURLs, mTotalURLs));
|
||||
nsCRT::free(buffer);
|
||||
}
|
||||
}
|
||||
#else
|
||||
const char* buffer;
|
||||
|
||||
aURL->GetSpec(&buffer);
|
||||
PR_LOG(gDocLoaderLog, PR_LOG_DEBUG,
|
||||
("DocLoader:%p: LoadURLComplete(...) called for %s; Foreground URLs: %d; Total URLs: %d\n",
|
||||
this, buffer, mForegroundURLs, mTotalURLs));
|
||||
#endif
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fire the OnEndURLLoad notification to any observers...
|
||||
@ -1328,6 +1383,7 @@ void nsDocLoaderImpl::SetDocumentUrl(nsIURI* aUrl)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef NECKO
|
||||
PRBool nsDocLoaderImpl::StopBindInfoEnumerator(nsISupports* aElement, void* aData)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -1372,6 +1428,7 @@ PRBool nsDocLoaderImpl::IsBusyEnumerator(void* aElement, void* aData)
|
||||
|
||||
return !(*result);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* nsDocumentBindInfo implementation...
|
||||
@ -1382,7 +1439,9 @@ nsDocumentBindInfo::nsDocumentBindInfo()
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
m_Command = nsnull;
|
||||
#ifndef NECKO
|
||||
m_Url = nsnull;
|
||||
#endif
|
||||
m_Container = nsnull;
|
||||
m_ExtraInfo = nsnull;
|
||||
m_Observer = nsnull;
|
||||
@ -1398,8 +1457,9 @@ nsDocumentBindInfo::Init(nsDocLoaderImpl* aDocLoader,
|
||||
nsISupports* aExtraInfo,
|
||||
nsIStreamObserver* anObserver)
|
||||
{
|
||||
|
||||
#ifndef NECKO
|
||||
m_Url = nsnull;
|
||||
#endif
|
||||
m_NextStream = nsnull;
|
||||
m_Command = (nsnull != aCommand) ? PL_strdup(aCommand) : nsnull;
|
||||
|
||||
@ -1427,7 +1487,9 @@ nsDocumentBindInfo::~nsDocumentBindInfo()
|
||||
m_Command = nsnull;
|
||||
|
||||
NS_RELEASE (m_DocLoader);
|
||||
#ifndef NECKO
|
||||
NS_IF_RELEASE(m_Url);
|
||||
#endif
|
||||
NS_IF_RELEASE(m_NextStream);
|
||||
NS_IF_RELEASE(m_Container);
|
||||
NS_IF_RELEASE(m_Observer);
|
||||
@ -1519,10 +1581,7 @@ nsresult nsDocumentBindInfo::Bind(const nsString& aURLSpec,
|
||||
/*
|
||||
* Set the URL has the current "document" being loaded...
|
||||
*/
|
||||
#ifdef NECKO
|
||||
// m_DocLoader->SetDocumentChannel(channel);
|
||||
//NS_ASSERTION(0, "help");
|
||||
#else
|
||||
#ifndef NECKO
|
||||
m_DocLoader->SetDocumentUrl(url);
|
||||
#endif
|
||||
/*
|
||||
@ -1544,8 +1603,10 @@ nsresult nsDocumentBindInfo::Bind(nsIURI* aURL, nsIStreamListener* aListener)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
#ifndef NECKO
|
||||
m_Url = aURL;
|
||||
NS_ADDREF(m_Url);
|
||||
#endif
|
||||
|
||||
#if defined(DEBUG)
|
||||
#ifdef NECKO
|
||||
@ -1586,13 +1647,21 @@ nsresult nsDocumentBindInfo::Bind(nsIURI* aURL, nsIStreamListener* aListener)
|
||||
if (m_DocLoader) {
|
||||
loadGroup = m_DocLoader->GetLoadGroup();
|
||||
}
|
||||
rv = NS_OpenURI(this, nsnull, m_Url, loadGroup);
|
||||
|
||||
nsCOMPtr<nsIChannel> channel;
|
||||
rv = NS_OpenURI(getter_AddRefs(channel), aURL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
m_DocLoader->SetDocumentChannel(channel);
|
||||
|
||||
rv = channel->AsyncRead(0, -1, nsnull, this, loadGroup);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
#endif // NECKO
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
#ifndef NECKO
|
||||
nsresult nsDocumentBindInfo::Stop(void)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -1638,7 +1707,6 @@ nsresult nsDocumentBindInfo::Stop(void)
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifndef NECKO
|
||||
NS_METHOD nsDocumentBindInfo::GetBindInfo(nsIURI* aURL, nsStreamBindingInfo* aInfo)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
@ -1808,9 +1876,13 @@ nsDocumentBindInfo::OnStartRequest(nsIURI* aURL, const char *aContentType)
|
||||
* (and viewer) of the appropriate type...
|
||||
*/
|
||||
if (m_DocLoader) {
|
||||
rv = m_DocLoader->CreateContentViewer(m_Url,
|
||||
rv = m_DocLoader->CreateContentViewer(m_Command,
|
||||
#ifdef NECKO
|
||||
channel,
|
||||
#else
|
||||
m_Url,
|
||||
#endif
|
||||
aContentType,
|
||||
m_Command,
|
||||
m_Container,
|
||||
m_ExtraInfo,
|
||||
&m_NextStream,
|
||||
@ -1867,7 +1939,7 @@ nsDocumentBindInfo::OnStartRequest(nsIURI* aURL, const char *aContentType)
|
||||
m_Container->GetContentViewer(&viewer);
|
||||
}
|
||||
#ifdef NECKO
|
||||
m_DocLoader->FireOnStartURLLoad((nsIDocumentLoader *)m_DocLoader, channel, aContentType, viewer);
|
||||
m_DocLoader->FireOnStartURLLoad((nsIDocumentLoader *)m_DocLoader, channel, viewer);
|
||||
#else
|
||||
m_DocLoader->FireOnStartURLLoad((nsIDocumentLoader *)m_DocLoader, m_Url, aContentType, viewer);
|
||||
#endif
|
||||
@ -1885,7 +1957,9 @@ nsDocumentBindInfo::OnStartRequest(nsIURI* aURL, const char *aContentType)
|
||||
|
||||
done:
|
||||
NS_IF_RELEASE(viewer);
|
||||
|
||||
#ifdef NECKO
|
||||
nsCRT::free(aContentType);
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -1985,15 +2059,14 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIURI* aURL, nsresult aStatus, cons
|
||||
nsCRT::free(spec);
|
||||
#endif
|
||||
|
||||
#ifdef NECKO
|
||||
if (NS_FAILED(aStatus)) {
|
||||
#ifdef NECKO
|
||||
char *url;
|
||||
if (NS_SUCCEEDED(rv))
|
||||
aURL->GetSpec(&url);
|
||||
else
|
||||
url = nsCRT::strdup("");
|
||||
#else
|
||||
if (NS_FAILED(aStatus)) {
|
||||
const char *url;
|
||||
if (nsnull != aURL)
|
||||
aURL->GetSpec(&url);
|
||||
@ -2001,7 +2074,7 @@ NS_METHOD nsDocumentBindInfo::OnStopRequest(nsIURI* aURL, nsresult aStatus, cons
|
||||
url = "";
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_pnunn
|
||||
#if DEBUG
|
||||
cerr << "nsDocumentBindInfo::OnStopRequest: Load of URL '" << url << "' failed. Error code: "
|
||||
<< NS_ERROR_GET_CODE(aStatus) << "\n";
|
||||
#endif
|
||||
@ -2157,3 +2230,4 @@ nsresult NS_NewDocLoaderServiceFactory(nsIFactory** aResult)
|
||||
*aResult = factory;
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "nsIStreamListener.h"
|
||||
#ifdef NECKO
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsNeckoUtil.h"
|
||||
#else
|
||||
#include "nsINetSupport.h"
|
||||
#include "nsIRefreshUrl.h"
|
||||
@ -310,9 +311,9 @@ public:
|
||||
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
PRInt32 aStatus,
|
||||
nsIDocumentLoaderObserver * );
|
||||
nsIDocumentLoaderObserver * );
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel, const char* aContentType,
|
||||
nsIChannel* channel,
|
||||
nsIContentViewer* aViewer);
|
||||
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel, PRUint32 aProgress,
|
||||
@ -1861,18 +1862,8 @@ nsWebShell::DoLoadURL(const nsString& aUrlSpec,
|
||||
nsCOMPtr<nsIURI> url;
|
||||
#ifndef NECKO
|
||||
rv = NS_NewURL(getter_AddRefs(url), aUrlSpec);
|
||||
#else
|
||||
NS_WITH_SERVICE(nsIIOService, service, kIOServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsIURI *uri = nsnull;
|
||||
char *uriSpec = aUrlSpec.ToNewCString();
|
||||
rv = service->NewURI(uriSpec, nsnull, &uri);
|
||||
nsCRT::free(uriSpec);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = uri->QueryInterface(nsIURI::GetIID(), (void**)&url);
|
||||
NS_RELEASE(uri);
|
||||
#else
|
||||
rv = NS_NewURI(getter_AddRefs(url), aUrlSpec);
|
||||
#endif // NECKO
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (url && docURL && EqualBaseURLs(docURL, url)) {
|
||||
@ -1960,13 +1951,16 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
||||
#endif
|
||||
const PRUint32 aLocalIP)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
PRInt32 colon, fSlash;
|
||||
PRUnichar port;
|
||||
nsAutoString urlSpec;
|
||||
convertFileToURL(nsString(aURLSpec), urlSpec);
|
||||
|
||||
//#ifdef NECKO
|
||||
// nsCOMPtr<nsIURI> url;
|
||||
// rv = NS_NewURI(getter_AddRefs(url), urlSpec);
|
||||
// if (NS_FAILED(rv)) return rv;
|
||||
//#else
|
||||
PRInt32 colon, fSlash;
|
||||
PRUnichar port;
|
||||
fSlash=urlSpec.Find('/');
|
||||
|
||||
// if no scheme (protocol) is found, assume http.
|
||||
@ -2102,6 +2096,7 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec,
|
||||
nsAutoString newURL(urlString);
|
||||
|
||||
return DoLoadURL(newURL, aCommand, aPostData, aType, aLocalIP);
|
||||
//#endif
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsWebShell::Stop(void)
|
||||
@ -3037,8 +3032,8 @@ nsWebShell::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
#else
|
||||
nsIURI* aURL,
|
||||
#endif
|
||||
const char* aContentType,
|
||||
#endif
|
||||
nsIContentViewer* aViewer)
|
||||
{
|
||||
nsresult rv;
|
||||
@ -3078,7 +3073,7 @@ nsWebShell::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
if ((nsnull != mContainer) && (nsnull != mDocLoaderObserver))
|
||||
{
|
||||
#ifdef NECKO
|
||||
mDocLoaderObserver->OnStartURLLoad(mDocLoader, channel, aContentType, aViewer);
|
||||
mDocLoaderObserver->OnStartURLLoad(mDocLoader, channel, aViewer);
|
||||
#else
|
||||
mDocLoaderObserver->OnStartURLLoad(mDocLoader, aURL, aContentType, aViewer);
|
||||
#endif
|
||||
@ -3772,8 +3767,8 @@ PRBool nsWebShellFactory::mStartedServices = PR_FALSE;
|
||||
void
|
||||
nsWebShellFactory::StartServices()
|
||||
{
|
||||
// XXX TEMPORARY Till we have real pluggable protocol handlers
|
||||
#ifndef NECKO
|
||||
// XXX TEMPORARY Till we have real pluggable protocol handlers
|
||||
NET_InitJavaScriptProtocol();
|
||||
#endif // NECKO
|
||||
mStartedServices = PR_TRUE;
|
||||
|
@ -329,7 +329,6 @@ NS_IMETHODIMP
|
||||
#ifdef NECKO
|
||||
nsWebCrawler::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
const char* aContentType,
|
||||
nsIContentViewer* aViewer)
|
||||
#else
|
||||
nsWebCrawler::OnStartURLLoad(nsIDocumentLoader* loader, nsIURI* aURL,
|
||||
|
@ -46,7 +46,7 @@ public:
|
||||
#ifdef NECKO
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand);
|
||||
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus, nsIDocumentLoaderObserver* aObserver);
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, const char* aContentType, nsIContentViewer* aViewer);
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsIContentViewer* aViewer);
|
||||
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsString& aMsg);
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus);
|
||||
|
@ -254,6 +254,33 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
|
||||
return NS_NOINTERFACE; \
|
||||
}
|
||||
|
||||
#define NS_IMPL_QUERY_INTERFACE2(_class, _c1, _c2) \
|
||||
NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
|
||||
{ \
|
||||
if (NULL == aInstancePtr) { \
|
||||
return NS_ERROR_NULL_POINTER; \
|
||||
} \
|
||||
\
|
||||
*aInstancePtr = NULL; \
|
||||
\
|
||||
if (aIID.Equals(nsCOMTypeInfo<_c1>::GetIID())) { \
|
||||
*aInstancePtr = (void*) ((_c1*)this); \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (aIID.Equals(nsCOMTypeInfo<_c2>::GetIID())) { \
|
||||
*aInstancePtr = (void*) ((_c2*)this); \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID())) { \
|
||||
*aInstancePtr = (void*) ((_c1*)this); \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
return NS_NOINTERFACE; \
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience macro for implementing all nsISupports methods for
|
||||
* a simple class.
|
||||
@ -267,6 +294,11 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
|
||||
NS_IMPL_RELEASE(_class) \
|
||||
NS_IMPL_QUERY_INTERFACE(_class,_classiiddef)
|
||||
|
||||
#define NS_IMPL_ISUPPORTS2(_class, _c1, _c2) \
|
||||
NS_IMPL_ADDREF(_class) \
|
||||
NS_IMPL_RELEASE(_class) \
|
||||
NS_IMPL_QUERY_INTERFACE2(_class, _c1, _c2)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
@ -254,6 +254,33 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
|
||||
return NS_NOINTERFACE; \
|
||||
}
|
||||
|
||||
#define NS_IMPL_QUERY_INTERFACE2(_class, _c1, _c2) \
|
||||
NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
|
||||
{ \
|
||||
if (NULL == aInstancePtr) { \
|
||||
return NS_ERROR_NULL_POINTER; \
|
||||
} \
|
||||
\
|
||||
*aInstancePtr = NULL; \
|
||||
\
|
||||
if (aIID.Equals(nsCOMTypeInfo<_c1>::GetIID())) { \
|
||||
*aInstancePtr = (void*) ((_c1*)this); \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (aIID.Equals(nsCOMTypeInfo<_c2>::GetIID())) { \
|
||||
*aInstancePtr = (void*) ((_c2*)this); \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
if (aIID.Equals(nsCOMTypeInfo<nsISupports>::GetIID())) { \
|
||||
*aInstancePtr = (void*) ((_c1*)this); \
|
||||
NS_ADDREF_THIS(); \
|
||||
return NS_OK; \
|
||||
} \
|
||||
return NS_NOINTERFACE; \
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience macro for implementing all nsISupports methods for
|
||||
* a simple class.
|
||||
@ -267,6 +294,11 @@ NS_IMETHODIMP _class::QueryInterface(REFNSIID aIID, void** aInstancePtr) \
|
||||
NS_IMPL_RELEASE(_class) \
|
||||
NS_IMPL_QUERY_INTERFACE(_class,_classiiddef)
|
||||
|
||||
#define NS_IMPL_ISUPPORTS2(_class, _c1, _c2) \
|
||||
NS_IMPL_ADDREF(_class) \
|
||||
NS_IMPL_RELEASE(_class) \
|
||||
NS_IMPL_QUERY_INTERFACE2(_class, _c1, _c2)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
|
@ -65,7 +65,7 @@ int main(int argc, char** argv)
|
||||
#ifndef NECKO
|
||||
ec = NS_OpenURL(url, &in);
|
||||
#else
|
||||
ec = NS_OpenURI(&in, url, nsnull);
|
||||
ec = NS_OpenURI(&in, url);
|
||||
#endif // NECKO
|
||||
if (nsnull == in) {
|
||||
printf("open of url('%s') failed: error=%x\n", urlName, ec);
|
||||
|
@ -1270,7 +1270,7 @@ nsBrowserAppCore::HandleUnknownContentType(nsIDocumentLoader* loader,
|
||||
NS_IMETHODIMP
|
||||
#ifdef NECKO
|
||||
nsBrowserAppCore::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel, const char* aContentType,
|
||||
nsIChannel* channel,
|
||||
nsIContentViewer* aViewer)
|
||||
#else
|
||||
nsBrowserAppCore::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
|
@ -110,7 +110,7 @@ class nsBrowserAppCore : public nsBaseAppCore,
|
||||
#ifdef NECKO
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand);
|
||||
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus, nsIDocumentLoaderObserver* aObserver);
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, const char* aContentType, nsIContentViewer* aViewer);
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsIContentViewer* aViewer);
|
||||
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsString& aMsg);
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus);
|
||||
|
@ -1827,7 +1827,6 @@ NS_IMETHODIMP
|
||||
#ifdef NECKO
|
||||
nsWebShellWindow::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
nsIChannel* channel,
|
||||
const char* aContentType,
|
||||
nsIContentViewer* aViewer)
|
||||
#else
|
||||
nsWebShellWindow::OnStartURLLoad(nsIDocumentLoader* loader,
|
||||
|
@ -142,7 +142,7 @@ public:
|
||||
#ifdef NECKO
|
||||
NS_IMETHOD OnStartDocumentLoad(nsIDocumentLoader* loader, nsIURI* aURL, const char* aCommand);
|
||||
NS_IMETHOD OnEndDocumentLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus, nsIDocumentLoaderObserver* aObserver);
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, const char* aContentType, nsIContentViewer* aViewer);
|
||||
NS_IMETHOD OnStartURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsIContentViewer* aViewer);
|
||||
NS_IMETHOD OnProgressURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
NS_IMETHOD OnStatusURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, nsString& aMsg);
|
||||
NS_IMETHOD OnEndURLLoad(nsIDocumentLoader* loader, nsIChannel* channel, PRInt32 aStatus);
|
||||
|
Loading…
Reference in New Issue
Block a user