Fix orange from bug 390168 by adopting a slightly different approach. Reviews from jst pending.

This commit is contained in:
bzbarsky@mit.edu 2007-08-24 18:45:15 -07:00
Родитель 477faceaa0
Коммит 5c53461a8a
2 изменённых файлов: 28 добавлений и 11 удалений

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

@ -57,7 +57,7 @@ PRLogModuleInfo * gWyciwygLog = nsnull;
nsWyciwygChannel::nsWyciwygChannel()
: mStatus(NS_OK),
mIsPending(PR_FALSE),
mCharsetSet(PR_FALSE),
mNeedToWriteCharset(PR_FALSE),
mCharsetSource(kCharsetUninitialized),
mContentLength(-1),
mLoadFlags(LOAD_NORMAL)
@ -350,12 +350,9 @@ nsWyciwygChannel::WriteToCacheEntry(const nsAString &aData)
mCacheEntry->SetSecurityInfo(mSecurityInfo);
}
if (mCharsetSet) {
mCacheEntry->SetMetaDataElement("charset", mCharset.get());
nsCAutoString source;
source.AppendInt(mCharsetSource);
mCacheEntry->SetMetaDataElement("charset-source", source.get());
if (mNeedToWriteCharset) {
WriteCharsetAndSourceToCache(mCharsetSource, mCharset);
mNeedToWriteCharset = PR_FALSE;
}
PRUint32 out;
@ -406,9 +403,13 @@ nsWyciwygChannel::SetCharsetAndSource(PRInt32 aSource,
{
NS_ENSURE_ARG(!aCharset.IsEmpty());
mCharsetSet = PR_TRUE;
mCharsetSource = aSource;
mCharset = aCharset;
if (mCacheEntry) {
WriteCharsetAndSourceToCache(aSource, PromiseFlatCString(aCharset));
} else {
mNeedToWriteCharset = PR_TRUE;
mCharsetSource = aSource;
mCharset = aCharset;
}
return NS_OK;
}
@ -638,4 +639,17 @@ nsWyciwygChannel::ReadFromCache()
return mPump->AsyncRead(this, nsnull);
}
void
nsWyciwygChannel::WriteCharsetAndSourceToCache(PRInt32 aSource,
const nsCString& aCharset)
{
NS_PRECONDITION(mCacheEntry, "Better have cache entry!");
mCacheEntry->SetMetaDataElement("charset", aCharset.get());
nsCAutoString source;
source.AppendInt(aSource);
mCacheEntry->SetMetaDataElement("charset-source", source.get());
}
// vim: ts=2 sw=2

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

@ -83,10 +83,13 @@ public:
protected:
nsresult ReadFromCache();
nsresult OpenCacheEntry(const nsACString & aCacheKey, nsCacheAccessMode aWriteAccess, PRBool * aDelayFlag = nsnull);
void WriteCharsetAndSourceToCache(PRInt32 aSource,
const nsCString& aCharset);
nsresult mStatus;
PRPackedBool mIsPending;
PRPackedBool mCharsetSet;
PRPackedBool mNeedToWriteCharset;
PRInt32 mCharsetSource;
nsCString mCharset;
PRInt32 mContentLength;