Bug 530901. Fix a warning and align an error code with the spec. r=jst a=jst

This commit is contained in:
Jonas Sicking 2009-11-24 17:53:17 -08:00
Родитель 16f471606f
Коммит 630d0607ed
3 изменённых файлов: 20 добавлений и 14 удалений

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

@ -44,7 +44,7 @@ interface nsIDOMFileError : nsISupports
const unsigned short NOT_FOUND_ERR = 8;
const unsigned short NOT_READABLE_ERR = 24;
const unsigned short SECURITY_ERR = 18;
const unsigned short ABORT_ERR = 25;
const unsigned short ABORT_ERR = 20;
const unsigned short ENCODING_ERR = 26;
readonly attribute unsigned short code;

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

@ -123,10 +123,6 @@ NS_INTERFACE_MAP_END_INHERITING(nsXHREventTarget)
NS_IMPL_ADDREF_INHERITED(nsDOMFileReader, nsXHREventTarget)
NS_IMPL_RELEASE_INHERITED(nsDOMFileReader, nsXHREventTarget)
static const PRUint32 FILE_AS_BINARY = 1;
static const PRUint32 FILE_AS_TEXT = 2;
static const PRUint32 FILE_AS_DATAURL = 3;
NS_IMETHODIMP
nsDOMFileReader::GetOnloadend(nsIDOMEventListener** aOnloadend)
{
@ -153,7 +149,7 @@ nsDOMFileReader::Notify(const char *aCharset, nsDetectionConfident aConf)
nsDOMFileReader::nsDOMFileReader()
: mFileData(nsnull),
mDataLen(0), mDataFormat(0),
mDataLen(0), mDataFormat(FILE_AS_BINARY),
mReadyState(nsIDOMFileReader::EMPTY),
mProgressEventWasDelayed(PR_FALSE),
mTimerIsActive(PR_FALSE),
@ -454,7 +450,7 @@ nsDOMFileReader::OnStopRequest(nsIRequest *aRequest,
return NS_OK;
}
nsresult rv;
nsresult rv = NS_OK;
switch (mDataFormat) {
case FILE_AS_BINARY:
break; //Already accumulated mResult
@ -464,17 +460,20 @@ nsDOMFileReader::OnStopRequest(nsIRequest *aRequest,
case FILE_AS_DATAURL:
rv = GetAsDataURL(mFile, mFileData, mDataLen, mResult);
break;
default:
return NS_ERROR_FAILURE;
}
FreeFileData();
if (NS_FAILED(rv)) {
DispatchError(rv);
return NS_OK;
}
//Dispatch load event to signify end of a successful load
DispatchProgressEvent(NS_LITERAL_STRING(LOAD_STR));
DispatchProgressEvent(NS_LITERAL_STRING(LOADEND_STR));
return rv;
return NS_OK;
}
// Helper methods
@ -482,8 +481,8 @@ nsDOMFileReader::OnStopRequest(nsIRequest *aRequest,
nsresult
nsDOMFileReader::ReadFileContent(nsIDOMFile* aFile,
const nsAString &aCharset,
PRUint32 aDataFormat)
{
eDataFormat aDataFormat)
{
NS_ENSURE_TRUE(aFile, NS_ERROR_NULL_POINTER);
//Implicit abort to clear any other activity going on

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

@ -111,7 +111,13 @@ public:
nsresult Init();
protected:
nsresult ReadFileContent(nsIDOMFile *aFile, const nsAString &aCharset, PRUint32 aDataFormat);
enum eDataFormat {
FILE_AS_BINARY,
FILE_AS_TEXT,
FILE_AS_DATAURL
};
nsresult ReadFileContent(nsIDOMFile *aFile, const nsAString &aCharset, eDataFormat aDataFormat);
nsresult GetAsText(const nsAString &aCharset,
const char *aFileData, PRUint32 aDataLen, nsAString &aResult);
nsresult GetAsDataURL(nsIFile *aFile, const char *aFileData, PRUint32 aDataLen, nsAString &aResult);
@ -130,7 +136,8 @@ protected:
nsCOMPtr<nsIFile> mFile;
nsString mCharset;
PRUint32 mDataLen;
PRUint32 mDataFormat;
eDataFormat mDataFormat;
nsString mResult;
PRUint16 mReadyState;