adding a loadgroup param

This commit is contained in:
pavlov%netscape.com 2001-02-24 23:45:30 +00:00
parent 160abd03ef
commit 98a0eae111
3 changed files with 29 additions and 9 deletions

View File

@ -26,10 +26,13 @@
interface imgIDecoderObserver;
interface imgIRequest;
interface nsISimpleEnumerator;
interface nsIChannel;
interface nsILoadGroup;
interface nsIStreamListener;
interface nsIURI;
interface nsIChannel;
interface nsISimpleEnumerator;
/**
* imgILoader interface
@ -47,7 +50,7 @@ interface imgILoader : nsISupports
* @param aObserver the observer
* @param cx some random data
*/
imgIRequest loadImage(in nsIURI uri, in imgIDecoderObserver aObserver, in nsISupports cx);
imgIRequest loadImage(in nsIURI uri, in nsILoadGroup aLoadGroup, in imgIDecoderObserver aObserver, in nsISupports cx);
/**
* Start the load and decode of an image.

View File

@ -29,7 +29,7 @@
#include "nsIChannel.h"
#include "nsIIOService.h"
#include "nsIRunnable.h"
#include "nsILoadGroup.h"
#include "nsIStreamListener.h"
#include "nsIURI.h"
@ -74,8 +74,8 @@ imgLoader::~imgLoader()
#endif
}
/* imgIRequest loadImage (in nsIURI uri, in imgIDecoderObserver aObserver, in nsISupports cx); */
NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, imgIDecoderObserver *aObserver, nsISupports *cx, imgIRequest **_retval)
/* imgIRequest loadImage (in nsIURI uri, in nsILoadGroup aLoadGroup, in imgIDecoderObserver aObserver, in nsISupports cx); */
NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, nsILoadGroup *aLoadGroup, imgIDecoderObserver *aObserver, nsISupports *cx, imgIRequest **_retval)
{
#if defined(PR_LOGGING)
nsXPIDLCString spec;
@ -101,8 +101,9 @@ NS_IMETHODIMP imgLoader::LoadImage(nsIURI *aURI, imgIDecoderObserver *aObserver,
ioserv->NewChannelFromURI(aURI, getter_AddRefs(newChannel));
if (!newChannel) return NS_ERROR_FAILURE;
// XXX do we need to SetOwner here?
newChannel->SetOwner(this); // the channel is now holding a strong ref to 'this'
// XXX this only handles the first load of the image... ugh
if (aLoadGroup)
newChannel->SetLoadGroup(aLoadGroup);
nsCOMPtr<imgIRequest> req(do_CreateInstance(kImageRequestCID));
request = NS_REINTERPRET_CAST(imgRequest*, req.get());

View File

@ -26,6 +26,7 @@
#include "nsXPIDLString.h"
#include "nsIChannel.h"
#include "nsIHTTPChannel.h"
#include "nsIInputStream.h"
#include "imgILoader.h"
#include "nsIComponentManager.h"
@ -378,7 +379,7 @@ NS_IMETHODIMP imgRequest::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt
LOG_SCOPE("imgRequest::OnStartRequest");
NS_ASSERTION(!mDecoder, "imgRequest::OnStartRequest -- we already have a decoder");
nsCOMPtr<nsIChannel> chan(do_QueryInterface(aRequest));
if (mChannel && (mChannel != chan)) {
@ -392,6 +393,21 @@ NS_IMETHODIMP imgRequest::OnStartRequest(nsIRequest *aRequest, nsISupports *ctxt
return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIHTTPChannel> httpChannel(do_QueryInterface(chan));
if (httpChannel) {
PRUint32 httpStatus;
httpChannel->GetResponseStatus(&httpStatus);
if (httpStatus == 404) {
PR_LOG(gImgLog, PR_LOG_DEBUG,
("[this=%p] imgRequest::OnStartRequest -- http status = 404. canceling.\n", this));
mStatus = imgIRequest::STATUS_ERROR;
this->Cancel(NS_BINDING_ABORTED);
return NS_ERROR_FAILURE;
}
}
nsXPIDLCString contentType;
nsresult rv = mChannel->GetContentType(getter_Copies(contentType));