Bug 442803: Remove offline fetching from nsPrefetchService.cpp. r+sr=bz

This commit is contained in:
Dave Camp
2008-08-19 19:28:46 -07:00
parent 8369b12957
commit 83757beabe
3 changed files with 62 additions and 193 deletions

View File

@@ -59,14 +59,8 @@ interface nsIPrefetchService : nsISupports
in boolean aExplicit); in boolean aExplicit);
/** /**
* Enqueue a request to prefetch the specified URI, making sure it's in the * @status DEPRECATED This method is no longer used, and will throw
* offline cache. * NS_ERROR_NOT_IMPLEMENTED.
*
* @param aURI the URI of the document to prefetch
* @param aReferrerURI the URI of the referring page
* @param aSource the DOM node (such as a <link> tag) that requested this
* fetch, or null if the prefetch was not requested by a DOM node.
* @param aExplicit the link element has an explicit offline link type
*/ */
void prefetchURIForOfflineUse(in nsIURI aURI, void prefetchURIForOfflineUse(in nsIURI aURI,
in nsIURI aReferrerURI, in nsIURI aReferrerURI,
@@ -77,9 +71,12 @@ interface nsIPrefetchService : nsISupports
* Enumerate the items in the prefetch queue. Each element in the * Enumerate the items in the prefetch queue. Each element in the
* enumeration is an nsIDOMLoadStatus. * enumeration is an nsIDOMLoadStatus.
* *
* @param aIncludeNormalItems include normal prefetch items in the list. * @param aIncludeNormalItems include normal prefetch items in the
* list. This parameter is deprecated and must be TRUE,
* or NS_ERROR_INT_IMPLEMENTED will be thrown.
* @param aIncludeOfflineItems include items being fetched for offline * @param aIncludeOfflineItems include items being fetched for offline
* use. * use. This parameter is deprecated and must be FALSE,
* or NS_ERROR_NOT_IMPLEMENTED will be thrown.
*/ */
nsISimpleEnumerator enumerateQueue(in boolean aIncludeNormalItems, nsISimpleEnumerator enumerateQueue(in boolean aIncludeNormalItems,
in boolean aIncludeOfflineItems); in boolean aIncludeOfflineItems);

View File

@@ -37,7 +37,6 @@
#include "nsPrefetchService.h" #include "nsPrefetchService.h"
#include "nsICacheSession.h" #include "nsICacheSession.h"
#include "nsIOfflineCacheSession.h"
#include "nsICacheService.h" #include "nsICacheService.h"
#include "nsIServiceManager.h" #include "nsIServiceManager.h"
#include "nsICategoryManager.h" #include "nsICategoryManager.h"
@@ -104,9 +103,7 @@ class nsPrefetchQueueEnumerator : public nsISimpleEnumerator
public: public:
NS_DECL_ISUPPORTS NS_DECL_ISUPPORTS
NS_DECL_NSISIMPLEENUMERATOR NS_DECL_NSISIMPLEENUMERATOR
nsPrefetchQueueEnumerator(nsPrefetchService *aService, nsPrefetchQueueEnumerator(nsPrefetchService *aService);
PRBool aIncludeNormal,
PRBool aIncludeOffline);
~nsPrefetchQueueEnumerator(); ~nsPrefetchQueueEnumerator();
private: private:
@@ -114,20 +111,14 @@ private:
nsRefPtr<nsPrefetchService> mService; nsRefPtr<nsPrefetchService> mService;
nsRefPtr<nsPrefetchNode> mCurrent; nsRefPtr<nsPrefetchNode> mCurrent;
PRBool mIncludeNormal;
PRBool mIncludeOffline;
PRBool mStarted; PRBool mStarted;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// nsPrefetchQueueEnumerator <public> // nsPrefetchQueueEnumerator <public>
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
nsPrefetchQueueEnumerator::nsPrefetchQueueEnumerator(nsPrefetchService *aService, nsPrefetchQueueEnumerator::nsPrefetchQueueEnumerator(nsPrefetchService *aService)
PRBool aIncludeNormal,
PRBool aIncludeOffline)
: mService(aService) : mService(aService)
, mIncludeNormal(aIncludeNormal)
, mIncludeOffline(aIncludeOffline)
, mStarted(PR_FALSE) , mStarted(PR_FALSE)
{ {
Increment(); Increment();
@@ -187,8 +178,7 @@ nsPrefetchQueueEnumerator::Increment()
mCurrent = mCurrent->mNext; mCurrent = mCurrent->mNext;
} }
} }
} while (mCurrent && mIncludeOffline != mCurrent->mOffline && } while (mCurrent);
mIncludeNormal == mCurrent->mOffline);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -204,12 +194,10 @@ NS_IMPL_ISUPPORTS1(nsPrefetchQueueEnumerator, nsISimpleEnumerator)
nsPrefetchNode::nsPrefetchNode(nsPrefetchService *aService, nsPrefetchNode::nsPrefetchNode(nsPrefetchService *aService,
nsIURI *aURI, nsIURI *aURI,
nsIURI *aReferrerURI, nsIURI *aReferrerURI,
nsIDOMNode *aSource, nsIDOMNode *aSource)
PRBool aOffline)
: mNext(nsnull) : mNext(nsnull)
, mURI(aURI) , mURI(aURI)
, mReferrerURI(aReferrerURI) , mReferrerURI(aReferrerURI)
, mOffline(aOffline)
, mService(aService) , mService(aService)
, mChannel(nsnull) , mChannel(nsnull)
, mState(nsIDOMLoadStatus::UNINITIALIZED) , mState(nsIDOMLoadStatus::UNINITIALIZED)
@@ -235,21 +223,10 @@ nsPrefetchNode::OpenChannel()
httpChannel->SetReferrer(mReferrerURI); httpChannel->SetReferrer(mReferrerURI);
httpChannel->SetRequestHeader( httpChannel->SetRequestHeader(
NS_LITERAL_CSTRING("X-Moz"), NS_LITERAL_CSTRING("X-Moz"),
mOffline ?
NS_LITERAL_CSTRING("offline-resource") :
NS_LITERAL_CSTRING("prefetch"), NS_LITERAL_CSTRING("prefetch"),
PR_FALSE); PR_FALSE);
} }
if (mOffline) {
nsCOMPtr<nsICachingChannel> cachingChannel =
do_QueryInterface(mChannel);
if (cachingChannel) {
rv = cachingChannel->SetCacheForOfflineUse(PR_TRUE);
NS_ENSURE_SUCCESS(rv, rv);
}
}
rv = mChannel->AsyncOpen(this, nsnull); rv = mChannel->AsyncOpen(this, nsnull);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@@ -294,40 +271,34 @@ nsPrefetchNode::OnStartRequest(nsIRequest *aRequest,
do_QueryInterface(aRequest, &rv); do_QueryInterface(aRequest, &rv);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
PRBool cacheForOfflineUse; // no need to prefetch a document that is already in the cache
rv = cachingChannel->GetCacheForOfflineUse(&cacheForOfflineUse); PRBool fromCache;
if (NS_SUCCEEDED(cachingChannel->IsFromCache(&fromCache)) &&
fromCache) {
LOG(("document is already in the cache; canceling prefetch\n"));
return NS_BINDING_ABORTED;
}
//
// no need to prefetch a document that must be requested fresh each
// and every time.
//
nsCOMPtr<nsISupports> cacheToken;
cachingChannel->GetCacheToken(getter_AddRefs(cacheToken));
if (!cacheToken)
return NS_ERROR_ABORT; // bail, no cache entry
nsCOMPtr<nsICacheEntryInfo> entryInfo =
do_QueryInterface(cacheToken, &rv);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (!cacheForOfflineUse) { PRUint32 expTime;
// no need to prefetch a document that is already in the cache if (NS_SUCCEEDED(entryInfo->GetExpirationTime(&expTime))) {
PRBool fromCache; if (NowInSeconds() >= expTime) {
if (NS_SUCCEEDED(cachingChannel->IsFromCache(&fromCache)) && LOG(("document cannot be reused from cache; "
fromCache) { "canceling prefetch\n"));
LOG(("document is already in the cache; canceling prefetch\n"));
return NS_BINDING_ABORTED; return NS_BINDING_ABORTED;
} }
//
// no need to prefetch a document that must be requested fresh each
// and every time.
//
nsCOMPtr<nsISupports> cacheToken;
cachingChannel->GetCacheToken(getter_AddRefs(cacheToken));
if (!cacheToken)
return NS_ERROR_ABORT; // bail, no cache entry
nsCOMPtr<nsICacheEntryInfo> entryInfo =
do_QueryInterface(cacheToken, &rv);
if (NS_FAILED(rv)) return rv;
PRUint32 expTime;
if (NS_SUCCEEDED(entryInfo->GetExpirationTime(&expTime))) {
if (NowInSeconds() >= expTime) {
LOG(("document cannot be reused from cache; "
"canceling prefetch\n"));
return NS_BINDING_ABORTED;
}
}
} }
mState = nsIDOMLoadStatus::RECEIVING; mState = nsIDOMLoadStatus::RECEIVING;
@@ -401,26 +372,14 @@ nsPrefetchNode::OnChannelRedirect(nsIChannel *aOldChannel,
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;
PRBool offline;
nsCOMPtr<nsICachingChannel> oldCachingChannel = nsCOMPtr<nsICachingChannel> oldCachingChannel =
do_QueryInterface(aOldChannel); do_QueryInterface(aOldChannel);
if (NS_SUCCEEDED(oldCachingChannel->GetCacheForOfflineUse(&offline)) &&
offline) {
nsCOMPtr<nsICachingChannel> newCachingChannel =
do_QueryInterface(aOldChannel);
if (newCachingChannel)
newCachingChannel->SetCacheForOfflineUse(PR_TRUE);
}
PRBool match; PRBool match;
rv = newURI->SchemeIs("http", &match); rv = newURI->SchemeIs("http", &match);
if (NS_FAILED(rv) || !match) { if (NS_FAILED(rv) || !match) {
if (!offline || LOG(("rejected: URL is not of type http\n"));
NS_FAILED(newURI->SchemeIs("https", &match)) || return NS_ERROR_ABORT;
!match) {
LOG(("rejected: URL is not of type http\n"));
return NS_ERROR_ABORT;
}
} }
// HTTP request headers are not automatically forwarded to the new channel. // HTTP request headers are not automatically forwarded to the new channel.
@@ -428,9 +387,7 @@ nsPrefetchNode::OnChannelRedirect(nsIChannel *aOldChannel,
NS_ENSURE_STATE(httpChannel); NS_ENSURE_STATE(httpChannel);
httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("X-Moz"), httpChannel->SetRequestHeader(NS_LITERAL_CSTRING("X-Moz"),
offline ? NS_LITERAL_CSTRING("prefetch"),
NS_LITERAL_CSTRING("offline-resource") :
NS_LITERAL_CSTRING("prefetch"),
PR_FALSE); PR_FALSE);
mChannel = aNewChannel; mChannel = aNewChannel;
@@ -449,7 +406,6 @@ nsPrefetchService::nsPrefetchService()
, mStopCount(0) , mStopCount(0)
, mHaveProcessed(PR_FALSE) , mHaveProcessed(PR_FALSE)
, mDisabled(PR_TRUE) , mDisabled(PR_TRUE)
, mFetchedOffline(PR_FALSE)
{ {
} }
@@ -457,7 +413,7 @@ nsPrefetchService::~nsPrefetchService()
{ {
// cannot reach destructor if prefetch in progress (listener owns reference // cannot reach destructor if prefetch in progress (listener owns reference
// to this service) // to this service)
EmptyQueue(PR_TRUE); EmptyQueue();
} }
nsresult nsresult
@@ -505,18 +461,6 @@ nsPrefetchService::ProcessNextURI()
do { do {
rv = DequeueNode(getter_AddRefs(mCurrentNode)); rv = DequeueNode(getter_AddRefs(mCurrentNode));
if (rv == NS_ERROR_NOT_AVAILABLE && mFetchedOffline) {
// done loading stuff, go ahead and evict unowned entries from
// the offline cache
mFetchedOffline = PR_FALSE;
nsCOMPtr<nsIOfflineCacheSession> session;
rv = GetOfflineCacheSession(getter_AddRefs(session));
if (NS_FAILED(rv)) break;
session->EvictUnownedEntries();
break;
}
if (NS_FAILED(rv)) break; if (NS_FAILED(rv)) break;
@@ -532,8 +476,6 @@ nsPrefetchService::ProcessNextURI()
// if opening the channel fails, then just skip to the next uri // if opening the channel fails, then just skip to the next uri
// //
rv = mCurrentNode->OpenChannel(); rv = mCurrentNode->OpenChannel();
if (NS_SUCCEEDED(rv) && mCurrentNode->mOffline)
mFetchedOffline = PR_TRUE;
} }
while (NS_FAILED(rv)); while (NS_FAILED(rv));
} }
@@ -547,11 +489,8 @@ nsPrefetchService::NotifyLoadRequested(nsPrefetchNode *node)
do_GetService("@mozilla.org/observer-service;1", &rv); do_GetService("@mozilla.org/observer-service;1", &rv);
if (NS_FAILED(rv)) return; if (NS_FAILED(rv)) return;
const char *topic = node->mOffline ? "offline-load-requested" :
"prefetch-load-requested";
observerService->NotifyObservers(static_cast<nsIDOMLoadStatus*>(node), observerService->NotifyObservers(static_cast<nsIDOMLoadStatus*>(node),
topic, nsnull); "prefetch-load-requested", nsnull);
} }
void void
@@ -563,11 +502,8 @@ nsPrefetchService::NotifyLoadCompleted(nsPrefetchNode *node)
do_GetService("@mozilla.org/observer-service;1", &rv); do_GetService("@mozilla.org/observer-service;1", &rv);
if (NS_FAILED(rv)) return; if (NS_FAILED(rv)) return;
const char *topic = node->mOffline ? "offline-load-completed" :
"prefetch-load-completed";
observerService->NotifyObservers(static_cast<nsIDOMLoadStatus*>(node), observerService->NotifyObservers(static_cast<nsIDOMLoadStatus*>(node),
topic, nsnull); "prefetch-load-completed", nsnull);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -615,11 +551,10 @@ nsresult
nsPrefetchService::EnqueueURI(nsIURI *aURI, nsPrefetchService::EnqueueURI(nsIURI *aURI,
nsIURI *aReferrerURI, nsIURI *aReferrerURI,
nsIDOMNode *aSource, nsIDOMNode *aSource,
PRBool aOffline,
nsPrefetchNode **aNode) nsPrefetchNode **aNode)
{ {
nsPrefetchNode *node = new nsPrefetchNode(this, aURI, aReferrerURI, nsPrefetchNode *node = new nsPrefetchNode(this, aURI, aReferrerURI,
aSource, aOffline); aSource);
if (!node) if (!node)
return NS_ERROR_OUT_OF_MEMORY; return NS_ERROR_OUT_OF_MEMORY;
@@ -646,52 +581,23 @@ nsPrefetchService::DequeueNode(nsPrefetchNode **node)
} }
void void
nsPrefetchService::EmptyQueue(PRBool includeOffline) nsPrefetchService::EmptyQueue()
{ {
nsPrefetchNode *prev = 0; nsPrefetchNode *prev = 0;
nsPrefetchNode *node = mQueueHead; nsPrefetchNode *node = mQueueHead;
while (node) { while (node) {
nsPrefetchNode *next = node->mNext; nsPrefetchNode *next = node->mNext;
if (includeOffline || !node->mOffline) { if (prev)
if (prev) prev->mNext = next;
prev->mNext = next;
else
mQueueHead = next;
NS_RELEASE(node);
}
else else
prev = node; mQueueHead = next;
NS_RELEASE(node);
node = next; node = next;
} }
} }
nsresult
nsPrefetchService::GetOfflineCacheSession(nsIOfflineCacheSession **aSession)
{
if (!mOfflineCacheSession) {
nsresult rv;
nsCOMPtr<nsICacheService> serv =
do_GetService(NS_CACHESERVICE_CONTRACTID,
&rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsICacheSession> session;
rv = serv->CreateSession("HTTP-offline",
nsICache::STORE_OFFLINE,
nsICache::STREAM_BASED,
getter_AddRefs(session));
NS_ENSURE_SUCCESS(rv, rv);
mOfflineCacheSession = do_QueryInterface(session, &rv);
NS_ENSURE_SUCCESS(rv, rv);
}
NS_ADDREF(*aSession = mOfflineCacheSession);
return NS_OK;
}
void void
nsPrefetchService::StartPrefetching() nsPrefetchService::StartPrefetching()
{ {
@@ -725,14 +631,9 @@ nsPrefetchService::StopPrefetching()
if (!mCurrentNode) if (!mCurrentNode)
return; return;
// if it's an offline prefetch, requeue it for when prefetching starts
// again
if (mCurrentNode->mOffline)
EnqueueNode(mCurrentNode);
mCurrentNode->CancelChannel(NS_BINDING_ABORTED); mCurrentNode->CancelChannel(NS_BINDING_ABORTED);
mCurrentNode = nsnull; mCurrentNode = nsnull;
EmptyQueue(PR_FALSE); EmptyQueue();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -753,8 +654,7 @@ nsresult
nsPrefetchService::Prefetch(nsIURI *aURI, nsPrefetchService::Prefetch(nsIURI *aURI,
nsIURI *aReferrerURI, nsIURI *aReferrerURI,
nsIDOMNode *aSource, nsIDOMNode *aSource,
PRBool aExplicit, PRBool aExplicit)
PRBool aOffline)
{ {
nsresult rv; nsresult rv;
@@ -788,11 +688,6 @@ nsPrefetchService::Prefetch(nsIURI *aURI,
PRBool match; PRBool match;
rv = aURI->SchemeIs("http", &match); rv = aURI->SchemeIs("http", &match);
if (NS_FAILED(rv) || !match) { if (NS_FAILED(rv) || !match) {
if (aOffline) {
// Offline https urls can be prefetched
rv = aURI->SchemeIs("https", &match);
}
if (NS_FAILED(rv) || !match) { if (NS_FAILED(rv) || !match) {
LOG(("rejected: URL is not of type http\n")); LOG(("rejected: URL is not of type http\n"));
return NS_ERROR_ABORT; return NS_ERROR_ABORT;
@@ -804,11 +699,6 @@ nsPrefetchService::Prefetch(nsIURI *aURI,
// //
rv = aReferrerURI->SchemeIs("http", &match); rv = aReferrerURI->SchemeIs("http", &match);
if (NS_FAILED(rv) || !match) { if (NS_FAILED(rv) || !match) {
if (aOffline) {
// Offline https urls can be prefetched
rv = aURI->SchemeIs("https", &match);
}
if (NS_FAILED(rv) || !match) { if (NS_FAILED(rv) || !match) {
LOG(("rejected: referrer URL is not of type http\n")); LOG(("rejected: referrer URL is not of type http\n"));
return NS_ERROR_ABORT; return NS_ERROR_ABORT;
@@ -834,12 +724,8 @@ nsPrefetchService::Prefetch(nsIURI *aURI,
if (mCurrentNode) { if (mCurrentNode) {
PRBool equals; PRBool equals;
if (NS_SUCCEEDED(mCurrentNode->mURI->Equals(aURI, &equals)) && equals) { if (NS_SUCCEEDED(mCurrentNode->mURI->Equals(aURI, &equals)) && equals) {
// We may still need to put it on the queue if the channel LOG(("rejected: URL is already being prefetched\n"));
// isn't fetching to the offline cache return NS_ERROR_ABORT;
if (!aOffline || mCurrentNode->mOffline) {
LOG(("rejected: URL is already being prefetched\n"));
return NS_ERROR_ABORT;
}
} }
} }
@@ -850,17 +736,13 @@ nsPrefetchService::Prefetch(nsIURI *aURI,
for (; node; node = node->mNext) { for (; node; node = node->mNext) {
PRBool equals; PRBool equals;
if (NS_SUCCEEDED(node->mURI->Equals(aURI, &equals)) && equals) { if (NS_SUCCEEDED(node->mURI->Equals(aURI, &equals)) && equals) {
if (aOffline) {
// make sure the node is placed in the offline cache
node->mOffline = PR_TRUE;
}
LOG(("rejected: URL is already on prefetch queue\n")); LOG(("rejected: URL is already on prefetch queue\n"));
return NS_ERROR_ABORT; return NS_ERROR_ABORT;
} }
} }
nsRefPtr<nsPrefetchNode> enqueuedNode; nsRefPtr<nsPrefetchNode> enqueuedNode;
rv = EnqueueURI(aURI, aReferrerURI, aSource, aOffline, rv = EnqueueURI(aURI, aReferrerURI, aSource,
getter_AddRefs(enqueuedNode)); getter_AddRefs(enqueuedNode));
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);
@@ -879,7 +761,7 @@ nsPrefetchService::PrefetchURI(nsIURI *aURI,
nsIDOMNode *aSource, nsIDOMNode *aSource,
PRBool aExplicit) PRBool aExplicit)
{ {
return Prefetch(aURI, aReferrerURI, aSource, aExplicit, PR_FALSE); return Prefetch(aURI, aReferrerURI, aSource, aExplicit);
} }
NS_IMETHODIMP NS_IMETHODIMP
@@ -888,7 +770,7 @@ nsPrefetchService::PrefetchURIForOfflineUse(nsIURI *aURI,
nsIDOMNode *aSource, nsIDOMNode *aSource,
PRBool aExplicit) PRBool aExplicit)
{ {
return Prefetch(aURI, aReferrerURI, aSource, aExplicit, PR_TRUE); return NS_ERROR_NOT_IMPLEMENTED;
} }
NS_IMETHODIMP NS_IMETHODIMP
@@ -896,9 +778,10 @@ nsPrefetchService::EnumerateQueue(PRBool aIncludeNormalItems,
PRBool aIncludeOfflineItems, PRBool aIncludeOfflineItems,
nsISimpleEnumerator **aEnumerator) nsISimpleEnumerator **aEnumerator)
{ {
*aEnumerator = new nsPrefetchQueueEnumerator(this, NS_ENSURE_TRUE(aIncludeNormalItems && !aIncludeOfflineItems,
aIncludeNormalItems, NS_ERROR_NOT_IMPLEMENTED);
aIncludeOfflineItems);
*aEnumerator = new nsPrefetchQueueEnumerator(this);
if (!*aEnumerator) return NS_ERROR_OUT_OF_MEMORY; if (!*aEnumerator) return NS_ERROR_OUT_OF_MEMORY;
NS_ADDREF(*aEnumerator); NS_ADDREF(*aEnumerator);

View File

@@ -56,7 +56,6 @@
class nsPrefetchService; class nsPrefetchService;
class nsPrefetchListener; class nsPrefetchListener;
class nsPrefetchNode; class nsPrefetchNode;
class nsIOfflineCacheSession;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// nsPrefetchService // nsPrefetchService
@@ -90,25 +89,19 @@ private:
nsresult Prefetch(nsIURI *aURI, nsresult Prefetch(nsIURI *aURI,
nsIURI *aReferrerURI, nsIURI *aReferrerURI,
nsIDOMNode *aSource, nsIDOMNode *aSource,
PRBool aExplicit, PRBool aExplicit);
PRBool aOffline);
void AddProgressListener(); void AddProgressListener();
void RemoveProgressListener(); void RemoveProgressListener();
nsresult EnqueueURI(nsIURI *aURI, nsIURI *aReferrerURI, nsresult EnqueueURI(nsIURI *aURI, nsIURI *aReferrerURI,
nsIDOMNode *aSource, PRBool aOffline, nsIDOMNode *aSource, nsPrefetchNode **node);
nsPrefetchNode **node);
nsresult EnqueueNode(nsPrefetchNode *node); nsresult EnqueueNode(nsPrefetchNode *node);
nsresult DequeueNode(nsPrefetchNode **node); nsresult DequeueNode(nsPrefetchNode **node);
void EmptyQueue(PRBool includeOffline); void EmptyQueue();
nsresult SaveOfflineList(nsIURI *aDocumentUri,
nsIDOMDocument *aDoc);
nsresult GetOfflineCacheSession(nsIOfflineCacheSession **aSession);
void StartPrefetching(); void StartPrefetching();
void StopPrefetching(); void StopPrefetching();
nsCOMPtr<nsIOfflineCacheSession> mOfflineCacheSession;
nsPrefetchNode *mQueueHead; nsPrefetchNode *mQueueHead;
nsPrefetchNode *mQueueTail; nsPrefetchNode *mQueueTail;
nsRefPtr<nsPrefetchNode> mCurrentNode; nsRefPtr<nsPrefetchNode> mCurrentNode;
@@ -116,8 +109,6 @@ private:
// true if pending document loads have ever reached zero. // true if pending document loads have ever reached zero.
PRInt32 mHaveProcessed; PRInt32 mHaveProcessed;
PRBool mDisabled; PRBool mDisabled;
PRBool mFetchedOffline;
}; };
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -140,8 +131,7 @@ public:
nsPrefetchNode(nsPrefetchService *aPrefetchService, nsPrefetchNode(nsPrefetchService *aPrefetchService,
nsIURI *aURI, nsIURI *aURI,
nsIURI *aReferrerURI, nsIURI *aReferrerURI,
nsIDOMNode *aSource, nsIDOMNode *aSource);
PRBool aOffline);
~nsPrefetchNode() {} ~nsPrefetchNode() {}
@@ -152,7 +142,6 @@ public:
nsCOMPtr<nsIURI> mURI; nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mReferrerURI; nsCOMPtr<nsIURI> mReferrerURI;
nsCOMPtr<nsIWeakReference> mSource; nsCOMPtr<nsIWeakReference> mSource;
PRBool mOffline;
private: private:
nsRefPtr<nsPrefetchService> mService; nsRefPtr<nsPrefetchService> mService;