| Index: content/browser/indexed_db/indexed_db_backing_store.cc
|
| diff --git a/content/browser/indexed_db/indexed_db_backing_store.cc b/content/browser/indexed_db/indexed_db_backing_store.cc
|
| index b33afc020c1bdfe08a258e8271d33bf2ac065ee5..c3fba32e6a96de7a77b90165c648df22d144db4f 100644
|
| --- a/content/browser/indexed_db/indexed_db_backing_store.cc
|
| +++ b/content/browser/indexed_db/indexed_db_backing_store.cc
|
| @@ -1363,14 +1363,19 @@ bool IndexedDBBackingStore::UpdateIDBDatabaseIntVersion(
|
| static leveldb::Status DeleteRangeBasic(LevelDBTransaction* transaction,
|
| const std::string& begin,
|
| const std::string& end,
|
| - bool upper_open) {
|
| + bool upper_open,
|
| + size_t* delete_count) {
|
| + DCHECK(delete_count);
|
| std::unique_ptr<LevelDBIterator> it = transaction->CreateIterator();
|
| leveldb::Status s;
|
| + *delete_count = 0;
|
| for (s = it->Seek(begin); s.ok() && it->IsValid() &&
|
| - (upper_open ? CompareKeys(it->Key(), end) < 0
|
| - : CompareKeys(it->Key(), end) <= 0);
|
| - s = it->Next())
|
| - transaction->Remove(it->Key());
|
| + (upper_open ? CompareKeys(it->Key(), end) < 0
|
| + : CompareKeys(it->Key(), end) <= 0);
|
| + s = it->Next()) {
|
| + if (transaction->Remove(it->Key()))
|
| + (*delete_count)++;
|
| + }
|
| return s;
|
| }
|
|
|
| @@ -1767,6 +1772,7 @@ leveldb::Status IndexedDBBackingStore::DeleteObjectStore(
|
| LevelDBTransaction* leveldb_transaction = transaction->transaction();
|
|
|
| base::string16 object_store_name;
|
| + size_t delete_count = 0;
|
| bool found = false;
|
| leveldb::Status s =
|
| GetString(leveldb_transaction,
|
| @@ -1792,8 +1798,8 @@ leveldb::Status IndexedDBBackingStore::DeleteObjectStore(
|
| s = DeleteRangeBasic(
|
| leveldb_transaction,
|
| ObjectStoreMetaDataKey::Encode(database_id, object_store_id, 0),
|
| - ObjectStoreMetaDataKey::EncodeMaxKey(database_id, object_store_id),
|
| - true);
|
| + ObjectStoreMetaDataKey::EncodeMaxKey(database_id, object_store_id), true,
|
| + &delete_count);
|
|
|
| if (s.ok()) {
|
| leveldb_transaction->Remove(
|
| @@ -1802,16 +1808,16 @@ leveldb::Status IndexedDBBackingStore::DeleteObjectStore(
|
| s = DeleteRangeBasic(
|
| leveldb_transaction,
|
| IndexFreeListKey::Encode(database_id, object_store_id, 0),
|
| - IndexFreeListKey::EncodeMaxKey(database_id, object_store_id),
|
| - true);
|
| + IndexFreeListKey::EncodeMaxKey(database_id, object_store_id), true,
|
| + &delete_count);
|
| }
|
|
|
| if (s.ok()) {
|
| s = DeleteRangeBasic(
|
| leveldb_transaction,
|
| IndexMetaDataKey::Encode(database_id, object_store_id, 0, 0),
|
| - IndexMetaDataKey::EncodeMaxKey(database_id, object_store_id),
|
| - true);
|
| + IndexMetaDataKey::EncodeMaxKey(database_id, object_store_id), true,
|
| + &delete_count);
|
| }
|
|
|
| if (!s.ok()) {
|
| @@ -1955,9 +1961,9 @@ leveldb::Status IndexedDBBackingStore::ClearObjectStore(
|
| KeyPrefix(database_id, object_store_id).Encode();
|
| const std::string stop_key =
|
| KeyPrefix(database_id, object_store_id + 1).Encode();
|
| -
|
| - leveldb::Status s =
|
| - DeleteRangeBasic(transaction->transaction(), start_key, stop_key, true);
|
| + size_t delete_count = 0;
|
| + leveldb::Status s = DeleteRangeBasic(transaction->transaction(), start_key,
|
| + stop_key, true, &delete_count);
|
| if (!s.ok()) {
|
| INTERNAL_WRITE_ERROR(CLEAR_OBJECT_STORE);
|
| return s;
|
| @@ -1993,8 +1999,11 @@ leveldb::Status IndexedDBBackingStore::DeleteRange(
|
| IndexedDBBackingStore::Transaction* transaction,
|
| int64_t database_id,
|
| int64_t object_store_id,
|
| - const IndexedDBKeyRange& key_range) {
|
| + const IndexedDBKeyRange& key_range,
|
| + size_t* exists_delete_count) {
|
| + DCHECK(exists_delete_count);
|
| leveldb::Status s;
|
| + *exists_delete_count = 0;
|
| std::unique_ptr<IndexedDBBackingStore::Cursor> start_cursor =
|
| OpenObjectStoreCursor(transaction, database_id, object_store_id,
|
| key_range, blink::WebIDBCursorDirectionNext, &s);
|
| @@ -2002,7 +2011,6 @@ leveldb::Status IndexedDBBackingStore::DeleteRange(
|
| return s;
|
| if (!start_cursor)
|
| return leveldb::Status::OK(); // Empty range == delete success.
|
| -
|
| std::unique_ptr<IndexedDBBackingStore::Cursor> end_cursor =
|
| OpenObjectStoreCursor(transaction, database_id, object_store_id,
|
| key_range, blink::WebIDBCursorDirectionPrev, &s);
|
| @@ -2013,7 +2021,6 @@ leveldb::Status IndexedDBBackingStore::DeleteRange(
|
| return leveldb::Status::OK(); // Empty range == delete success.
|
|
|
| BlobEntryKey start_blob_key, end_blob_key;
|
| -
|
| std::string start_key = ObjectStoreDataKey::Encode(
|
| database_id, object_store_id, start_cursor->key());
|
| base::StringPiece start_key_piece(start_key);
|
| @@ -2033,15 +2040,20 @@ leveldb::Status IndexedDBBackingStore::DeleteRange(
|
| false);
|
| if (!s.ok())
|
| return s;
|
| - s = DeleteRangeBasic(transaction->transaction(), start_key, stop_key, false);
|
| + size_t data_delete_count = 0;
|
| + s = DeleteRangeBasic(transaction->transaction(), start_key, stop_key, false,
|
| + &data_delete_count);
|
| if (!s.ok())
|
| return s;
|
| start_key =
|
| ExistsEntryKey::Encode(database_id, object_store_id, start_cursor->key());
|
| stop_key =
|
| ExistsEntryKey::Encode(database_id, object_store_id, end_cursor->key());
|
| - return DeleteRangeBasic(
|
| - transaction->transaction(), start_key, stop_key, false);
|
| +
|
| + s = DeleteRangeBasic(transaction->transaction(), start_key, stop_key, false,
|
| + exists_delete_count);
|
| + DCHECK_EQ(data_delete_count, *exists_delete_count);
|
| + return s;
|
| }
|
|
|
| leveldb::Status IndexedDBBackingStore::GetKeyGeneratorCurrentNumber(
|
| @@ -2835,20 +2847,22 @@ leveldb::Status IndexedDBBackingStore::DeleteIndex(
|
| return InvalidDBKeyStatus();
|
| LevelDBTransaction* leveldb_transaction = transaction->transaction();
|
|
|
| + size_t delete_count = 0;
|
| const std::string index_meta_data_start =
|
| IndexMetaDataKey::Encode(database_id, object_store_id, index_id, 0);
|
| const std::string index_meta_data_end =
|
| IndexMetaDataKey::EncodeMaxKey(database_id, object_store_id, index_id);
|
| - leveldb::Status s = DeleteRangeBasic(
|
| - leveldb_transaction, index_meta_data_start, index_meta_data_end, true);
|
| + leveldb::Status s =
|
| + DeleteRangeBasic(leveldb_transaction, index_meta_data_start,
|
| + index_meta_data_end, true, &delete_count);
|
|
|
| if (s.ok()) {
|
| const std::string index_data_start =
|
| IndexDataKey::EncodeMinKey(database_id, object_store_id, index_id);
|
| const std::string index_data_end =
|
| IndexDataKey::EncodeMaxKey(database_id, object_store_id, index_id);
|
| - s = DeleteRangeBasic(
|
| - leveldb_transaction, index_data_start, index_data_end, true);
|
| + s = DeleteRangeBasic(leveldb_transaction, index_data_start, index_data_end,
|
| + true, &delete_count);
|
| }
|
|
|
| if (!s.ok())
|
|
|