Bug 662534 - Let imgRequestProxy implement nsITimedChannel, r=joe

This commit is contained in:
Honza Bambas 2011-06-09 23:11:57 +02:00
parent 3aa3bd7fb7
commit 3c214fe898
4 changed files with 34 additions and 3 deletions

View File

@ -226,6 +226,8 @@ nsresult imgRequest::Init(nsIURI *aURI,
mKeyURI = aKeyURI;
mRequest = aRequest;
mChannel = aChannel;
mTimedChannel = do_QueryInterface(mChannel);
mChannel->GetNotificationCallbacks(getter_AddRefs(mPrevChannelSink));
NS_ASSERTION(mPrevChannelSink != this,
@ -956,6 +958,7 @@ NS_IMETHODIMP imgRequest::OnStopRequest(nsIRequest *aRequest, nsISupports *ctxt,
statusTracker.SendStopRequest(srIter.GetNext(), lastPart, status);
}
mTimedChannel = nsnull;
return NS_OK;
}
@ -1277,6 +1280,7 @@ imgRequest::OnRedirectVerifyCallback(nsresult result)
}
mChannel = mNewRedirectChannel;
mTimedChannel = do_QueryInterface(mChannel);
mNewRedirectChannel = nsnull;
// Don't make any cache changes if we're going to point to the same thing. We

View File

@ -51,6 +51,7 @@
#include "nsIStreamListener.h"
#include "nsIURI.h"
#include "nsIPrincipal.h"
#include "nsITimedChannel.h"
#include "nsCategoryCache.h"
#include "nsCOMPtr.h"
@ -219,6 +220,8 @@ private:
nsTObserverArray<imgRequestProxy*> mObservers;
nsCOMPtr<nsITimedChannel> mTimedChannel;
nsCString mContentType;
nsRefPtr<imgCacheEntry> mCacheEntry; /* we hold on to this to this so long as we have observers */

View File

@ -57,8 +57,17 @@
using namespace mozilla::imagelib;
NS_IMPL_ISUPPORTS4(imgRequestProxy, imgIRequest, nsIRequest,
nsISupportsPriority, nsISecurityInfoProvider)
NS_IMPL_ADDREF(imgRequestProxy)
NS_IMPL_RELEASE(imgRequestProxy)
NS_INTERFACE_MAP_BEGIN(imgRequestProxy)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, imgIRequest)
NS_INTERFACE_MAP_ENTRY(imgIRequest)
NS_INTERFACE_MAP_ENTRY(nsIRequest)
NS_INTERFACE_MAP_ENTRY(nsISupportsPriority)
NS_INTERFACE_MAP_ENTRY(nsISecurityInfoProvider)
NS_INTERFACE_MAP_ENTRY_CONDITIONAL(nsITimedChannel, TimedChannel() != nsnull)
NS_INTERFACE_MAP_END
imgRequestProxy::imgRequestProxy() :
mOwner(nsnull),

View File

@ -48,6 +48,7 @@
#include "nsIChannel.h"
#include "nsILoadGroup.h"
#include "nsISupportsPriority.h"
#include "nsITimedChannel.h"
#include "nsCOMPtr.h"
#include "nsAutoPtr.h"
#include "nsThreadUtils.h"
@ -71,7 +72,10 @@ class Image;
} // namespace imagelib
} // namespace mozilla
class imgRequestProxy : public imgIRequest, public nsISupportsPriority, public nsISecurityInfoProvider
class imgRequestProxy : public imgIRequest,
public nsISupportsPriority,
public nsISecurityInfoProvider,
public nsITimedChannel
{
public:
NS_DECL_ISUPPORTS
@ -79,6 +83,7 @@ public:
NS_DECL_NSIREQUEST
NS_DECL_NSISUPPORTSPRIORITY
NS_DECL_NSISECURITYINFOPROVIDER
// nsITimedChannel declared below
imgRequestProxy();
virtual ~imgRequestProxy();
@ -196,6 +201,16 @@ protected:
// (b) whether mOwner has instantiated its image yet
imgStatusTracker& GetStatusTracker();
nsITimedChannel* TimedChannel()
{
if (!mOwner)
return nsnull;
return mOwner->mTimedChannel;
}
public:
NS_FORWARD_SAFE_NSITIMEDCHANNEL(TimedChannel())
private:
friend class imgCacheValidator;