mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-24 19:37:15 +00:00
Fix nsStandardURL serialization/deserialization to properly restore all state. Bug 396389, r+sr=biesi, a=bsmedberg
This commit is contained in:
parent
2f0c7d5b24
commit
56d122cc1c
@ -82,7 +82,7 @@ const char XUL_FASTLOAD_FILE_BASENAME[] = "XUL";
|
||||
// (opaque to XPCOM FastLoad code) format of XUL-specific XDR serializations.
|
||||
// See also JSXDR_BYTECODE_VERSION in jsxdrapi.h, which tracks incompatible JS
|
||||
// bytecode version changes.
|
||||
#define XUL_FASTLOAD_FILE_VERSION (0xfeedbeef - 23)
|
||||
#define XUL_FASTLOAD_FILE_VERSION (0xfeedbeef - 24)
|
||||
|
||||
#define XUL_SERIALIZATION_BUFFER_SIZE (64 * 1024)
|
||||
#define XUL_DESERIALIZATION_BUFFER_SIZE (8 * 1024)
|
||||
|
@ -2631,6 +2631,10 @@ nsStandardURL::SetMutable(PRBool value)
|
||||
NS_IMETHODIMP
|
||||
nsStandardURL::Read(nsIObjectInputStream *stream)
|
||||
{
|
||||
NS_PRECONDITION(!mHostA, "Shouldn't have cached ASCII host");
|
||||
NS_PRECONDITION(mSpecEncoding == eEncoding_Unknown,
|
||||
"Shouldn't have spec encoding here");
|
||||
|
||||
nsresult rv;
|
||||
|
||||
PRUint32 urlType;
|
||||
@ -2706,9 +2710,30 @@ nsStandardURL::Read(nsIObjectInputStream *stream)
|
||||
PRBool isMutable;
|
||||
rv = stream->ReadBoolean(&isMutable);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (isMutable != PR_TRUE && isMutable != PR_FALSE) {
|
||||
NS_WARNING("Unexpected boolean value");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
mMutable = isMutable;
|
||||
|
||||
PRBool supportsFileURL;
|
||||
rv = stream->ReadBoolean(&supportsFileURL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (supportsFileURL != PR_TRUE && supportsFileURL != PR_FALSE) {
|
||||
NS_WARNING("Unexpected boolean value");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
mSupportsFileURL = supportsFileURL;
|
||||
|
||||
PRUint32 hostEncoding;
|
||||
rv = stream->Read32(&hostEncoding);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if (hostEncoding != eEncoding_ASCII && hostEncoding != eEncoding_UTF8) {
|
||||
NS_WARNING("Unexpected host encoding");
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
mHostEncoding = hostEncoding;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2774,6 +2799,14 @@ nsStandardURL::Write(nsIObjectOutputStream *stream)
|
||||
rv = stream->WriteBoolean(mMutable);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = stream->WriteBoolean(mSupportsFileURL);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = stream->Write32(mHostEncoding);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// mSpecEncoding and mHostA are just caches that can be recovered as needed.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user