exposing the network status of a image request to wpl consumers. bug 355555. r=stuart.

git-svn-id: svn://10.0.0.236/trunk@215060 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
dougt%meer.net
2006-11-09 22:47:43 +00:00
parent d29838fcfa
commit 9e6e105dfd
3 changed files with 29 additions and 5 deletions

View File

@@ -79,7 +79,7 @@ NS_IMPL_ISUPPORTS6(imgRequest, imgILoad,
imgRequest::imgRequest() :
mObservers(0),
mLoading(PR_FALSE), mProcessing(PR_FALSE), mHadLastPart(PR_FALSE),
mImageStatus(imgIRequest::STATUS_NONE), mState(0),
mNetworkStatus(0), mImageStatus(imgIRequest::STATUS_NONE), mState(0),
mCacheId(0), mValidator(nsnull), mIsMultiPartChannel(PR_FALSE)
{
/* member initializers and constructor code */
@@ -738,6 +738,10 @@ NS_IMETHODIMP imgRequest::OnStopRequest(nsIRequest *aRequest, nsISupports *ctxt,
}
// XXXldb What if this is a non-last part of a multipart request?
// xxx before we release our reference to mChannel, lets
// save the last status that we saw so that the
// imgRequestProxy will have access to it.
mRequest->GetStatus(&mNetworkStatus);
mRequest = nsnull; // we no longer need the request
// If mImage is still null, we didn't properly load the image.
@@ -928,3 +932,15 @@ imgRequest::SniffMimeType(const char *buf, PRUint32 len)
{
imgLoader::GetMimeTypeFromContent(buf, len, mContentType);
}
nsresult
imgRequest::GetNetworkStatus()
{
nsresult status;
if (mRequest)
mRequest->GetStatus(&status);
else
status = mNetworkStatus;
return status;
}

View File

@@ -102,6 +102,10 @@ public:
// being made...
PRBool IsReusable(void *aCacheId) { return !mLoading || (aCacheId == mCacheId); }
// get the current or last network status from our
// internal nsIChannel.
nsresult GetNetworkStatus();
private:
friend class imgRequestProxy;
friend class imgLoader;
@@ -155,10 +159,9 @@ private:
PRPackedBool mLoading;
PRPackedBool mProcessing;
PRPackedBool mHadLastPart;
PRUint32 mNetworkStatus;
PRUint32 mImageStatus;
PRUint32 mState;
nsCString mContentType;
nsCOMPtr<nsICacheEntryDescriptor> mCacheEntry; /* we hold on to this to this so long as we have observers */

View File

@@ -187,13 +187,18 @@ NS_IMETHODIMP imgRequestProxy::GetName(nsACString &aName)
/* boolean isPending (); */
NS_IMETHODIMP imgRequestProxy::IsPending(PRBool *_retval)
{
return NS_ERROR_NOT_IMPLEMENTED;
return NS_ERROR_NOT_IMPLEMENTED;
}
/* readonly attribute nsresult status; */
NS_IMETHODIMP imgRequestProxy::GetStatus(nsresult *aStatus)
{
return NS_ERROR_NOT_IMPLEMENTED;
if (!mOwner)
return NS_ERROR_FAILURE;
*aStatus = mOwner->GetNetworkStatus();
return NS_OK;
}
/* void cancel (in nsresult status); */