Changed GetDocumentLoadGroup(...) to be XPCom complient. This helps prevent leaks when using nsCOMPtrs.

This commit is contained in:
rpotts%netscape.com 1999-09-18 06:20:49 +00:00
parent 59b7aaac23
commit 69eebbead3
11 changed files with 32 additions and 13 deletions

View File

@ -117,7 +117,7 @@ public:
/**
* Return the LoadGroup for the document. May return null.
*/
virtual nsILoadGroup* GetDocumentLoadGroup() const = 0;
NS_IMETHOD GetDocumentLoadGroup(nsILoadGroup** aGroup) const = 0;
/**
* Return the base URL for realtive URLs in the document. May return null (or the document URL).

View File

@ -961,10 +961,12 @@ nsDocument::GetContentType(nsString& aContentType) const
return NS_ERROR_NOT_IMPLEMENTED;
}
nsILoadGroup* nsDocument::GetDocumentLoadGroup() const
NS_IMETHODIMP
nsDocument::GetDocumentLoadGroup(nsILoadGroup **aGroup) const
{
*aGroup = mDocumentLoadGroup;
NS_IF_ADDREF(mDocumentLoadGroup);
return mDocumentLoadGroup;
return NS_OK;
}
NS_IMETHODIMP

View File

@ -148,7 +148,7 @@ public:
/**
* Return the LoadGroup for the document. May return null.
*/
virtual nsILoadGroup* GetDocumentLoadGroup() const;
NS_IMETHOD GetDocumentLoadGroup(nsILoadGroup **aGroup) const;
/**
* Return the base URL for realtive URLs in the document. May return null (or the document URL).

View File

@ -3351,10 +3351,13 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
// onto it as opaque data.
NS_ADDREF(this);
nsCOMPtr<nsILoadGroup> loadGroup;
nsIUnicharStreamLoader* loader;
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
rv = NS_NewUnicharStreamLoader(&loader,
url,
nsCOMPtr<nsILoadGroup>(mDocument->GetDocumentLoadGroup()),
loadGroup,
(nsStreamCompleteFunc)nsDoneLoadingScript,
(void *)this);
NS_RELEASE(url);

View File

@ -1024,8 +1024,11 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
#ifdef NS_DEBUG
mSyncCallback = PR_TRUE;
#endif
nsCOMPtr<nsILoadGroup> loadGroup;
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
result = NS_NewUnicharStreamLoader(&loader, urlClone,
nsCOMPtr<nsILoadGroup>(mDocument->GetDocumentLoadGroup()),
loadGroup,
DoneLoadingStyle, aData);
#ifdef NS_DEBUG
mSyncCallback = PR_FALSE;

View File

@ -117,7 +117,7 @@ public:
/**
* Return the LoadGroup for the document. May return null.
*/
virtual nsILoadGroup* GetDocumentLoadGroup() const = 0;
NS_IMETHOD GetDocumentLoadGroup(nsILoadGroup** aGroup) const = 0;
/**
* Return the base URL for realtive URLs in the document. May return null (or the document URL).

View File

@ -961,10 +961,12 @@ nsDocument::GetContentType(nsString& aContentType) const
return NS_ERROR_NOT_IMPLEMENTED;
}
nsILoadGroup* nsDocument::GetDocumentLoadGroup() const
NS_IMETHODIMP
nsDocument::GetDocumentLoadGroup(nsILoadGroup **aGroup) const
{
*aGroup = mDocumentLoadGroup;
NS_IF_ADDREF(mDocumentLoadGroup);
return mDocumentLoadGroup;
return NS_OK;
}
NS_IMETHODIMP

View File

@ -148,7 +148,7 @@ public:
/**
* Return the LoadGroup for the document. May return null.
*/
virtual nsILoadGroup* GetDocumentLoadGroup() const;
NS_IMETHOD GetDocumentLoadGroup(nsILoadGroup **aGroup) const;
/**
* Return the base URL for realtive URLs in the document. May return null (or the document URL).

View File

@ -3351,10 +3351,13 @@ HTMLContentSink::ProcessSCRIPTTag(const nsIParserNode& aNode)
// onto it as opaque data.
NS_ADDREF(this);
nsCOMPtr<nsILoadGroup> loadGroup;
nsIUnicharStreamLoader* loader;
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
rv = NS_NewUnicharStreamLoader(&loader,
url,
nsCOMPtr<nsILoadGroup>(mDocument->GetDocumentLoadGroup()),
loadGroup,
(nsStreamCompleteFunc)nsDoneLoadingScript,
(void *)this);
NS_RELEASE(url);

View File

@ -1024,8 +1024,11 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
#ifdef NS_DEBUG
mSyncCallback = PR_TRUE;
#endif
nsCOMPtr<nsILoadGroup> loadGroup;
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
result = NS_NewUnicharStreamLoader(&loader, urlClone,
nsCOMPtr<nsILoadGroup>(mDocument->GetDocumentLoadGroup()),
loadGroup,
DoneLoadingStyle, aData);
#ifdef NS_DEBUG
mSyncCallback = PR_FALSE;

View File

@ -1024,8 +1024,11 @@ CSSLoaderImpl::LoadSheet(URLKey& aKey, SheetLoadData* aData)
#ifdef NS_DEBUG
mSyncCallback = PR_TRUE;
#endif
nsCOMPtr<nsILoadGroup> loadGroup;
mDocument->GetDocumentLoadGroup(getter_AddRefs(loadGroup));
result = NS_NewUnicharStreamLoader(&loader, urlClone,
nsCOMPtr<nsILoadGroup>(mDocument->GetDocumentLoadGroup()),
loadGroup,
DoneLoadingStyle, aData);
#ifdef NS_DEBUG
mSyncCallback = PR_FALSE;