summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-31 22:17:51 +0000
committerdgrogan@chromium.org <dgrogan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-31 22:17:51 +0000
commit41db229745c2d9ebb677d399b562389952b253f5 (patch)
tree1c71ce38bde7cae482f6031a07f9f95c6590a7eb
parent35805ad1d6111f01fdecb2bfcb83a04b43f5df09 (diff)
downloadchromium_src-41db229745c2d9ebb677d399b562389952b253f5.zip
chromium_src-41db229745c2d9ebb677d399b562389952b253f5.tar.gz
chromium_src-41db229745c2d9ebb677d399b562389952b253f5.tar.bz2
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
-rw-r--r--content/browser/indexed_db/indexed_db_database.cc31
-rw-r--r--content/browser/indexed_db/indexed_db_database_unittest.cc2
-rw-r--r--content/browser/indexed_db/indexed_db_factory.cc5
-rw-r--r--content/browser/indexed_db/indexed_db_fake_backing_store.cc7
-rw-r--r--content/browser/indexed_db/indexed_db_fake_backing_store.h4
5 files changed, 32 insertions, 17 deletions
diff --git a/content/browser/indexed_db/indexed_db_database.cc b/content/browser/indexed_db/indexed_db_database.cc
index a7d5da0..c38ef19 100644
--- a/content/browser/indexed_db/indexed_db_database.cc
+++ b/content/browser/indexed_db/indexed_db_database.cc
@@ -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;
diff --git a/content/browser/indexed_db/indexed_db_database_unittest.cc b/content/browser/indexed_db/indexed_db_database_unittest.cc
index c5f3a13..30581c8 100644
--- a/content/browser/indexed_db/indexed_db_database_unittest.cc
+++ b/content/browser/indexed_db/indexed_db_database_unittest.cc
@@ -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
diff --git a/content/browser/indexed_db/indexed_db_factory.cc b/content/browser/indexed_db/indexed_db_factory.cc
index bf6e0b9..dccec5f 100644
--- a/content/browser/indexed_db/indexed_db_factory.cc
+++ b/content/browser/indexed_db/indexed_db_factory.cc
@@ -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);
}
diff --git a/content/browser/indexed_db/indexed_db_fake_backing_store.cc b/content/browser/indexed_db/indexed_db_fake_backing_store.cc
index 6773d1b..c77a691 100644
--- a/content/browser/indexed_db/indexed_db_fake_backing_store.cc
+++ b/content/browser/indexed_db/indexed_db_fake_backing_store.cc
@@ -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,
diff --git a/content/browser/indexed_db/indexed_db_fake_backing_store.h b/content/browser/indexed_db/indexed_db_fake_backing_store.h
index 43d244a..8b1d222 100644
--- a/content/browser/indexed_db/indexed_db_fake_backing_store.h
+++ b/content/browser/indexed_db/indexed_db_fake_backing_store.h
@@ -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,