Bug 715837 - Crash @ mozilla::net::HttpChannelParent::RecvMarkOfflineCacheEntryAsForeign, r=jduell

This commit is contained in:
Honza Bambas 2012-05-07 13:20:21 +02:00
Родитель 2c8764dfd9
Коммит ca8751c41b
4 изменённых файлов: 52 добавлений и 9 удалений

Просмотреть файл

@ -43,7 +43,6 @@
#include "mozilla/net/NeckoParent.h"
#include "mozilla/unused.h"
#include "HttpChannelParentListener.h"
#include "nsHttpChannel.h"
#include "nsHttpHandler.h"
#include "nsNetUtil.h"
#include "nsISupportsPriority.h"
@ -394,8 +393,11 @@ HttpChannelParent::RecvDocumentChannelCleanup()
bool
HttpChannelParent::RecvMarkOfflineCacheEntryAsForeign()
{
nsHttpChannel *httpChan = static_cast<nsHttpChannel *>(mChannel.get());
httpChan->MarkOfflineCacheEntryAsForeign();
if (mOfflineForeignMarker) {
mOfflineForeignMarker->MarkAsForeign();
mOfflineForeignMarker = 0;
}
return true;
}
@ -421,6 +423,7 @@ HttpChannelParent::OnStartRequest(nsIRequest *aRequest, nsISupports *aContext)
bool loadedFromApplicationCache;
chan->GetLoadedFromApplicationCache(&loadedFromApplicationCache);
if (loadedFromApplicationCache) {
mOfflineForeignMarker = chan->GetOfflineCacheEntryAsForeignMarker();
nsCOMPtr<nsIApplicationCache> appCache;
chan->GetApplicationCache(getter_AddRefs(appCache));
nsCString appCacheGroupId;

Просмотреть файл

@ -49,6 +49,7 @@
#include "nsIParentRedirectingChannel.h"
#include "nsIProgressEventSink.h"
#include "nsITabParent.h"
#include "nsHttpChannel.h"
using namespace mozilla::dom;
@ -128,6 +129,8 @@ private:
nsCOMPtr<nsIChannel> mRedirectChannel;
nsCOMPtr<nsIAsyncVerifyRedirectCallback> mRedirectCallback;
nsAutoPtr<class nsHttpChannel::OfflineCacheEntryAsForeignMarker> mOfflineForeignMarker;
// state for combining OnStatus/OnProgress with OnDataAvailable
// into one IPDL call to child.
nsresult mStoredStatus;

Просмотреть файл

@ -5176,20 +5176,40 @@ nsHttpChannel::SetChooseApplicationCache(bool aChoose)
return NS_OK;
}
NS_IMETHODIMP
nsHttpChannel::MarkOfflineCacheEntryAsForeign()
nsHttpChannel::OfflineCacheEntryAsForeignMarker*
nsHttpChannel::GetOfflineCacheEntryAsForeignMarker()
{
if (!mApplicationCache)
return NS_ERROR_NOT_AVAILABLE;
return nsnull;
nsresult rv;
nsCAutoString cacheKey;
rv = GenerateCacheKey(mPostID, cacheKey);
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_SUCCESS(rv, nsnull);
rv = mApplicationCache->MarkEntry(cacheKey,
nsIApplicationCache::ITEM_FOREIGN);
return new OfflineCacheEntryAsForeignMarker(mApplicationCache, cacheKey);
}
nsresult
nsHttpChannel::OfflineCacheEntryAsForeignMarker::MarkAsForeign()
{
return mApplicationCache->MarkEntry(mCacheKey,
nsIApplicationCache::ITEM_FOREIGN);
}
NS_IMETHODIMP
nsHttpChannel::MarkOfflineCacheEntryAsForeign()
{
nsresult rv;
nsAutoPtr<OfflineCacheEntryAsForeignMarker> marker(
GetOfflineCacheEntryAsForeignMarker());
if (!marker)
return NS_ERROR_NOT_AVAILABLE;
rv = marker->MarkAsForeign();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;

Просмотреть файл

@ -161,6 +161,23 @@ public: /* internal necko use only */
return NS_OK;
}
// This allows cache entry to be marked as foreign even after channel itself
// is gone. Needed for e10s (see HttpChannelParent::RecvDocumentChannelCleanup)
class OfflineCacheEntryAsForeignMarker {
nsCOMPtr<nsIApplicationCache> mApplicationCache;
nsCString mCacheKey;
public:
OfflineCacheEntryAsForeignMarker(nsIApplicationCache* appCache,
const nsCSubstring& key)
: mApplicationCache(appCache)
, mCacheKey(key)
{}
nsresult MarkAsForeign();
};
OfflineCacheEntryAsForeignMarker* GetOfflineCacheEntryAsForeignMarker();
private:
typedef nsresult (nsHttpChannel::*nsContinueRedirectionFunc)(nsresult result);