Bug 856921 - Ensure that all quota failures are exposed to JS as QuotaExceededError. r=bent

This commit is contained in:
Jan Varga 2014-04-02 19:14:14 +02:00
Родитель 29eff211c9
Коммит 9ec24dfafc
7 изменённых файлов: 25 добавлений и 11 удалений

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

@ -127,5 +127,6 @@ DOM4_MSG_DEF(ReadOnlyError, "A mutation operation was attempted in a READ_ONLY l
DOM4_MSG_DEF(InvalidStateError, "A mutation operation was attempted on a file storage that did not allow mutations.", NS_ERROR_DOM_FILEHANDLE_NOT_ALLOWED_ERR)
DOM4_MSG_DEF(AbortError, "A request was aborted, for example through a call to LockedFile.abort.", NS_ERROR_DOM_FILEHANDLE_ABORT_ERR)
DOM4_MSG_DEF(QuotaExceededError, "The current locked file exceeded its quota limitations.", NS_ERROR_DOM_FILEHANDLE_QUOTA_ERR)
DOM_MSG_DEF(NS_ERROR_DOM_JS_EXCEPTION, "A callback threw an exception")

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

@ -110,7 +110,12 @@ FileHelper::OnStopRequest(nsIRequest* aRequest, nsISupports* aCtxt,
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (NS_FAILED(aStatus)) {
mResultCode = NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
if (aStatus == NS_ERROR_FILE_NO_DEVICE_SPACE) {
mResultCode = NS_ERROR_DOM_FILEHANDLE_QUOTA_ERR;
}
else {
mResultCode = NS_ERROR_DOM_FILEHANDLE_UNKNOWN_ERR;
}
}
Finish();

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

@ -2991,7 +2991,7 @@ CopyData(nsIInputStream* aInputStream, nsIOutputStream* aOutputStream)
uint32_t numRead;
rv = aInputStream->Read(copyBuffer, sizeof(copyBuffer), &numRead);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_ENSURE_SUCCESS(rv, rv);
if (!numRead) {
break;
@ -2999,16 +2999,16 @@ CopyData(nsIInputStream* aInputStream, nsIOutputStream* aOutputStream)
uint32_t numWrite;
rv = aOutputStream->Write(copyBuffer, numRead, &numWrite);
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (numWrite < numRead) {
// Must have hit the quota limit.
return NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR;
if (rv == NS_ERROR_FILE_NO_DEVICE_SPACE) {
rv = NS_ERROR_DOM_INDEXEDDB_QUOTA_ERR;
}
NS_ENSURE_SUCCESS(rv, rv);
NS_ENSURE_TRUE(numWrite == numRead, NS_ERROR_FAILURE);
} while (true);
rv = aOutputStream->Flush();
IDB_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
@ -3251,6 +3251,11 @@ AddHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
IDB_ENSURE_TRUE(outputStream, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
rv = CopyData(inputStream, outputStream);
if (NS_FAILED(rv) &&
NS_ERROR_GET_MODULE(rv) != NS_ERROR_MODULE_DOM_INDEXEDDB) {
IDB_REPORT_INTERNAL_ERR();
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
NS_ENSURE_SUCCESS(rv, rv);
cloneFile.mFile->AddFileInfo(fileInfo);

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

@ -40,7 +40,8 @@
let objectStore = trans.objectStore(objectStoreName);
request = objectStore.add(fileData.file, fileData.key);
request.addEventListener("error", new ExpectError("UnknownError", true));
request.addEventListener("error",
new ExpectError("QuotaExceededError", true));
request.onsuccess = unexpectedSuccessHandler;
event = yield undefined;

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

@ -41,7 +41,8 @@
let blob = getNullBlob(DEFAULT_QUOTA);
request = lockedFile.write(blob);
request.addEventListener("error", new ExpectError("UnknownError", true));
request.addEventListener("error",
new ExpectError("QuotaExceededError", true));
request.onsuccess = unexpectedSuccessHandler;
event = yield undefined;

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

@ -77,7 +77,7 @@ FileQuotaStreamWithWrite<FileStreamBase>::Write(const char* aBuf,
if (!FileQuotaStreamWithWrite::
mQuotaObject->MaybeAllocateMoreSpace(offset, aCount)) {
return NS_ERROR_FAILURE;
return NS_ERROR_FILE_NO_DEVICE_SPACE;
}
}

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

@ -809,6 +809,7 @@
ERROR(NS_ERROR_DOM_FILEHANDLE_LOCKEDFILE_INACTIVE_ERR, FAILURE(3)),
ERROR(NS_ERROR_DOM_FILEHANDLE_ABORT_ERR, FAILURE(4)),
ERROR(NS_ERROR_DOM_FILEHANDLE_READ_ONLY_ERR, FAILURE(5)),
ERROR(NS_ERROR_DOM_FILEHANDLE_QUOTA_ERR, FAILURE(6)),
#undef MODULE
/* ======================================================================= */