Handle session history navigation across a document.open with nothing written. Bug 376064, r=biesi, sr=jst, a=schrep

This commit is contained in:
bzbarsky@mit.edu 2008-01-04 22:48:12 -08:00
parent e2a623f614
commit e988f1f7ae
2 changed files with 33 additions and 14 deletions

View File

@ -46,7 +46,7 @@
#include "nsICacheService.h"
#include "nsICacheSession.h"
#include "nsIParser.h"
#include "nsThreadUtils.h"
PRLogModuleInfo * gWyciwygLog = nsnull;
@ -305,7 +305,17 @@ nsWyciwygChannel::AsyncOpen(nsIStreamListener *listener, nsISupports *ctx)
// open a cache entry for this channel...
PRBool delayed = PR_FALSE;
nsresult rv = OpenCacheEntry(spec, nsICache::ACCESS_READ, &delayed);
nsresult rv = OpenCacheEntry(spec, nsICache::ACCESS_READ, &delayed);
if (rv == NS_ERROR_CACHE_KEY_NOT_FOUND) {
nsCOMPtr<nsIRunnable> ev =
new nsRunnableMethod<nsWyciwygChannel>(this,
&nsWyciwygChannel::NotifyListener);
// Overwrite rv on purpose; if event dispatch fails we'll bail, and
// otherwise we'll wait until the event fires before calling back.
rv = NS_DispatchToCurrentThread(ev);
delayed = PR_TRUE;
}
if (NS_FAILED(rv)) {
LOG(("nsWyciwygChannel::OpenCacheEntry failed [rv=%x]\n", rv));
return rv;
@ -477,18 +487,7 @@ nsWyciwygChannel::OnCacheEntryAvailable(nsICacheEntryDescriptor * aCacheEntry, n
if (NS_FAILED(rv)) {
CloseCacheEntry(rv);
if (mListener) {
mListener->OnStartRequest(this, mListenerContext);
mListener->OnStopRequest(this, mListenerContext, mStatus);
mListener = 0;
mListenerContext = 0;
}
mIsPending = PR_FALSE;
// Remove ourselves from the load group.
if (mLoadGroup)
mLoadGroup->RemoveRequest(this, nsnull, mStatus);
NotifyListener();
}
return NS_OK;
@ -652,4 +651,22 @@ nsWyciwygChannel::WriteCharsetAndSourceToCache(PRInt32 aSource,
mCacheEntry->SetMetaDataElement("charset-source", source.get());
}
void
nsWyciwygChannel::NotifyListener()
{
if (mListener) {
mListener->OnStartRequest(this, mListenerContext);
mListener->OnStopRequest(this, mListenerContext, mStatus);
mListener = 0;
mListenerContext = 0;
}
mIsPending = PR_FALSE;
// Remove ourselves from the load group.
if (mLoadGroup) {
mLoadGroup->RemoveRequest(this, nsnull, mStatus);
}
}
// vim: ts=2 sw=2

View File

@ -86,6 +86,8 @@ protected:
void WriteCharsetAndSourceToCache(PRInt32 aSource,
const nsCString& aCharset);
void NotifyListener();
nsresult mStatus;
PRPackedBool mIsPending;