Commit 41db2297 authored by dgrogan@chromium.org's avatar dgrogan@chromium.org

Change instances of s.IsCorruption() to leveldb_env::IsCorruption(s).

LevelDB sometimes returns Status::InvalidArgument() when it encounters
corruption. But LevelDB doesn't provide a Status::IsInvalidArgument()
accessor so we need to indirectly detect it.

This patch revealed that IndexedDBDatabaseOperationTest.CreatePutDelete
had been passing by accident. In order to make it continue to pass, this
patch adds a method to IndexedDBFakeBackingStore.

BUG=322707

Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=273757

Review URL: https://codereview.chromium.org/303073002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274066 0039d316-1c4b-4281-b951-d872f2087c98
parent 35805ad1
......@@ -27,6 +27,7 @@
#include "content/common/indexed_db/indexed_db_key_path.h"
#include "content/common/indexed_db/indexed_db_key_range.h"
#include "third_party/WebKit/public/platform/WebIDBDatabaseException.h"
#include "third_party/leveldatabase/env_chromium.h"
#include "webkit/browser/blob/blob_data_handle.h"
using base::ASCIIToUTF16;
......@@ -300,7 +301,7 @@ void IndexedDBDatabase::CreateObjectStore(int64 transaction_id,
ASCIIToUTF16("Internal error creating object store '") +
object_store_metadata.name + ASCIIToUTF16("'."));
transaction->Abort(error);
if (s.IsCorruption())
if (leveldb_env::IsCorruption(s))
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
return;
......@@ -424,7 +425,7 @@ void IndexedDBDatabase::DeleteIndexOperation(
IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
error_string);
transaction->Abort(error);
if (s.IsCorruption())
if (leveldb_env::IsCorruption(s))
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
return;
......@@ -557,7 +558,7 @@ void IndexedDBDatabase::GetOperation(
DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString();
IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
"Internal error deleting data in range");
if (s.IsCorruption()) {
if (leveldb_env::IsCorruption(s)) {
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
}
......@@ -585,7 +586,7 @@ void IndexedDBDatabase::GetOperation(
"Internal error in GetRecord.");
callbacks->OnError(error);
if (s.IsCorruption())
if (leveldb_env::IsCorruption(s))
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
return;
......@@ -618,7 +619,7 @@ void IndexedDBDatabase::GetOperation(
IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
"Internal error in GetPrimaryKeyViaIndex.");
callbacks->OnError(error);
if (s.IsCorruption())
if (leveldb_env::IsCorruption(s))
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
return;
......@@ -644,7 +645,7 @@ void IndexedDBDatabase::GetOperation(
IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
"Internal error in GetRecord.");
callbacks->OnError(error);
if (s.IsCorruption())
if (leveldb_env::IsCorruption(s))
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
return;
......@@ -790,7 +791,7 @@ void IndexedDBDatabase::PutOperation(scoped_ptr<PutOperationParams> params,
IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
"Internal error checking key existence.");
params->callbacks->OnError(error);
if (s.IsCorruption())
if (leveldb_env::IsCorruption(s))
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
return;
......@@ -843,7 +844,7 @@ void IndexedDBDatabase::PutOperation(scoped_ptr<PutOperationParams> params,
blink::WebIDBDatabaseExceptionUnknownError,
"Internal error: backing store error performing put/add.");
params->callbacks->OnError(error);
if (s.IsCorruption())
if (leveldb_env::IsCorruption(s))
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
return;
......@@ -871,7 +872,7 @@ void IndexedDBDatabase::PutOperation(scoped_ptr<PutOperationParams> params,
IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
"Internal error updating key generator.");
params->callbacks->OnError(error);
if (s.IsCorruption())
if (leveldb_env::IsCorruption(s))
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
return;
......@@ -906,7 +907,7 @@ void IndexedDBDatabase::SetIndexKeys(int64 transaction_id,
IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
"Internal error setting index keys.");
transaction->Abort(error);
if (s.IsCorruption())
if (leveldb_env::IsCorruption(s))
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
return;
......@@ -1085,7 +1086,7 @@ void IndexedDBDatabase::OpenCursorOperation(
DLOG(ERROR) << "Unable to open cursor operation: " << s.ToString();
IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
"Internal error opening cursor operation");
if (s.IsCorruption()) {
if (leveldb_env::IsCorruption(s)) {
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
}
......@@ -1160,7 +1161,7 @@ void IndexedDBDatabase::CountOperation(
DLOG(ERROR) << "Unable perform count operation: " << s.ToString();
IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
"Internal error performing count operation");
if (s.IsCorruption()) {
if (leveldb_env::IsCorruption(s)) {
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
}
......@@ -1235,7 +1236,7 @@ void IndexedDBDatabase::DeleteRangeOperation(
IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
ASCIIToUTF16("Internal error deleting range"));
transaction->Abort(error);
if (s.IsCorruption()) {
if (leveldb_env::IsCorruption(s)) {
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
}
......@@ -1272,7 +1273,7 @@ void IndexedDBDatabase::ClearOperation(
IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
"Internal error clearing object store");
callbacks->OnError(error);
if (s.IsCorruption()) {
if (leveldb_env::IsCorruption(s)) {
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
}
......@@ -1299,7 +1300,7 @@ void IndexedDBDatabase::DeleteObjectStoreOperation(
IndexedDBDatabaseError error(blink::WebIDBDatabaseExceptionUnknownError,
error_string);
transaction->Abort(error);
if (s.IsCorruption())
if (leveldb_env::IsCorruption(s))
factory_->HandleBackingStoreCorruption(backing_store_->origin_url(),
error);
return;
......
......@@ -400,6 +400,8 @@ TEST_F(IndexedDBDatabaseOperationTest, CreatePutDelete) {
// This will execute the Put then Delete.
RunPostedTasks();
EXPECT_EQ(0ULL, db_->metadata().object_stores.size());
transaction_->Commit(); // Cleans up the object hierarchy.
}
} // namespace content
......@@ -13,6 +13,7 @@
#include "content/browser/indexed_db/indexed_db_tracing.h"
#include "content/browser/indexed_db/indexed_db_transaction_coordinator.h"
#include "third_party/WebKit/public/platform/WebIDBDatabaseException.h"
#include "third_party/leveldatabase/env_chromium.h"
#include "webkit/common/database/database_identifier.h"
using base::ASCIIToUTF16;
......@@ -250,7 +251,7 @@ void IndexedDBFactory::DeleteDatabase(
"Internal error creating database backend for "
"indexedDB.deleteDatabase."));
callbacks->OnError(error);
if (s.IsCorruption())
if (leveldb_env::IsCorruption(s))
HandleBackingStoreCorruption(origin_url, error);
return;
}
......@@ -436,7 +437,7 @@ void IndexedDBFactory::Open(const base::string16& name,
"database backend for "
"indexedDB.open."));
connection.callbacks->OnError(error);
if (s.IsCorruption()) {
if (leveldb_env::IsCorruption(s)) {
backing_store = NULL; // Closes the LevelDB so that it can be deleted
HandleBackingStoreCorruption(origin_url, error);
}
......
......@@ -70,6 +70,13 @@ leveldb::Status IndexedDBFakeBackingStore::CreateObjectStore(
return leveldb::Status::OK();
}
leveldb::Status IndexedDBFakeBackingStore::DeleteObjectStore(
Transaction* transaction,
int64 database_id,
int64 object_store_id) {
return leveldb::Status::OK();
}
leveldb::Status IndexedDBFakeBackingStore::PutRecord(
IndexedDBBackingStore::Transaction* transaction,
int64 database_id,
......
......@@ -44,6 +44,10 @@ class IndexedDBFakeBackingStore : public IndexedDBBackingStore {
const IndexedDBKeyPath&,
bool auto_increment) OVERRIDE;
virtual leveldb::Status DeleteObjectStore(Transaction* transaction,
int64 database_id,
int64 object_store_id) OVERRIDE;
virtual leveldb::Status PutRecord(
IndexedDBBackingStore::Transaction* transaction,
int64 database_id,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment