2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-08-13 21:09:48 -07:00
|
|
|
#ifndef imgLoader_h__
|
|
|
|
#define imgLoader_h__
|
|
|
|
|
2012-01-02 12:23:41 -08:00
|
|
|
#include "mozilla/Attributes.h"
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "imgILoader.h"
|
2008-09-04 16:00:42 -07:00
|
|
|
#include "imgICache.h"
|
|
|
|
#include "nsWeakReference.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIContentSniffer.h"
|
2008-09-04 16:00:42 -07:00
|
|
|
#include "nsRefPtrHashtable.h"
|
|
|
|
#include "nsExpirationTracker.h"
|
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include "prtypes.h"
|
|
|
|
#include "imgRequest.h"
|
2009-07-15 00:22:40 -07:00
|
|
|
#include "nsIObserverService.h"
|
2010-05-20 13:08:02 -07:00
|
|
|
#include "nsIChannelPolicy.h"
|
2011-07-01 10:03:38 -07:00
|
|
|
#include "nsIProgressEventSink.h"
|
|
|
|
#include "nsIChannel.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
#ifdef LOADER_THREADSAFE
|
|
|
|
#include "prlock.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
class imgRequest;
|
|
|
|
class imgRequestProxy;
|
|
|
|
class imgIRequest;
|
|
|
|
class imgIDecoderObserver;
|
|
|
|
class nsILoadGroup;
|
|
|
|
|
2008-09-04 16:00:42 -07:00
|
|
|
class imgCacheEntry
|
|
|
|
{
|
|
|
|
public:
|
2012-08-27 12:31:29 -07:00
|
|
|
imgCacheEntry(imgRequest *request, bool aForcePrincipalCheck);
|
2009-01-30 18:17:47 -08:00
|
|
|
~imgCacheEntry();
|
2008-09-04 16:00:42 -07:00
|
|
|
|
|
|
|
nsrefcnt AddRef()
|
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
NS_PRECONDITION(int32_t(mRefCnt) >= 0, "illegal refcnt");
|
2009-01-30 18:17:47 -08:00
|
|
|
NS_ABORT_IF_FALSE(_mOwningThread.GetThread() == PR_GetCurrentThread(), "imgCacheEntry addref isn't thread-safe!");
|
2008-09-04 16:00:42 -07:00
|
|
|
++mRefCnt;
|
|
|
|
NS_LOG_ADDREF(this, mRefCnt, "imgCacheEntry", sizeof(*this));
|
|
|
|
return mRefCnt;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsrefcnt Release()
|
|
|
|
{
|
|
|
|
NS_PRECONDITION(0 != mRefCnt, "dup release");
|
2009-01-30 18:17:47 -08:00
|
|
|
NS_ABORT_IF_FALSE(_mOwningThread.GetThread() == PR_GetCurrentThread(), "imgCacheEntry release isn't thread-safe!");
|
2008-09-04 16:00:42 -07:00
|
|
|
--mRefCnt;
|
|
|
|
NS_LOG_RELEASE(this, mRefCnt, "imgCacheEntry");
|
|
|
|
if (mRefCnt == 0) {
|
|
|
|
mRefCnt = 1; /* stabilize */
|
|
|
|
delete this;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return mRefCnt;
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetDataSize() const
|
2008-09-04 16:00:42 -07:00
|
|
|
{
|
|
|
|
return mDataSize;
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetDataSize(uint32_t aDataSize)
|
2008-09-04 16:00:42 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t oldsize = mDataSize;
|
2008-09-04 16:00:42 -07:00
|
|
|
mDataSize = aDataSize;
|
2009-09-12 15:44:18 -07:00
|
|
|
UpdateCache(mDataSize - oldsize);
|
2008-09-04 16:00:42 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetTouchedTime() const
|
2008-09-04 16:00:42 -07:00
|
|
|
{
|
|
|
|
return mTouchedTime;
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetTouchedTime(int32_t time)
|
2008-09-04 16:00:42 -07:00
|
|
|
{
|
|
|
|
mTouchedTime = time;
|
2011-10-17 07:59:28 -07:00
|
|
|
Touch(/* updateTime = */ false);
|
2008-09-04 16:00:42 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t GetExpiryTime() const
|
2008-09-04 16:00:42 -07:00
|
|
|
{
|
|
|
|
return mExpiryTime;
|
|
|
|
}
|
2012-08-22 08:56:38 -07:00
|
|
|
void SetExpiryTime(int32_t aExpiryTime)
|
2008-09-04 16:00:42 -07:00
|
|
|
{
|
|
|
|
mExpiryTime = aExpiryTime;
|
|
|
|
Touch();
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool GetMustValidate() const
|
2008-09-04 16:00:42 -07:00
|
|
|
{
|
2011-07-01 10:03:35 -07:00
|
|
|
return mMustValidate;
|
2008-09-04 16:00:42 -07:00
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetMustValidate(bool aValidate)
|
2008-09-04 16:00:42 -07:00
|
|
|
{
|
2011-07-01 10:03:35 -07:00
|
|
|
mMustValidate = aValidate;
|
2008-09-04 16:00:42 -07:00
|
|
|
Touch();
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<imgRequest> GetRequest() const
|
|
|
|
{
|
|
|
|
imgRequest *req = mRequest;
|
|
|
|
NS_ADDREF(req);
|
|
|
|
return req;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool Evicted() const
|
2008-09-04 16:00:42 -07:00
|
|
|
{
|
|
|
|
return mEvicted;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsExpirationState *GetExpirationState()
|
|
|
|
{
|
|
|
|
return &mExpirationState;
|
|
|
|
}
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool HasNoProxies() const
|
2009-01-30 18:17:47 -08:00
|
|
|
{
|
|
|
|
return mHasNoProxies;
|
|
|
|
}
|
|
|
|
|
2011-09-20 14:00:42 -07:00
|
|
|
bool ForcePrincipalCheck() const
|
|
|
|
{
|
|
|
|
return mForcePrincipalCheck;
|
|
|
|
}
|
|
|
|
|
2008-09-04 16:00:42 -07:00
|
|
|
private: // methods
|
|
|
|
friend class imgLoader;
|
|
|
|
friend class imgCacheQueue;
|
2011-09-28 23:19:26 -07:00
|
|
|
void Touch(bool updateTime = true);
|
2012-08-22 08:56:38 -07:00
|
|
|
void UpdateCache(int32_t diff = 0);
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetEvicted(bool evict)
|
2008-09-04 16:00:42 -07:00
|
|
|
{
|
|
|
|
mEvicted = evict;
|
|
|
|
}
|
2011-09-28 23:19:26 -07:00
|
|
|
void SetHasNoProxies(bool hasNoProxies);
|
2009-01-30 18:17:47 -08:00
|
|
|
|
|
|
|
// Private, unimplemented copy constructor.
|
|
|
|
imgCacheEntry(const imgCacheEntry &);
|
2008-09-04 16:00:42 -07:00
|
|
|
|
|
|
|
private: // data
|
|
|
|
nsAutoRefCnt mRefCnt;
|
|
|
|
NS_DECL_OWNINGTHREAD
|
|
|
|
|
|
|
|
nsRefPtr<imgRequest> mRequest;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mDataSize;
|
|
|
|
int32_t mTouchedTime;
|
|
|
|
int32_t mExpiryTime;
|
2008-09-04 16:00:42 -07:00
|
|
|
nsExpirationState mExpirationState;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mMustValidate : 1;
|
|
|
|
bool mEvicted : 1;
|
|
|
|
bool mHasNoProxies : 1;
|
|
|
|
bool mForcePrincipalCheck : 1;
|
2008-09-04 16:00:42 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
#define NS_IMGLOADER_CID \
|
|
|
|
{ /* 9f6a0d2e-1dd1-11b2-a5b8-951f13c846f7 */ \
|
|
|
|
0x9f6a0d2e, \
|
|
|
|
0x1dd1, \
|
|
|
|
0x11b2, \
|
|
|
|
{0xa5, 0xb8, 0x95, 0x1f, 0x13, 0xc8, 0x46, 0xf7} \
|
|
|
|
}
|
|
|
|
|
2008-09-04 16:00:42 -07:00
|
|
|
class imgCacheQueue
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
imgCacheQueue();
|
|
|
|
void Remove(imgCacheEntry *);
|
|
|
|
void Push(imgCacheEntry *);
|
|
|
|
void MarkDirty();
|
2011-09-28 23:19:26 -07:00
|
|
|
bool IsDirty();
|
2008-09-04 16:00:42 -07:00
|
|
|
already_AddRefed<imgCacheEntry> Pop();
|
|
|
|
void Refresh();
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t GetSize() const;
|
|
|
|
void UpdateSize(int32_t diff);
|
|
|
|
uint32_t GetNumElements() const;
|
2008-09-04 16:00:42 -07:00
|
|
|
typedef std::vector<nsRefPtr<imgCacheEntry> > queueContainer;
|
|
|
|
typedef queueContainer::iterator iterator;
|
|
|
|
typedef queueContainer::const_iterator const_iterator;
|
|
|
|
|
|
|
|
iterator begin();
|
|
|
|
const_iterator begin() const;
|
|
|
|
iterator end();
|
|
|
|
const_iterator end() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
queueContainer mQueue;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool mDirty;
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t mSize;
|
2008-09-04 16:00:42 -07:00
|
|
|
};
|
|
|
|
|
2010-05-21 21:10:14 -07:00
|
|
|
class imgMemoryReporter;
|
|
|
|
|
2008-09-04 16:00:42 -07:00
|
|
|
class imgLoader : public imgILoader,
|
|
|
|
public nsIContentSniffer,
|
|
|
|
public imgICache,
|
2009-07-15 00:22:40 -07:00
|
|
|
public nsSupportsWeakReference,
|
|
|
|
public nsIObserver
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_IMGILOADER
|
|
|
|
NS_DECL_NSICONTENTSNIFFER
|
2008-09-04 16:00:42 -07:00
|
|
|
NS_DECL_IMGICACHE
|
2009-07-15 00:22:40 -07:00
|
|
|
NS_DECL_NSIOBSERVER
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
imgLoader();
|
|
|
|
virtual ~imgLoader();
|
|
|
|
|
2009-07-15 00:22:40 -07:00
|
|
|
nsresult Init();
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
static nsresult GetMimeTypeFromContent(const char* aContents, uint32_t aLength, nsACString& aContentType);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-04 16:00:42 -07:00
|
|
|
static void Shutdown(); // for use by the factory
|
|
|
|
|
2012-08-27 12:31:29 -07:00
|
|
|
static nsresult ClearChromeImageCache();
|
|
|
|
static nsresult ClearImageCache();
|
|
|
|
static void MinimizeCaches();
|
2008-09-04 16:00:42 -07:00
|
|
|
|
2012-08-27 12:31:29 -07:00
|
|
|
static nsresult InitCache();
|
2008-09-04 16:00:42 -07:00
|
|
|
|
2012-08-27 12:31:29 -07:00
|
|
|
static bool RemoveFromCache(nsIURI *aKey);
|
|
|
|
static bool RemoveFromCache(imgCacheEntry *entry);
|
2008-09-04 16:00:42 -07:00
|
|
|
|
2012-08-27 12:31:29 -07:00
|
|
|
static bool PutIntoCache(nsIURI *key, imgCacheEntry *entry);
|
2008-09-04 16:00:42 -07:00
|
|
|
|
2009-06-15 15:33:48 -07:00
|
|
|
// Returns true if we should prefer evicting cache entry |two| over cache
|
|
|
|
// entry |one|.
|
2008-09-04 16:00:42 -07:00
|
|
|
// This mixes units in the worst way, but provides reasonable results.
|
|
|
|
inline static bool CompareCacheEntries(const nsRefPtr<imgCacheEntry> &one,
|
2009-06-15 15:33:48 -07:00
|
|
|
const nsRefPtr<imgCacheEntry> &two)
|
2008-09-04 16:00:42 -07:00
|
|
|
{
|
|
|
|
if (!one)
|
|
|
|
return false;
|
|
|
|
if (!two)
|
|
|
|
return true;
|
|
|
|
|
2009-06-15 15:33:48 -07:00
|
|
|
const double sizeweight = 1.0 - sCacheTimeWeight;
|
|
|
|
|
|
|
|
// We want large, old images to be evicted first (depending on their
|
|
|
|
// relative weights). Since a larger time is actually newer, we subtract
|
|
|
|
// time's weight, so an older image has a larger weight.
|
|
|
|
double oneweight = double(one->GetDataSize()) * sizeweight -
|
|
|
|
double(one->GetTouchedTime()) * sCacheTimeWeight;
|
|
|
|
double twoweight = double(two->GetDataSize()) * sizeweight -
|
|
|
|
double(two->GetTouchedTime()) * sCacheTimeWeight;
|
|
|
|
|
|
|
|
return oneweight < twoweight;
|
2008-09-04 16:00:42 -07:00
|
|
|
}
|
|
|
|
|
2012-08-27 12:31:29 -07:00
|
|
|
static void VerifyCacheSizes();
|
2008-09-04 16:00:42 -07:00
|
|
|
|
2009-01-30 18:17:47 -08:00
|
|
|
// The image loader maintains a hash table of all imgCacheEntries. However,
|
|
|
|
// only some of them will be evicted from the cache: those who have no
|
|
|
|
// imgRequestProxies watching their imgRequests.
|
|
|
|
//
|
|
|
|
// Once an imgRequest has no imgRequestProxies, it should notify us by
|
|
|
|
// calling HasNoObservers(), and null out its cache entry pointer.
|
|
|
|
//
|
|
|
|
// Upon having a proxy start observing again, it should notify us by calling
|
|
|
|
// HasObservers(). The request's cache entry will be re-set before this
|
|
|
|
// happens, by calling imgRequest::SetCacheEntry() when an entry with no
|
|
|
|
// observers is re-requested.
|
2012-08-27 12:31:29 -07:00
|
|
|
static bool SetHasNoProxies(nsIURI *key, imgCacheEntry *entry);
|
|
|
|
static bool SetHasProxies(nsIURI *key);
|
2009-01-30 18:17:47 -08:00
|
|
|
|
2008-09-04 16:00:42 -07:00
|
|
|
private: // methods
|
|
|
|
|
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ValidateEntry(imgCacheEntry *aEntry, nsIURI *aKey,
|
2008-09-04 16:00:42 -07:00
|
|
|
nsIURI *aInitialDocumentURI, nsIURI *aReferrerURI,
|
|
|
|
nsILoadGroup *aLoadGroup,
|
|
|
|
imgIDecoderObserver *aObserver, nsISupports *aCX,
|
2011-09-28 23:19:26 -07:00
|
|
|
nsLoadFlags aLoadFlags, bool aCanMakeNewChannel,
|
2008-09-04 16:00:42 -07:00
|
|
|
imgIRequest *aExistingRequest,
|
2010-05-20 13:08:02 -07:00
|
|
|
imgIRequest **aProxyRequest,
|
2011-07-14 11:47:32 -07:00
|
|
|
nsIChannelPolicy *aPolicy,
|
2011-07-14 11:47:34 -07:00
|
|
|
nsIPrincipal* aLoadingPrincipal,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aCORSMode);
|
2011-09-28 23:19:26 -07:00
|
|
|
bool ValidateRequestWithNewChannel(imgRequest *request, nsIURI *aURI,
|
2008-09-04 16:00:42 -07:00
|
|
|
nsIURI *aInitialDocumentURI,
|
|
|
|
nsIURI *aReferrerURI,
|
|
|
|
nsILoadGroup *aLoadGroup,
|
|
|
|
imgIDecoderObserver *aObserver,
|
|
|
|
nsISupports *aCX, nsLoadFlags aLoadFlags,
|
|
|
|
imgIRequest *aExistingRequest,
|
2010-05-20 13:08:02 -07:00
|
|
|
imgIRequest **aProxyRequest,
|
2011-07-14 11:47:32 -07:00
|
|
|
nsIChannelPolicy *aPolicy,
|
2011-07-14 11:47:34 -07:00
|
|
|
nsIPrincipal* aLoadingPrincipal,
|
2012-08-22 08:56:38 -07:00
|
|
|
int32_t aCORSMode);
|
2008-09-04 16:00:42 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsresult CreateNewProxyForRequest(imgRequest *aRequest, nsILoadGroup *aLoadGroup,
|
|
|
|
imgIDecoderObserver *aObserver,
|
|
|
|
nsLoadFlags aLoadFlags, imgIRequest *aRequestProxy,
|
|
|
|
imgIRequest **_retval);
|
2008-09-04 16:00:42 -07:00
|
|
|
|
2011-06-11 19:30:15 -07:00
|
|
|
void ReadAcceptHeaderPref();
|
2009-07-15 00:22:40 -07:00
|
|
|
|
2008-09-04 16:00:42 -07:00
|
|
|
|
|
|
|
typedef nsRefPtrHashtable<nsCStringHashKey, imgCacheEntry> imgCacheTable;
|
|
|
|
|
2012-08-27 12:31:29 -07:00
|
|
|
static nsresult EvictEntries(imgCacheTable &aCacheToClear);
|
|
|
|
static nsresult EvictEntries(imgCacheQueue &aQueueToClear);
|
2008-09-04 16:00:42 -07:00
|
|
|
|
2012-08-27 12:31:29 -07:00
|
|
|
static imgCacheTable &GetCache(nsIURI *aURI);
|
|
|
|
static imgCacheQueue &GetCacheQueue(nsIURI *aURI);
|
|
|
|
static void CacheEntriesChanged(nsIURI *aURI, int32_t sizediff = 0);
|
|
|
|
static void CheckCacheLimits(imgCacheTable &cache, imgCacheQueue &queue);
|
2008-09-04 16:00:42 -07:00
|
|
|
|
|
|
|
private: // data
|
|
|
|
friend class imgCacheEntry;
|
2010-05-21 21:10:14 -07:00
|
|
|
friend class imgMemoryReporter;
|
2008-09-04 16:00:42 -07:00
|
|
|
|
2012-08-27 12:31:29 -07:00
|
|
|
static imgCacheTable sCache;
|
|
|
|
static imgCacheQueue sCacheQueue;
|
2008-09-04 16:00:42 -07:00
|
|
|
|
2012-08-27 12:31:29 -07:00
|
|
|
static imgCacheTable sChromeCache;
|
|
|
|
static imgCacheQueue sChromeCacheQueue;
|
2012-08-09 00:09:42 -07:00
|
|
|
static double sCacheTimeWeight;
|
2012-08-22 08:56:38 -07:00
|
|
|
static uint32_t sCacheMaxSize;
|
2009-07-15 00:22:40 -07:00
|
|
|
|
|
|
|
nsCString mAcceptHeader;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* proxy stream listener class used to handle multipart/x-mixed-replace
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
#include "nsIStreamListener.h"
|
|
|
|
|
|
|
|
class ProxyListener : public nsIStreamListener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ProxyListener(nsIStreamListener *dest);
|
|
|
|
virtual ~ProxyListener();
|
|
|
|
|
|
|
|
/* additional members */
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISTREAMLISTENER
|
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIStreamListener> mDestListener;
|
|
|
|
};
|
|
|
|
|
2011-07-01 10:03:38 -07:00
|
|
|
/**
|
|
|
|
* A class that implements nsIProgressEventSink and forwards all calls to it to
|
|
|
|
* the original notification callbacks of the channel. Also implements
|
|
|
|
* nsIInterfaceRequestor and gives out itself for nsIProgressEventSink calls,
|
|
|
|
* and forwards everything else to the channel's notification callbacks.
|
|
|
|
*/
|
2012-01-02 12:23:41 -08:00
|
|
|
class nsProgressNotificationProxy MOZ_FINAL
|
|
|
|
: public nsIProgressEventSink
|
|
|
|
, public nsIChannelEventSink
|
|
|
|
, public nsIInterfaceRequestor
|
2011-07-01 10:03:38 -07:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
nsProgressNotificationProxy(nsIChannel* channel,
|
|
|
|
imgIRequest* proxy)
|
|
|
|
: mImageRequest(proxy) {
|
|
|
|
channel->GetNotificationCallbacks(getter_AddRefs(mOriginalCallbacks));
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSIPROGRESSEVENTSINK
|
|
|
|
NS_DECL_NSICHANNELEVENTSINK
|
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
private:
|
|
|
|
~nsProgressNotificationProxy() {}
|
|
|
|
|
|
|
|
nsCOMPtr<nsIInterfaceRequestor> mOriginalCallbacks;
|
|
|
|
nsCOMPtr<nsIRequest> mImageRequest;
|
|
|
|
};
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* validate checker
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsCOMArray.h"
|
|
|
|
|
2011-07-01 10:03:38 -07:00
|
|
|
class imgCacheValidator : public nsIStreamListener,
|
|
|
|
public nsIChannelEventSink,
|
|
|
|
public nsIInterfaceRequestor,
|
|
|
|
public nsIAsyncVerifyRedirectCallback
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
public:
|
2012-08-27 12:31:29 -07:00
|
|
|
imgCacheValidator(nsProgressNotificationProxy* progress, imgRequest *request,
|
|
|
|
void *aContext, bool forcePrincipalCheckForCacheEntry);
|
2007-03-22 10:30:00 -07:00
|
|
|
virtual ~imgCacheValidator();
|
|
|
|
|
|
|
|
void AddProxy(imgRequestProxy *aProxy);
|
|
|
|
|
|
|
|
NS_DECL_ISUPPORTS
|
|
|
|
NS_DECL_NSISTREAMLISTENER
|
|
|
|
NS_DECL_NSIREQUESTOBSERVER
|
2011-07-01 10:03:38 -07:00
|
|
|
NS_DECL_NSICHANNELEVENTSINK
|
|
|
|
NS_DECL_NSIINTERFACEREQUESTOR
|
|
|
|
NS_DECL_NSIASYNCVERIFYREDIRECTCALLBACK
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
private:
|
|
|
|
nsCOMPtr<nsIStreamListener> mDestListener;
|
2011-07-01 10:03:38 -07:00
|
|
|
nsRefPtr<nsProgressNotificationProxy> mProgressProxy;
|
|
|
|
nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;
|
|
|
|
nsCOMPtr<nsIChannel> mRedirectChannel;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-09-04 16:00:42 -07:00
|
|
|
nsRefPtr<imgRequest> mRequest;
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMArray<imgIRequest> mProxies;
|
|
|
|
|
2011-07-01 10:03:38 -07:00
|
|
|
nsRefPtr<imgRequest> mNewRequest;
|
|
|
|
nsRefPtr<imgCacheEntry> mNewEntry;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void *mContext;
|
2008-09-04 16:00:42 -07:00
|
|
|
|
2012-08-27 12:31:29 -07:00
|
|
|
static imgLoader sImgLoader;
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
2010-08-13 21:09:48 -07:00
|
|
|
|
|
|
|
#endif // imgLoader_h__
|