| 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 0da2abd5b8aff66b948e8cbf036f755d4f13c730..4cba1653922814baceff52090a34b5f66e64802e 100644
|
| --- a/content/browser/indexed_db/indexed_db_backing_store.cc
|
| +++ b/content/browser/indexed_db/indexed_db_backing_store.cc
|
| @@ -4,8 +4,6 @@
|
|
|
| #include "content/browser/indexed_db/indexed_db_backing_store.h"
|
|
|
| -#include <string>
|
| -
|
| #include "base/file_util.h"
|
| #include "base/logging.h"
|
| #include "base/metrics/histogram.h"
|
| @@ -17,7 +15,6 @@
|
| #include "content/browser/indexed_db/leveldb/leveldb_comparator.h"
|
| #include "content/browser/indexed_db/leveldb/leveldb_database.h"
|
| #include "content/browser/indexed_db/leveldb/leveldb_iterator.h"
|
| -#include "content/browser/indexed_db/leveldb/leveldb_slice.h"
|
| #include "content/browser/indexed_db/leveldb/leveldb_transaction.h"
|
| #include "content/common/indexed_db/indexed_db_key.h"
|
| #include "content/common/indexed_db/indexed_db_key_path.h"
|
| @@ -88,16 +85,16 @@ static void RecordInternalError(const char* type,
|
| #define INTERNAL_WRITE_ERROR(location) REPORT_ERROR("Write", location)
|
|
|
| static void PutBool(LevelDBTransaction* transaction,
|
| - const LevelDBSlice& key,
|
| + const StringPiece& key,
|
| bool value) {
|
| - std::vector<char> buffer;
|
| + std::string buffer;
|
| EncodeBool(value, &buffer);
|
| transaction->Put(key, &buffer);
|
| }
|
|
|
| template <typename DBOrTransaction>
|
| static bool GetInt(DBOrTransaction* db,
|
| - const LevelDBSlice& key,
|
| + const StringPiece& key,
|
| int64* found_int,
|
| bool* found) {
|
| std::string result;
|
| @@ -111,17 +108,17 @@ static bool GetInt(DBOrTransaction* db,
|
| }
|
|
|
| static void PutInt(LevelDBTransaction* transaction,
|
| - const LevelDBSlice& key,
|
| + const StringPiece& key,
|
| int64 value) {
|
| DCHECK_GE(value, 0);
|
| - std::vector<char> buffer;
|
| + std::string buffer;
|
| EncodeInt(value, &buffer);
|
| transaction->Put(key, &buffer);
|
| }
|
|
|
| template <typename DBOrTransaction>
|
| WARN_UNUSED_RESULT static bool GetVarInt(DBOrTransaction* db,
|
| - const LevelDBSlice& key,
|
| + const StringPiece& key,
|
| int64* found_int,
|
| bool* found) {
|
| std::string result;
|
| @@ -135,16 +132,16 @@ WARN_UNUSED_RESULT static bool GetVarInt(DBOrTransaction* db,
|
| }
|
|
|
| static void PutVarInt(LevelDBTransaction* transaction,
|
| - const LevelDBSlice& key,
|
| + const StringPiece& key,
|
| int64 value) {
|
| - std::vector<char> buffer;
|
| + std::string buffer;
|
| EncodeVarInt(value, &buffer);
|
| transaction->Put(key, &buffer);
|
| }
|
|
|
| template <typename DBOrTransaction>
|
| WARN_UNUSED_RESULT static bool GetString(DBOrTransaction* db,
|
| - const LevelDBSlice& key,
|
| + const StringPiece& key,
|
| string16* found_string,
|
| bool* found) {
|
| std::string result;
|
| @@ -159,32 +156,32 @@ WARN_UNUSED_RESULT static bool GetString(DBOrTransaction* db,
|
| }
|
|
|
| static void PutString(LevelDBTransaction* transaction,
|
| - const LevelDBSlice& key,
|
| + const StringPiece& key,
|
| const string16& value) {
|
| - std::vector<char> buffer;
|
| + std::string buffer;
|
| EncodeString(value, &buffer);
|
| transaction->Put(key, &buffer);
|
| }
|
|
|
| static void PutIDBKeyPath(LevelDBTransaction* transaction,
|
| - const LevelDBSlice& key,
|
| + const StringPiece& key,
|
| const IndexedDBKeyPath& value) {
|
| - std::vector<char> buffer;
|
| + std::string buffer;
|
| EncodeIDBKeyPath(value, &buffer);
|
| transaction->Put(key, &buffer);
|
| }
|
|
|
| -static int CompareKeys(const LevelDBSlice& a, const LevelDBSlice& b) {
|
| +static int CompareKeys(const StringPiece& a, const StringPiece& b) {
|
| return Compare(a, b, false /*index_keys*/);
|
| }
|
|
|
| -static int CompareIndexKeys(const LevelDBSlice& a, const LevelDBSlice& b) {
|
| +static int CompareIndexKeys(const StringPiece& a, const StringPiece& b) {
|
| return Compare(a, b, true /*index_keys*/);
|
| }
|
|
|
| class Comparator : public LevelDBComparator {
|
| public:
|
| - virtual int Compare(const LevelDBSlice& a, const LevelDBSlice& b) const
|
| + virtual int Compare(const StringPiece& a, const StringPiece& b) const
|
| OVERRIDE {
|
| return content::Compare(a, b, false /*index_keys*/);
|
| }
|
| @@ -198,8 +195,7 @@ static const int64 kLatestKnownSchemaVersion = 2;
|
| WARN_UNUSED_RESULT static bool IsSchemaKnown(LevelDBDatabase* db, bool* known) {
|
| int64 db_schema_version = 0;
|
| bool found = false;
|
| - bool ok = GetInt(
|
| - db, LevelDBSlice(SchemaVersionKey::Encode()), &db_schema_version, &found);
|
| + bool ok = GetInt(db, SchemaVersionKey::Encode(), &db_schema_version, &found);
|
| if (!ok)
|
| return false;
|
| if (!found) {
|
| @@ -213,8 +209,7 @@ WARN_UNUSED_RESULT static bool IsSchemaKnown(LevelDBDatabase* db, bool* known) {
|
|
|
| const uint32 latest_known_data_version = kWireVersion;
|
| int64 db_data_version = 0;
|
| - ok = GetInt(
|
| - db, LevelDBSlice(DataVersionKey::Encode()), &db_data_version, &found);
|
| + ok = GetInt(db, DataVersionKey::Encode(), &db_data_version, &found);
|
| if (!ok)
|
| return false;
|
| if (!found) {
|
| @@ -235,8 +230,8 @@ WARN_UNUSED_RESULT static bool SetUpMetadata(
|
| LevelDBDatabase* db,
|
| const std::string& origin_identifier) {
|
| const uint32 latest_known_data_version = kWireVersion;
|
| - const std::vector<char> schema_version_key = SchemaVersionKey::Encode();
|
| - const std::vector<char> data_version_key = DataVersionKey::Encode();
|
| + const std::string schema_version_key = SchemaVersionKey::Encode();
|
| + const std::string data_version_key = DataVersionKey::Encode();
|
|
|
| scoped_refptr<LevelDBTransaction> transaction =
|
| LevelDBTransaction::Create(db);
|
| @@ -244,10 +239,8 @@ WARN_UNUSED_RESULT static bool SetUpMetadata(
|
| int64 db_schema_version = 0;
|
| int64 db_data_version = 0;
|
| bool found = false;
|
| - bool ok = GetInt(transaction.get(),
|
| - LevelDBSlice(schema_version_key),
|
| - &db_schema_version,
|
| - &found);
|
| + bool ok =
|
| + GetInt(transaction.get(), schema_version_key, &db_schema_version, &found);
|
| if (!ok) {
|
| INTERNAL_READ_ERROR(SET_UP_METADATA);
|
| return false;
|
| @@ -255,25 +248,22 @@ WARN_UNUSED_RESULT static bool SetUpMetadata(
|
| if (!found) {
|
| // Initialize new backing store.
|
| db_schema_version = kLatestKnownSchemaVersion;
|
| - PutInt(
|
| - transaction.get(), LevelDBSlice(schema_version_key), db_schema_version);
|
| + PutInt(transaction.get(), schema_version_key, db_schema_version);
|
| db_data_version = latest_known_data_version;
|
| - PutInt(transaction.get(), LevelDBSlice(data_version_key), db_data_version);
|
| + PutInt(transaction.get(), data_version_key, db_data_version);
|
| } else {
|
| // Upgrade old backing store.
|
| DCHECK_LE(db_schema_version, kLatestKnownSchemaVersion);
|
| if (db_schema_version < 1) {
|
| db_schema_version = 1;
|
| - PutInt(transaction.get(),
|
| - LevelDBSlice(schema_version_key),
|
| - db_schema_version);
|
| - const std::vector<char> start_key =
|
| + PutInt(transaction.get(), schema_version_key, db_schema_version);
|
| + const std::string start_key =
|
| DatabaseNameKey::EncodeMinKeyForOrigin(origin_identifier);
|
| - const std::vector<char> stop_key =
|
| + const std::string stop_key =
|
| DatabaseNameKey::EncodeStopKeyForOrigin(origin_identifier);
|
| scoped_ptr<LevelDBIterator> it = db->CreateIterator();
|
| - for (it->Seek(LevelDBSlice(start_key));
|
| - it->IsValid() && CompareKeys(it->Key(), LevelDBSlice(stop_key)) < 0;
|
| + for (it->Seek(start_key);
|
| + it->IsValid() && CompareKeys(it->Key(), stop_key) < 0;
|
| it->Next()) {
|
| int64 database_id = 0;
|
| found = false;
|
| @@ -286,30 +276,24 @@ WARN_UNUSED_RESULT static bool SetUpMetadata(
|
| INTERNAL_CONSISTENCY_ERROR(SET_UP_METADATA);
|
| return false;
|
| }
|
| - std::vector<char> int_version_key = DatabaseMetaDataKey::Encode(
|
| + std::string int_version_key = DatabaseMetaDataKey::Encode(
|
| database_id, DatabaseMetaDataKey::USER_INT_VERSION);
|
| PutVarInt(transaction.get(),
|
| - LevelDBSlice(int_version_key),
|
| + int_version_key,
|
| IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION);
|
| }
|
| }
|
| if (db_schema_version < 2) {
|
| db_schema_version = 2;
|
| - PutInt(transaction.get(),
|
| - LevelDBSlice(schema_version_key),
|
| - db_schema_version);
|
| + PutInt(transaction.get(), schema_version_key, db_schema_version);
|
| db_data_version = kWireVersion;
|
| - PutInt(
|
| - transaction.get(), LevelDBSlice(data_version_key), db_data_version);
|
| + PutInt(transaction.get(), data_version_key, db_data_version);
|
| }
|
| }
|
|
|
| // All new values will be written using this serialization version.
|
| found = false;
|
| - ok = GetInt(transaction.get(),
|
| - LevelDBSlice(data_version_key),
|
| - &db_data_version,
|
| - &found);
|
| + ok = GetInt(transaction.get(), data_version_key, &db_data_version, &found);
|
| if (!ok) {
|
| INTERNAL_READ_ERROR(SET_UP_METADATA);
|
| return false;
|
| @@ -320,7 +304,7 @@ WARN_UNUSED_RESULT static bool SetUpMetadata(
|
| }
|
| if (db_data_version < latest_known_data_version) {
|
| db_data_version = latest_known_data_version;
|
| - PutInt(transaction.get(), LevelDBSlice(data_version_key), db_data_version);
|
| + PutInt(transaction.get(), data_version_key, db_data_version);
|
| }
|
|
|
| DCHECK_EQ(db_schema_version, kLatestKnownSchemaVersion);
|
| @@ -337,7 +321,7 @@ template <typename DBOrTransaction>
|
| WARN_UNUSED_RESULT static bool GetMaxObjectStoreId(DBOrTransaction* db,
|
| int64 database_id,
|
| int64* max_object_store_id) {
|
| - const std::vector<char> max_object_store_id_key = DatabaseMetaDataKey::Encode(
|
| + const std::string max_object_store_id_key = DatabaseMetaDataKey::Encode(
|
| database_id, DatabaseMetaDataKey::MAX_OBJECT_STORE_ID);
|
| bool ok =
|
| GetMaxObjectStoreId(db, max_object_store_id_key, max_object_store_id);
|
| @@ -347,12 +331,11 @@ WARN_UNUSED_RESULT static bool GetMaxObjectStoreId(DBOrTransaction* db,
|
| template <typename DBOrTransaction>
|
| WARN_UNUSED_RESULT static bool GetMaxObjectStoreId(
|
| DBOrTransaction* db,
|
| - const std::vector<char>& max_object_store_id_key,
|
| + const std::string& max_object_store_id_key,
|
| int64* max_object_store_id) {
|
| *max_object_store_id = -1;
|
| bool found = false;
|
| - bool ok = GetInt(
|
| - db, LevelDBSlice(max_object_store_id_key), max_object_store_id, &found);
|
| + bool ok = GetInt(db, max_object_store_id_key, max_object_store_id, &found);
|
| if (!ok)
|
| return false;
|
| if (!found)
|
| @@ -391,7 +374,7 @@ IndexedDBBackingStore::~IndexedDBBackingStore() {
|
| }
|
|
|
| IndexedDBBackingStore::RecordIdentifier::RecordIdentifier(
|
| - const std::vector<char>& primary_key,
|
| + const std::string& primary_key,
|
| int64 version)
|
| : primary_key_(primary_key), version_(version) {
|
| DCHECK(!primary_key.empty());
|
| @@ -468,8 +451,8 @@ scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Open(
|
| }
|
|
|
| base::FilePath identifier_path =
|
| - base::FilePath().AppendASCII(origin_identifier).
|
| - AddExtension(FILE_PATH_LITERAL(".indexeddb.leveldb"));
|
| + base::FilePath().AppendASCII(origin_identifier)
|
| + .AddExtension(FILE_PATH_LITERAL(".indexeddb.leveldb"));
|
|
|
| int limit = file_util::GetMaximumPathComponentLength(path_base);
|
| if (limit == -1) {
|
| @@ -549,12 +532,11 @@ scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Open(
|
| ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_SUCCESS);
|
| } else if (is_disk_full) {
|
| LOG(ERROR) << "Unable to open backing store - disk is full.";
|
| - base::Histogram::FactoryGet(
|
| - "WebCore.IndexedDB.BackingStore.OpenStatus",
|
| - 1,
|
| - INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX,
|
| - INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1,
|
| - base::HistogramBase::kUmaTargetedHistogramFlag)
|
| + base::Histogram::FactoryGet("WebCore.IndexedDB.BackingStore.OpenStatus",
|
| + 1,
|
| + INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX,
|
| + INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_MAX + 1,
|
| + base::HistogramBase::kUmaTargetedHistogramFlag)
|
| ->Add(INDEXED_DB_LEVEL_DB_BACKING_STORE_OPEN_DISK_FULL);
|
| return scoped_refptr<IndexedDBBackingStore>();
|
| } else {
|
| @@ -658,16 +640,16 @@ scoped_refptr<IndexedDBBackingStore> IndexedDBBackingStore::Create(
|
|
|
| std::vector<string16> IndexedDBBackingStore::GetDatabaseNames() {
|
| std::vector<string16> found_names;
|
| - const std::vector<char> start_key =
|
| + const std::string start_key =
|
| DatabaseNameKey::EncodeMinKeyForOrigin(identifier_);
|
| - const std::vector<char> stop_key =
|
| + const std::string stop_key =
|
| DatabaseNameKey::EncodeStopKeyForOrigin(identifier_);
|
|
|
| DCHECK(found_names.empty());
|
|
|
| scoped_ptr<LevelDBIterator> it = db_->CreateIterator();
|
| - for (it->Seek(LevelDBSlice(start_key));
|
| - it->IsValid() && CompareKeys(it->Key(), LevelDBSlice(stop_key)) < 0;
|
| + for (it->Seek(start_key);
|
| + it->IsValid() && CompareKeys(it->Key(), stop_key) < 0;
|
| it->Next()) {
|
| const char* p = it->Key().begin();
|
| const char* limit = it->Key().end();
|
| @@ -685,10 +667,10 @@ bool IndexedDBBackingStore::GetIDBDatabaseMetaData(
|
| const string16& name,
|
| IndexedDBDatabaseMetadata* metadata,
|
| bool* found) {
|
| - const std::vector<char> key = DatabaseNameKey::Encode(identifier_, name);
|
| + const std::string key = DatabaseNameKey::Encode(identifier_, name);
|
| *found = false;
|
|
|
| - bool ok = GetInt(db_.get(), LevelDBSlice(key), &metadata->id, found);
|
| + bool ok = GetInt(db_.get(), key, &metadata->id, found);
|
| if (!ok) {
|
| INTERNAL_READ_ERROR(GET_IDBDATABASE_METADATA);
|
| return false;
|
| @@ -697,8 +679,8 @@ bool IndexedDBBackingStore::GetIDBDatabaseMetaData(
|
| return true;
|
|
|
| ok = GetString(db_.get(),
|
| - LevelDBSlice(DatabaseMetaDataKey::Encode(
|
| - metadata->id, DatabaseMetaDataKey::USER_VERSION)),
|
| + DatabaseMetaDataKey::Encode(metadata->id,
|
| + DatabaseMetaDataKey::USER_VERSION),
|
| &metadata->version,
|
| found);
|
| if (!ok) {
|
| @@ -711,8 +693,8 @@ bool IndexedDBBackingStore::GetIDBDatabaseMetaData(
|
| }
|
|
|
| ok = GetVarInt(db_.get(),
|
| - LevelDBSlice(DatabaseMetaDataKey::Encode(
|
| - metadata->id, DatabaseMetaDataKey::USER_INT_VERSION)),
|
| + DatabaseMetaDataKey::Encode(
|
| + metadata->id, DatabaseMetaDataKey::USER_INT_VERSION),
|
| &metadata->int_version,
|
| found);
|
| if (!ok) {
|
| @@ -745,10 +727,8 @@ WARN_UNUSED_RESULT static bool GetNewDatabaseId(LevelDBDatabase* db,
|
| *new_id = -1;
|
| int64 max_database_id = -1;
|
| bool found = false;
|
| - bool ok = GetInt(transaction.get(),
|
| - LevelDBSlice(MaxDatabaseIdKey::Encode()),
|
| - &max_database_id,
|
| - &found);
|
| + bool ok = GetInt(
|
| + transaction.get(), MaxDatabaseIdKey::Encode(), &max_database_id, &found);
|
| if (!ok) {
|
| INTERNAL_READ_ERROR(GET_NEW_DATABASE_ID);
|
| return false;
|
| @@ -759,8 +739,7 @@ WARN_UNUSED_RESULT static bool GetNewDatabaseId(LevelDBDatabase* db,
|
| DCHECK_GE(max_database_id, 0);
|
|
|
| int64 database_id = max_database_id + 1;
|
| - PutInt(
|
| - transaction.get(), LevelDBSlice(MaxDatabaseIdKey::Encode()), database_id);
|
| + PutInt(transaction.get(), MaxDatabaseIdKey::Encode(), database_id);
|
| if (!transaction->Commit()) {
|
| INTERNAL_WRITE_ERROR(GET_NEW_DATABASE_ID);
|
| return false;
|
| @@ -783,16 +762,15 @@ bool IndexedDBBackingStore::CreateIDBDatabaseMetaData(const string16& name,
|
|
|
| scoped_refptr<LevelDBTransaction> transaction =
|
| LevelDBTransaction::Create(db_.get());
|
| - PutInt(transaction.get(),
|
| - LevelDBSlice(DatabaseNameKey::Encode(identifier_, name)),
|
| - *row_id);
|
| - PutString(transaction.get(),
|
| - LevelDBSlice(DatabaseMetaDataKey::Encode(
|
| - *row_id, DatabaseMetaDataKey::USER_VERSION)),
|
| - version);
|
| + PutInt(
|
| + transaction.get(), DatabaseNameKey::Encode(identifier_, name), *row_id);
|
| + PutString(
|
| + transaction.get(),
|
| + DatabaseMetaDataKey::Encode(*row_id, DatabaseMetaDataKey::USER_VERSION),
|
| + version);
|
| PutVarInt(transaction.get(),
|
| - LevelDBSlice(DatabaseMetaDataKey::Encode(
|
| - *row_id, DatabaseMetaDataKey::USER_INT_VERSION)),
|
| + DatabaseMetaDataKey::Encode(*row_id,
|
| + DatabaseMetaDataKey::USER_INT_VERSION),
|
| int_version);
|
| if (!transaction->Commit()) {
|
| INTERNAL_WRITE_ERROR(CREATE_IDBDATABASE_METADATA);
|
| @@ -809,8 +787,8 @@ bool IndexedDBBackingStore::UpdateIDBDatabaseIntVersion(
|
| int_version = IndexedDBDatabaseMetadata::DEFAULT_INT_VERSION;
|
| DCHECK_GE(int_version, 0) << "int_version was " << int_version;
|
| PutVarInt(Transaction::LevelDBTransactionFrom(transaction),
|
| - LevelDBSlice(DatabaseMetaDataKey::Encode(
|
| - row_id, DatabaseMetaDataKey::USER_INT_VERSION)),
|
| + DatabaseMetaDataKey::Encode(row_id,
|
| + DatabaseMetaDataKey::USER_INT_VERSION),
|
| int_version);
|
| return true;
|
| }
|
| @@ -819,19 +797,18 @@ bool IndexedDBBackingStore::UpdateIDBDatabaseMetaData(
|
| IndexedDBBackingStore::Transaction* transaction,
|
| int64 row_id,
|
| const string16& version) {
|
| - PutString(Transaction::LevelDBTransactionFrom(transaction),
|
| - LevelDBSlice(DatabaseMetaDataKey::Encode(
|
| - row_id, DatabaseMetaDataKey::USER_VERSION)),
|
| - version);
|
| + PutString(
|
| + Transaction::LevelDBTransactionFrom(transaction),
|
| + DatabaseMetaDataKey::Encode(row_id, DatabaseMetaDataKey::USER_VERSION),
|
| + version);
|
| return true;
|
| }
|
|
|
| static void DeleteRange(LevelDBTransaction* transaction,
|
| - const std::vector<char>& begin,
|
| - const std::vector<char>& end) {
|
| + const std::string& begin,
|
| + const std::string& end) {
|
| scoped_ptr<LevelDBIterator> it = transaction->CreateIterator();
|
| - for (it->Seek(LevelDBSlice(begin));
|
| - it->IsValid() && CompareKeys(it->Key(), LevelDBSlice(end)) < 0;
|
| + for (it->Seek(begin); it->IsValid() && CompareKeys(it->Key(), end) < 0;
|
| it->Next())
|
| transaction->Remove(it->Key());
|
| }
|
| @@ -849,18 +826,18 @@ bool IndexedDBBackingStore::DeleteDatabase(const string16& name) {
|
| if (!success)
|
| return true;
|
|
|
| - const std::vector<char> start_key = DatabaseMetaDataKey::Encode(
|
| + const std::string start_key = DatabaseMetaDataKey::Encode(
|
| metadata.id, DatabaseMetaDataKey::ORIGIN_NAME);
|
| - const std::vector<char> stop_key = DatabaseMetaDataKey::Encode(
|
| + const std::string stop_key = DatabaseMetaDataKey::Encode(
|
| metadata.id + 1, DatabaseMetaDataKey::ORIGIN_NAME);
|
| scoped_ptr<LevelDBIterator> it = db_->CreateIterator();
|
| - for (it->Seek(LevelDBSlice(start_key));
|
| - it->IsValid() && CompareKeys(it->Key(), LevelDBSlice(stop_key)) < 0;
|
| + for (it->Seek(start_key);
|
| + it->IsValid() && CompareKeys(it->Key(), stop_key) < 0;
|
| it->Next())
|
| transaction->Remove(it->Key());
|
|
|
| - const std::vector<char> key = DatabaseNameKey::Encode(identifier_, name);
|
| - transaction->Remove(LevelDBSlice(key));
|
| + const std::string key = DatabaseNameKey::Encode(identifier_, name);
|
| + transaction->Remove(key);
|
|
|
| if (!transaction->Commit()) {
|
| INTERNAL_WRITE_ERROR(DELETE_DATABASE);
|
| @@ -870,10 +847,10 @@ bool IndexedDBBackingStore::DeleteDatabase(const string16& name) {
|
| }
|
|
|
| static bool CheckObjectStoreAndMetaDataType(const LevelDBIterator* it,
|
| - const std::vector<char>& stop_key,
|
| + const std::string& stop_key,
|
| int64 object_store_id,
|
| int64 meta_data_type) {
|
| - if (!it->IsValid() || CompareKeys(it->Key(), LevelDBSlice(stop_key)) >= 0)
|
| + if (!it->IsValid() || CompareKeys(it->Key(), stop_key) >= 0)
|
| return false;
|
|
|
| ObjectStoreMetaDataKey meta_data_key;
|
| @@ -895,16 +872,16 @@ bool IndexedDBBackingStore::GetObjectStores(
|
| IDB_TRACE("IndexedDBBackingStore::GetObjectStores");
|
| if (!KeyPrefix::IsValidDatabaseId(database_id))
|
| return false;
|
| - const std::vector<char> start_key =
|
| + const std::string start_key =
|
| ObjectStoreMetaDataKey::Encode(database_id, 1, 0);
|
| - const std::vector<char> stop_key =
|
| + const std::string stop_key =
|
| ObjectStoreMetaDataKey::EncodeMaxKey(database_id);
|
|
|
| DCHECK(object_stores->empty());
|
|
|
| scoped_ptr<LevelDBIterator> it = db_->CreateIterator();
|
| - it->Seek(LevelDBSlice(start_key));
|
| - while (it->IsValid() && CompareKeys(it->Key(), LevelDBSlice(stop_key)) < 0) {
|
| + it->Seek(start_key);
|
| + while (it->IsValid() && CompareKeys(it->Key(), stop_key) < 0) {
|
| const char* p = it->Key().begin();
|
| const char* limit = it->Key().end();
|
|
|
| @@ -924,7 +901,7 @@ bool IndexedDBBackingStore::GetObjectStores(
|
| // simplify.
|
| string16 object_store_name;
|
| {
|
| - StringPiece slice(it->Value().AsStringPiece());
|
| + StringPiece slice(it->Value());
|
| if (!DecodeString(&slice, &object_store_name) || !slice.empty())
|
| INTERNAL_CONSISTENCY_ERROR(GET_OBJECT_STORES);
|
| }
|
| @@ -939,7 +916,7 @@ bool IndexedDBBackingStore::GetObjectStores(
|
| }
|
| IndexedDBKeyPath key_path;
|
| {
|
| - StringPiece slice(it->Value().AsStringPiece());
|
| + StringPiece slice(it->Value());
|
| if (!DecodeIDBKeyPath(&slice, &key_path) || !slice.empty())
|
| INTERNAL_CONSISTENCY_ERROR(GET_OBJECT_STORES);
|
| }
|
| @@ -955,7 +932,7 @@ bool IndexedDBBackingStore::GetObjectStores(
|
| }
|
| bool auto_increment;
|
| {
|
| - StringPiece slice(it->Value().AsStringPiece());
|
| + StringPiece slice(it->Value());
|
| if (!DecodeBool(&slice, &auto_increment) || !slice.empty())
|
| INTERNAL_CONSISTENCY_ERROR(GET_OBJECT_STORES);
|
| }
|
| @@ -990,7 +967,7 @@ bool IndexedDBBackingStore::GetObjectStores(
|
| }
|
| int64 max_index_id;
|
| {
|
| - StringPiece slice(it->Value().AsStringPiece());
|
| + StringPiece slice(it->Value());
|
| if (!DecodeInt(&slice, &max_index_id) || !slice.empty())
|
| INTERNAL_CONSISTENCY_ERROR(GET_OBJECT_STORES);
|
| }
|
| @@ -1002,7 +979,7 @@ bool IndexedDBBackingStore::GetObjectStores(
|
| ObjectStoreMetaDataKey::HAS_KEY_PATH)) {
|
| bool has_key_path;
|
| {
|
| - StringPiece slice(it->Value().AsStringPiece());
|
| + StringPiece slice(it->Value());
|
| if (!DecodeBool(&slice, &has_key_path))
|
| INTERNAL_CONSISTENCY_ERROR(GET_OBJECT_STORES);
|
| }
|
| @@ -1027,7 +1004,7 @@ bool IndexedDBBackingStore::GetObjectStores(
|
| stop_key,
|
| object_store_id,
|
| ObjectStoreMetaDataKey::KEY_GENERATOR_CURRENT_NUMBER)) {
|
| - StringPiece slice(it->Value().AsStringPiece());
|
| + StringPiece slice(it->Value());
|
| if (!DecodeInt(&slice, &key_generator_current_number) || !slice.empty())
|
| INTERNAL_CONSISTENCY_ERROR(GET_OBJECT_STORES);
|
|
|
| @@ -1054,7 +1031,7 @@ WARN_UNUSED_RESULT static bool SetMaxObjectStoreId(
|
| LevelDBTransaction* transaction,
|
| int64 database_id,
|
| int64 object_store_id) {
|
| - const std::vector<char> max_object_store_id_key = DatabaseMetaDataKey::Encode(
|
| + const std::string max_object_store_id_key = DatabaseMetaDataKey::Encode(
|
| database_id, DatabaseMetaDataKey::MAX_OBJECT_STORE_ID);
|
| int64 max_object_store_id = -1;
|
| bool ok = GetMaxObjectStoreId(
|
| @@ -1068,7 +1045,7 @@ WARN_UNUSED_RESULT static bool SetMaxObjectStoreId(
|
| INTERNAL_CONSISTENCY_ERROR(SET_MAX_OBJECT_STORE_ID);
|
| return false;
|
| }
|
| - PutInt(transaction, LevelDBSlice(max_object_store_id_key), object_store_id);
|
| + PutInt(transaction, max_object_store_id_key, object_store_id);
|
| return true;
|
| }
|
|
|
| @@ -1087,40 +1064,38 @@ bool IndexedDBBackingStore::CreateObjectStore(
|
| if (!SetMaxObjectStoreId(leveldb_transaction, database_id, object_store_id))
|
| return false;
|
|
|
| - const std::vector<char> name_key = ObjectStoreMetaDataKey::Encode(
|
| + const std::string name_key = ObjectStoreMetaDataKey::Encode(
|
| database_id, object_store_id, ObjectStoreMetaDataKey::NAME);
|
| - const std::vector<char> key_path_key = ObjectStoreMetaDataKey::Encode(
|
| + const std::string key_path_key = ObjectStoreMetaDataKey::Encode(
|
| database_id, object_store_id, ObjectStoreMetaDataKey::KEY_PATH);
|
| - const std::vector<char> auto_increment_key = ObjectStoreMetaDataKey::Encode(
|
| + const std::string auto_increment_key = ObjectStoreMetaDataKey::Encode(
|
| database_id, object_store_id, ObjectStoreMetaDataKey::AUTO_INCREMENT);
|
| - const std::vector<char> evictable_key = ObjectStoreMetaDataKey::Encode(
|
| + const std::string evictable_key = ObjectStoreMetaDataKey::Encode(
|
| database_id, object_store_id, ObjectStoreMetaDataKey::EVICTABLE);
|
| - const std::vector<char> last_version_key = ObjectStoreMetaDataKey::Encode(
|
| + const std::string last_version_key = ObjectStoreMetaDataKey::Encode(
|
| database_id, object_store_id, ObjectStoreMetaDataKey::LAST_VERSION);
|
| - const std::vector<char> max_index_id_key = ObjectStoreMetaDataKey::Encode(
|
| + const std::string max_index_id_key = ObjectStoreMetaDataKey::Encode(
|
| database_id, object_store_id, ObjectStoreMetaDataKey::MAX_INDEX_ID);
|
| - const std::vector<char> has_key_path_key = ObjectStoreMetaDataKey::Encode(
|
| + const std::string has_key_path_key = ObjectStoreMetaDataKey::Encode(
|
| database_id, object_store_id, ObjectStoreMetaDataKey::HAS_KEY_PATH);
|
| - const std::vector<char> key_generator_current_number_key =
|
| + const std::string key_generator_current_number_key =
|
| ObjectStoreMetaDataKey::Encode(
|
| database_id,
|
| object_store_id,
|
| ObjectStoreMetaDataKey::KEY_GENERATOR_CURRENT_NUMBER);
|
| - const std::vector<char> names_key =
|
| - ObjectStoreNamesKey::Encode(database_id, name);
|
| -
|
| - PutString(leveldb_transaction, LevelDBSlice(name_key), name);
|
| - PutIDBKeyPath(leveldb_transaction, LevelDBSlice(key_path_key), key_path);
|
| - PutInt(leveldb_transaction, LevelDBSlice(auto_increment_key), auto_increment);
|
| - PutInt(leveldb_transaction, LevelDBSlice(evictable_key), false);
|
| - PutInt(leveldb_transaction, LevelDBSlice(last_version_key), 1);
|
| - PutInt(leveldb_transaction, LevelDBSlice(max_index_id_key), kMinimumIndexId);
|
| - PutBool(
|
| - leveldb_transaction, LevelDBSlice(has_key_path_key), !key_path.IsNull());
|
| + const std::string names_key = ObjectStoreNamesKey::Encode(database_id, name);
|
| +
|
| + PutString(leveldb_transaction, name_key, name);
|
| + PutIDBKeyPath(leveldb_transaction, key_path_key, key_path);
|
| + PutInt(leveldb_transaction, auto_increment_key, auto_increment);
|
| + PutInt(leveldb_transaction, evictable_key, false);
|
| + PutInt(leveldb_transaction, last_version_key, 1);
|
| + PutInt(leveldb_transaction, max_index_id_key, kMinimumIndexId);
|
| + PutBool(leveldb_transaction, has_key_path_key, !key_path.IsNull());
|
| PutInt(leveldb_transaction,
|
| - LevelDBSlice(key_generator_current_number_key),
|
| + key_generator_current_number_key,
|
| kKeyGeneratorInitialNumber);
|
| - PutInt(leveldb_transaction, LevelDBSlice(names_key), object_store_id);
|
| + PutInt(leveldb_transaction, names_key, object_store_id);
|
| return true;
|
| }
|
|
|
| @@ -1138,8 +1113,8 @@ bool IndexedDBBackingStore::DeleteObjectStore(
|
| bool found = false;
|
| bool ok = GetString(
|
| leveldb_transaction,
|
| - LevelDBSlice(ObjectStoreMetaDataKey::Encode(
|
| - database_id, object_store_id, ObjectStoreMetaDataKey::NAME)),
|
| + ObjectStoreMetaDataKey::Encode(
|
| + database_id, object_store_id, ObjectStoreMetaDataKey::NAME),
|
| &object_store_name,
|
| &found);
|
| if (!ok) {
|
| @@ -1156,8 +1131,8 @@ bool IndexedDBBackingStore::DeleteObjectStore(
|
| ObjectStoreMetaDataKey::Encode(database_id, object_store_id, 0),
|
| ObjectStoreMetaDataKey::EncodeMaxKey(database_id, object_store_id));
|
|
|
| - leveldb_transaction->Remove(LevelDBSlice(
|
| - ObjectStoreNamesKey::Encode(database_id, object_store_name)));
|
| + leveldb_transaction->Remove(
|
| + ObjectStoreNamesKey::Encode(database_id, object_store_name));
|
|
|
| DeleteRange(leveldb_transaction,
|
| IndexFreeListKey::Encode(database_id, object_store_id, 0),
|
| @@ -1174,21 +1149,21 @@ bool IndexedDBBackingStore::GetRecord(
|
| int64 database_id,
|
| int64 object_store_id,
|
| const IndexedDBKey& key,
|
| - std::vector<char>* record) {
|
| + std::string* record) {
|
| IDB_TRACE("IndexedDBBackingStore::GetRecord");
|
| if (!KeyPrefix::ValidIds(database_id, object_store_id))
|
| return false;
|
| LevelDBTransaction* leveldb_transaction =
|
| IndexedDBBackingStore::Transaction::LevelDBTransactionFrom(transaction);
|
|
|
| - const std::vector<char> leveldb_key =
|
| + const std::string leveldb_key =
|
| ObjectStoreDataKey::Encode(database_id, object_store_id, key);
|
| std::string data;
|
|
|
| record->clear();
|
|
|
| bool found = false;
|
| - bool ok = leveldb_transaction->Get(LevelDBSlice(leveldb_key), &data, &found);
|
| + bool ok = leveldb_transaction->Get(leveldb_key, &data, &found);
|
| if (!ok) {
|
| INTERNAL_READ_ERROR(GET_RECORD);
|
| return false;
|
| @@ -1207,7 +1182,7 @@ bool IndexedDBBackingStore::GetRecord(
|
| return false;
|
| }
|
|
|
| - record->insert(record->end(), slice.begin(), slice.end());
|
| + *record = slice.as_string();
|
| return true;
|
| }
|
|
|
| @@ -1216,14 +1191,13 @@ WARN_UNUSED_RESULT static bool GetNewVersionNumber(
|
| int64 database_id,
|
| int64 object_store_id,
|
| int64* new_version_number) {
|
| - const std::vector<char> last_version_key = ObjectStoreMetaDataKey::Encode(
|
| + const std::string last_version_key = ObjectStoreMetaDataKey::Encode(
|
| database_id, object_store_id, ObjectStoreMetaDataKey::LAST_VERSION);
|
|
|
| *new_version_number = -1;
|
| int64 last_version = -1;
|
| bool found = false;
|
| - bool ok = GetInt(
|
| - transaction, LevelDBSlice(last_version_key), &last_version, &found);
|
| + bool ok = GetInt(transaction, last_version_key, &last_version, &found);
|
| if (!ok) {
|
| INTERNAL_READ_ERROR(GET_NEW_VERSION_NUMBER);
|
| return false;
|
| @@ -1234,7 +1208,7 @@ WARN_UNUSED_RESULT static bool GetNewVersionNumber(
|
| DCHECK_GE(last_version, 0);
|
|
|
| int64 version = last_version + 1;
|
| - PutInt(transaction, LevelDBSlice(last_version_key), version);
|
| + PutInt(transaction, last_version_key, version);
|
|
|
| // TODO(jsbell): Think about how we want to handle the overflow scenario.
|
| DCHECK(version > last_version);
|
| @@ -1248,7 +1222,7 @@ bool IndexedDBBackingStore::PutRecord(
|
| int64 database_id,
|
| int64 object_store_id,
|
| const IndexedDBKey& key,
|
| - const std::vector<char>& value,
|
| + const std::string& value,
|
| RecordIdentifier* record_identifier) {
|
| IDB_TRACE("IndexedDBBackingStore::PutRecord");
|
| if (!KeyPrefix::ValidIds(database_id, object_store_id))
|
| @@ -1263,22 +1237,22 @@ bool IndexedDBBackingStore::PutRecord(
|
| if (!ok)
|
| return false;
|
| DCHECK_GE(version, 0);
|
| - const std::vector<char> object_storedata_key =
|
| + const std::string object_storedata_key =
|
| ObjectStoreDataKey::Encode(database_id, object_store_id, key);
|
|
|
| - std::vector<char> v;
|
| + std::string v;
|
| EncodeVarInt(version, &v);
|
| - v.insert(v.end(), value.begin(), value.end());
|
| + v.append(value);
|
|
|
| - leveldb_transaction->Put(LevelDBSlice(object_storedata_key), &v);
|
| + leveldb_transaction->Put(object_storedata_key, &v);
|
|
|
| - const std::vector<char> exists_entry_key =
|
| + const std::string exists_entry_key =
|
| ExistsEntryKey::Encode(database_id, object_store_id, key);
|
| - std::vector<char> version_encoded;
|
| + std::string version_encoded;
|
| EncodeInt(version, &version_encoded);
|
| - leveldb_transaction->Put(LevelDBSlice(exists_entry_key), &version_encoded);
|
| + leveldb_transaction->Put(exists_entry_key, &version_encoded);
|
|
|
| - std::vector<char> key_encoded;
|
| + std::string key_encoded;
|
| EncodeIDBKey(key, &key_encoded);
|
| record_identifier->Reset(key_encoded, version);
|
| return true;
|
| @@ -1293,9 +1267,9 @@ bool IndexedDBBackingStore::ClearObjectStore(
|
| return false;
|
| LevelDBTransaction* leveldb_transaction =
|
| IndexedDBBackingStore::Transaction::LevelDBTransactionFrom(transaction);
|
| - const std::vector<char> start_key =
|
| + const std::string start_key =
|
| KeyPrefix(database_id, object_store_id).Encode();
|
| - const std::vector<char> stop_key =
|
| + const std::string stop_key =
|
| KeyPrefix(database_id, object_store_id + 1).Encode();
|
|
|
| DeleteRange(leveldb_transaction, start_key, stop_key);
|
| @@ -1313,13 +1287,13 @@ bool IndexedDBBackingStore::DeleteRecord(
|
| LevelDBTransaction* leveldb_transaction =
|
| IndexedDBBackingStore::Transaction::LevelDBTransactionFrom(transaction);
|
|
|
| - const std::vector<char> object_store_data_key = ObjectStoreDataKey::Encode(
|
| + const std::string object_store_data_key = ObjectStoreDataKey::Encode(
|
| database_id, object_store_id, record_identifier.primary_key());
|
| - leveldb_transaction->Remove(LevelDBSlice(object_store_data_key));
|
| + leveldb_transaction->Remove(object_store_data_key);
|
|
|
| - const std::vector<char> exists_entry_key = ExistsEntryKey::Encode(
|
| + const std::string exists_entry_key = ExistsEntryKey::Encode(
|
| database_id, object_store_id, record_identifier.primary_key());
|
| - leveldb_transaction->Remove(LevelDBSlice(exists_entry_key));
|
| + leveldb_transaction->Remove(exists_entry_key);
|
| return true;
|
| }
|
|
|
| @@ -1333,7 +1307,7 @@ bool IndexedDBBackingStore::GetKeyGeneratorCurrentNumber(
|
| LevelDBTransaction* leveldb_transaction =
|
| IndexedDBBackingStore::Transaction::LevelDBTransactionFrom(transaction);
|
|
|
| - const std::vector<char> key_generator_current_number_key =
|
| + const std::string key_generator_current_number_key =
|
| ObjectStoreMetaDataKey::Encode(
|
| database_id,
|
| object_store_id,
|
| @@ -1343,8 +1317,8 @@ bool IndexedDBBackingStore::GetKeyGeneratorCurrentNumber(
|
| std::string data;
|
|
|
| bool found = false;
|
| - bool ok = leveldb_transaction->Get(
|
| - LevelDBSlice(key_generator_current_number_key), &data, &found);
|
| + bool ok =
|
| + leveldb_transaction->Get(key_generator_current_number_key, &data, &found);
|
| if (!ok) {
|
| INTERNAL_READ_ERROR(GET_KEY_GENERATOR_CURRENT_NUMBER);
|
| return false;
|
| @@ -1363,16 +1337,16 @@ bool IndexedDBBackingStore::GetKeyGeneratorCurrentNumber(
|
| // data. This violates the spec as the data may be cleared but the
|
| // key generator state must be preserved.
|
| // TODO(jsbell): Fix this for all stores on database open?
|
| - const std::vector<char> start_key =
|
| + const std::string start_key =
|
| ObjectStoreDataKey::Encode(database_id, object_store_id, MinIDBKey());
|
| - const std::vector<char> stop_key =
|
| + const std::string stop_key =
|
| ObjectStoreDataKey::Encode(database_id, object_store_id, MaxIDBKey());
|
|
|
| scoped_ptr<LevelDBIterator> it = leveldb_transaction->CreateIterator();
|
| int64 max_numeric_key = 0;
|
|
|
| - for (it->Seek(LevelDBSlice(start_key));
|
| - it->IsValid() && CompareKeys(it->Key(), LevelDBSlice(stop_key)) < 0;
|
| + for (it->Seek(start_key);
|
| + it->IsValid() && CompareKeys(it->Key(), stop_key) < 0;
|
| it->Next()) {
|
| const char* p = it->Key().begin();
|
| const char* limit = it->Key().end();
|
| @@ -1414,14 +1388,12 @@ bool IndexedDBBackingStore::MaybeUpdateKeyGeneratorCurrentNumber(
|
| return true;
|
| }
|
|
|
| - const std::vector<char> key_generator_current_number_key =
|
| + const std::string key_generator_current_number_key =
|
| ObjectStoreMetaDataKey::Encode(
|
| database_id,
|
| object_store_id,
|
| ObjectStoreMetaDataKey::KEY_GENERATOR_CURRENT_NUMBER);
|
| - PutInt(leveldb_transaction,
|
| - LevelDBSlice(key_generator_current_number_key),
|
| - new_number);
|
| + PutInt(leveldb_transaction, key_generator_current_number_key, new_number);
|
| return true;
|
| }
|
|
|
| @@ -1438,11 +1410,11 @@ bool IndexedDBBackingStore::KeyExistsInObjectStore(
|
| *found = false;
|
| LevelDBTransaction* leveldb_transaction =
|
| IndexedDBBackingStore::Transaction::LevelDBTransactionFrom(transaction);
|
| - const std::vector<char> leveldb_key =
|
| + const std::string leveldb_key =
|
| ObjectStoreDataKey::Encode(database_id, object_store_id, key);
|
| std::string data;
|
|
|
| - bool ok = leveldb_transaction->Get(LevelDBSlice(leveldb_key), &data, found);
|
| + bool ok = leveldb_transaction->Get(leveldb_key, &data, found);
|
| if (!ok) {
|
| INTERNAL_READ_ERROR(KEY_EXISTS_IN_OBJECT_STORE);
|
| return false;
|
| @@ -1459,17 +1431,17 @@ bool IndexedDBBackingStore::KeyExistsInObjectStore(
|
| if (!DecodeVarInt(&slice, &version))
|
| return false;
|
|
|
| - std::vector<char> encoded_key;
|
| + std::string encoded_key;
|
| EncodeIDBKey(key, &encoded_key);
|
| found_record_identifier->Reset(encoded_key, version);
|
| return true;
|
| }
|
|
|
| static bool CheckIndexAndMetaDataKey(const LevelDBIterator* it,
|
| - const std::vector<char>& stop_key,
|
| + const std::string& stop_key,
|
| int64 index_id,
|
| unsigned char meta_data_type) {
|
| - if (!it->IsValid() || CompareKeys(it->Key(), LevelDBSlice(stop_key)) >= 0)
|
| + if (!it->IsValid() || CompareKeys(it->Key(), stop_key) >= 0)
|
| return false;
|
|
|
| IndexMetaDataKey meta_data_key;
|
| @@ -1492,17 +1464,16 @@ bool IndexedDBBackingStore::GetIndexes(
|
| IDB_TRACE("IndexedDBBackingStore::GetIndexes");
|
| if (!KeyPrefix::ValidIds(database_id, object_store_id))
|
| return false;
|
| - const std::vector<char> start_key =
|
| + const std::string start_key =
|
| IndexMetaDataKey::Encode(database_id, object_store_id, 0, 0);
|
| - const std::vector<char> stop_key =
|
| + const std::string stop_key =
|
| IndexMetaDataKey::Encode(database_id, object_store_id + 1, 0, 0);
|
|
|
| DCHECK(indexes->empty());
|
|
|
| scoped_ptr<LevelDBIterator> it = db_->CreateIterator();
|
| - it->Seek(LevelDBSlice(start_key));
|
| - while (it->IsValid() &&
|
| - CompareKeys(LevelDBSlice(it->Key()), LevelDBSlice(stop_key)) < 0) {
|
| + it->Seek(start_key);
|
| + while (it->IsValid() && CompareKeys(it->Key(), stop_key) < 0) {
|
| const char* p = it->Key().begin();
|
| const char* limit = it->Key().end();
|
|
|
| @@ -1522,7 +1493,7 @@ bool IndexedDBBackingStore::GetIndexes(
|
| int64 index_id = meta_data_key.IndexId();
|
| string16 index_name;
|
| {
|
| - StringPiece slice(it->Value().AsStringPiece());
|
| + StringPiece slice(it->Value());
|
| if (!DecodeString(&slice, &index_name) || !slice.empty())
|
| INTERNAL_CONSISTENCY_ERROR(GET_INDEXES);
|
| }
|
| @@ -1535,7 +1506,7 @@ bool IndexedDBBackingStore::GetIndexes(
|
| }
|
| bool index_unique;
|
| {
|
| - StringPiece slice(it->Value().AsStringPiece());
|
| + StringPiece slice(it->Value());
|
| if (!DecodeBool(&slice, &index_unique) || !slice.empty())
|
| INTERNAL_CONSISTENCY_ERROR(GET_INDEXES);
|
| }
|
| @@ -1548,7 +1519,7 @@ bool IndexedDBBackingStore::GetIndexes(
|
| }
|
| IndexedDBKeyPath key_path;
|
| {
|
| - StringPiece slice(it->Value().AsStringPiece());
|
| + StringPiece slice(it->Value());
|
| if (!DecodeIDBKeyPath(&slice, &key_path) || !slice.empty())
|
| INTERNAL_CONSISTENCY_ERROR(GET_INDEXES);
|
| }
|
| @@ -1557,7 +1528,7 @@ bool IndexedDBBackingStore::GetIndexes(
|
| bool index_multi_entry = false;
|
| if (CheckIndexAndMetaDataKey(
|
| it.get(), stop_key, index_id, IndexMetaDataKey::MULTI_ENTRY)) {
|
| - StringPiece slice(it->Value().AsStringPiece());
|
| + StringPiece slice(it->Value());
|
| if (!DecodeBool(&slice, &index_multi_entry) || !slice.empty())
|
| INTERNAL_CONSISTENCY_ERROR(GET_INDEXES);
|
|
|
| @@ -1575,11 +1546,10 @@ WARN_UNUSED_RESULT static bool SetMaxIndexId(LevelDBTransaction* transaction,
|
| int64 object_store_id,
|
| int64 index_id) {
|
| int64 max_index_id = -1;
|
| - const std::vector<char> max_index_id_key = ObjectStoreMetaDataKey::Encode(
|
| + const std::string max_index_id_key = ObjectStoreMetaDataKey::Encode(
|
| database_id, object_store_id, ObjectStoreMetaDataKey::MAX_INDEX_ID);
|
| bool found = false;
|
| - bool ok = GetInt(
|
| - transaction, LevelDBSlice(max_index_id_key), &max_index_id, &found);
|
| + bool ok = GetInt(transaction, max_index_id_key, &max_index_id, &found);
|
| if (!ok) {
|
| INTERNAL_READ_ERROR(SET_MAX_INDEX_ID);
|
| return false;
|
| @@ -1592,7 +1562,7 @@ WARN_UNUSED_RESULT static bool SetMaxIndexId(LevelDBTransaction* transaction,
|
| return false;
|
| }
|
|
|
| - PutInt(transaction, LevelDBSlice(max_index_id_key), index_id);
|
| + PutInt(transaction, max_index_id_key, index_id);
|
| return true;
|
| }
|
|
|
| @@ -1614,19 +1584,19 @@ bool IndexedDBBackingStore::CreateIndex(
|
| leveldb_transaction, database_id, object_store_id, index_id))
|
| return false;
|
|
|
| - const std::vector<char> name_key = IndexMetaDataKey::Encode(
|
| + const std::string name_key = IndexMetaDataKey::Encode(
|
| database_id, object_store_id, index_id, IndexMetaDataKey::NAME);
|
| - const std::vector<char> unique_key = IndexMetaDataKey::Encode(
|
| + const std::string unique_key = IndexMetaDataKey::Encode(
|
| database_id, object_store_id, index_id, IndexMetaDataKey::UNIQUE);
|
| - const std::vector<char> key_path_key = IndexMetaDataKey::Encode(
|
| + const std::string key_path_key = IndexMetaDataKey::Encode(
|
| database_id, object_store_id, index_id, IndexMetaDataKey::KEY_PATH);
|
| - const std::vector<char> multi_entry_key = IndexMetaDataKey::Encode(
|
| + const std::string multi_entry_key = IndexMetaDataKey::Encode(
|
| database_id, object_store_id, index_id, IndexMetaDataKey::MULTI_ENTRY);
|
|
|
| - PutString(leveldb_transaction, LevelDBSlice(name_key), name);
|
| - PutBool(leveldb_transaction, LevelDBSlice(unique_key), is_unique);
|
| - PutIDBKeyPath(leveldb_transaction, LevelDBSlice(key_path_key), key_path);
|
| - PutBool(leveldb_transaction, LevelDBSlice(multi_entry_key), is_multi_entry);
|
| + PutString(leveldb_transaction, name_key, name);
|
| + PutBool(leveldb_transaction, unique_key, is_unique);
|
| + PutIDBKeyPath(leveldb_transaction, key_path_key, key_path);
|
| + PutBool(leveldb_transaction, multi_entry_key, is_multi_entry);
|
| return true;
|
| }
|
|
|
| @@ -1641,15 +1611,15 @@ bool IndexedDBBackingStore::DeleteIndex(
|
| LevelDBTransaction* leveldb_transaction =
|
| IndexedDBBackingStore::Transaction::LevelDBTransactionFrom(transaction);
|
|
|
| - const std::vector<char> index_meta_data_start =
|
| + const std::string index_meta_data_start =
|
| IndexMetaDataKey::Encode(database_id, object_store_id, index_id, 0);
|
| - const std::vector<char> index_meta_data_end =
|
| + const std::string index_meta_data_end =
|
| IndexMetaDataKey::EncodeMaxKey(database_id, object_store_id, index_id);
|
| DeleteRange(leveldb_transaction, index_meta_data_start, index_meta_data_end);
|
|
|
| - const std::vector<char> index_data_start =
|
| + const std::string index_data_start =
|
| IndexDataKey::EncodeMinKey(database_id, object_store_id, index_id);
|
| - const std::vector<char> index_data_end =
|
| + const std::string index_data_end =
|
| IndexDataKey::EncodeMaxKey(database_id, object_store_id, index_id);
|
| DeleteRange(leveldb_transaction, index_data_start, index_data_end);
|
| return true;
|
| @@ -1670,10 +1640,10 @@ bool IndexedDBBackingStore::PutIndexDataForRecord(
|
| LevelDBTransaction* leveldb_transaction =
|
| IndexedDBBackingStore::Transaction::LevelDBTransactionFrom(transaction);
|
|
|
| - std::vector<char> encoded_key;
|
| + std::string encoded_key;
|
| EncodeIDBKey(key, &encoded_key);
|
|
|
| - const std::vector<char> index_data_key =
|
| + const std::string index_data_key =
|
| IndexDataKey::Encode(database_id,
|
| object_store_id,
|
| index_id,
|
| @@ -1681,20 +1651,19 @@ bool IndexedDBBackingStore::PutIndexDataForRecord(
|
| record_identifier.primary_key(),
|
| 0);
|
|
|
| - std::vector<char> data;
|
| + std::string data;
|
| EncodeVarInt(record_identifier.version(), &data);
|
| - const std::vector<char>& primary_key = record_identifier.primary_key();
|
| - data.insert(data.end(), primary_key.begin(), primary_key.end());
|
| + data.append(record_identifier.primary_key());
|
|
|
| - leveldb_transaction->Put(LevelDBSlice(index_data_key), &data);
|
| + leveldb_transaction->Put(index_data_key, &data);
|
| return true;
|
| }
|
|
|
| static bool FindGreatestKeyLessThanOrEqual(LevelDBTransaction* transaction,
|
| - const std::vector<char>& target,
|
| - std::vector<char>* found_key) {
|
| + const std::string& target,
|
| + std::string* found_key) {
|
| scoped_ptr<LevelDBIterator> it = transaction->CreateIterator();
|
| - it->Seek(LevelDBSlice(target));
|
| + it->Seek(target);
|
|
|
| if (!it->IsValid()) {
|
| it->SeekToLast();
|
| @@ -1702,18 +1671,18 @@ static bool FindGreatestKeyLessThanOrEqual(LevelDBTransaction* transaction,
|
| return false;
|
| }
|
|
|
| - while (CompareIndexKeys(LevelDBSlice(it->Key()), LevelDBSlice(target)) > 0) {
|
| + while (CompareIndexKeys(it->Key(), target) > 0) {
|
| it->Prev();
|
| if (!it->IsValid())
|
| return false;
|
| }
|
|
|
| do {
|
| - found_key->assign(it->Key().begin(), it->Key().end());
|
| + *found_key = it->Key().as_string();
|
|
|
| // There can be several index keys that compare equal. We want the last one.
|
| it->Next();
|
| - } while (it->IsValid() && !CompareIndexKeys(it->Key(), LevelDBSlice(target)));
|
| + } while (it->IsValid() && !CompareIndexKeys(it->Key(), target));
|
|
|
| return true;
|
| }
|
| @@ -1722,13 +1691,13 @@ static bool VersionExists(LevelDBTransaction* transaction,
|
| int64 database_id,
|
| int64 object_store_id,
|
| int64 version,
|
| - const std::vector<char>& encoded_primary_key,
|
| + const std::string& encoded_primary_key,
|
| bool* exists) {
|
| - const std::vector<char> key =
|
| + const std::string key =
|
| ExistsEntryKey::Encode(database_id, object_store_id, encoded_primary_key);
|
| std::string data;
|
|
|
| - bool ok = transaction->Get(LevelDBSlice(key), &data, exists);
|
| + bool ok = transaction->Get(key, &data, exists);
|
| if (!ok) {
|
| INTERNAL_READ_ERROR(VERSION_EXISTS);
|
| return false;
|
| @@ -1750,7 +1719,7 @@ bool IndexedDBBackingStore::FindKeyInIndex(
|
| int64 object_store_id,
|
| int64 index_id,
|
| const IndexedDBKey& key,
|
| - std::vector<char>* found_encoded_primary_key,
|
| + std::string* found_encoded_primary_key,
|
| bool* found) {
|
| IDB_TRACE("IndexedDBBackingStore::FindKeyInIndex");
|
| DCHECK(KeyPrefix::ValidIds(database_id, object_store_id, index_id));
|
| @@ -1760,26 +1729,25 @@ bool IndexedDBBackingStore::FindKeyInIndex(
|
|
|
| LevelDBTransaction* leveldb_transaction =
|
| IndexedDBBackingStore::Transaction::LevelDBTransactionFrom(transaction);
|
| - const std::vector<char> leveldb_key =
|
| + const std::string leveldb_key =
|
| IndexDataKey::Encode(database_id, object_store_id, index_id, key);
|
| scoped_ptr<LevelDBIterator> it = leveldb_transaction->CreateIterator();
|
| - it->Seek(LevelDBSlice(leveldb_key));
|
| + it->Seek(leveldb_key);
|
|
|
| for (;;) {
|
| if (!it->IsValid())
|
| return true;
|
| - if (CompareIndexKeys(it->Key(), LevelDBSlice(leveldb_key)) > 0)
|
| + if (CompareIndexKeys(it->Key(), leveldb_key) > 0)
|
| return true;
|
|
|
| - StringPiece slice(it->Value().AsStringPiece());
|
| + StringPiece slice(it->Value());
|
|
|
| int64 version;
|
| if (!DecodeVarInt(&slice, &version)) {
|
| INTERNAL_READ_ERROR(FIND_KEY_IN_INDEX);
|
| return false;
|
| }
|
| - found_encoded_primary_key->insert(
|
| - found_encoded_primary_key->end(), slice.begin(), slice.end());
|
| + *found_encoded_primary_key = slice.as_string();
|
|
|
| bool exists = false;
|
| bool ok = VersionExists(leveldb_transaction,
|
| @@ -1813,7 +1781,7 @@ bool IndexedDBBackingStore::GetPrimaryKeyViaIndex(
|
| return false;
|
|
|
| bool found = false;
|
| - std::vector<char> found_encoded_primary_key;
|
| + std::string found_encoded_primary_key;
|
| bool ok = FindKeyInIndex(transaction,
|
| database_id,
|
| object_store_id,
|
| @@ -1832,8 +1800,7 @@ bool IndexedDBBackingStore::GetPrimaryKeyViaIndex(
|
| return false;
|
| }
|
|
|
| - StringPiece slice(&*found_encoded_primary_key.begin(),
|
| - found_encoded_primary_key.size());
|
| + StringPiece slice(found_encoded_primary_key);
|
| return DecodeIDBKey(&slice, primary_key) && slice.empty();
|
| }
|
|
|
| @@ -1850,7 +1817,7 @@ bool IndexedDBBackingStore::KeyExistsInIndex(
|
| return false;
|
|
|
| *exists = false;
|
| - std::vector<char> found_encoded_primary_key;
|
| + std::string found_encoded_primary_key;
|
| bool ok = FindKeyInIndex(transaction,
|
| database_id,
|
| object_store_id,
|
| @@ -1869,8 +1836,7 @@ bool IndexedDBBackingStore::KeyExistsInIndex(
|
| return false;
|
| }
|
|
|
| - StringPiece slice(&*found_encoded_primary_key.begin(),
|
| - found_encoded_primary_key.size());
|
| + StringPiece slice(found_encoded_primary_key);
|
| return DecodeIDBKey(&slice, found_primary_key) && slice.empty();
|
| }
|
|
|
| @@ -1897,9 +1863,9 @@ IndexedDBBackingStore::Cursor::~Cursor() {}
|
| bool IndexedDBBackingStore::Cursor::FirstSeek() {
|
| iterator_ = transaction_->CreateIterator();
|
| if (cursor_options_.forward)
|
| - iterator_->Seek(LevelDBSlice(cursor_options_.low_key));
|
| + iterator_->Seek(cursor_options_.low_key);
|
| else
|
| - iterator_->Seek(LevelDBSlice(cursor_options_.high_key));
|
| + iterator_->Seek(cursor_options_.high_key);
|
|
|
| return ContinueFunction(0, READY);
|
| }
|
| @@ -1930,7 +1896,7 @@ bool IndexedDBBackingStore::Cursor::ContinueFunction(const IndexedDBKey* key,
|
| if (next_state == SEEK) {
|
| // TODO(jsbell): Optimize seeking for reverse cursors as well.
|
| if (first_iteration && key && key->IsValid() && forward) {
|
| - iterator_->Seek(LevelDBSlice(EncodeKey(*key)));
|
| + iterator_->Seek(EncodeKey(*key));
|
| first_iteration = false;
|
| } else if (forward) {
|
| iterator_->Next();
|
| @@ -2015,15 +1981,13 @@ bool IndexedDBBackingStore::Cursor::ContinueFunction(const IndexedDBKey* key,
|
|
|
| bool IndexedDBBackingStore::Cursor::HaveEnteredRange() const {
|
| if (cursor_options_.forward) {
|
| - int compare = CompareIndexKeys(iterator_->Key(),
|
| - LevelDBSlice(cursor_options_.low_key));
|
| + int compare = CompareIndexKeys(iterator_->Key(), cursor_options_.low_key);
|
| if (cursor_options_.low_open) {
|
| return compare > 0;
|
| }
|
| return compare >= 0;
|
| }
|
| - int compare = CompareIndexKeys(iterator_->Key(),
|
| - LevelDBSlice(cursor_options_.high_key));
|
| + int compare = CompareIndexKeys(iterator_->Key(), cursor_options_.high_key);
|
| if (cursor_options_.high_open) {
|
| return compare < 0;
|
| }
|
| @@ -2032,15 +1996,13 @@ bool IndexedDBBackingStore::Cursor::HaveEnteredRange() const {
|
|
|
| bool IndexedDBBackingStore::Cursor::IsPastBounds() const {
|
| if (cursor_options_.forward) {
|
| - int compare = CompareIndexKeys(iterator_->Key(),
|
| - LevelDBSlice(cursor_options_.high_key));
|
| + int compare = CompareIndexKeys(iterator_->Key(), cursor_options_.high_key);
|
| if (cursor_options_.high_open) {
|
| return compare >= 0;
|
| }
|
| return compare > 0;
|
| }
|
| - int compare =
|
| - CompareIndexKeys(iterator_->Key(), LevelDBSlice(cursor_options_.low_key));
|
| + int compare = CompareIndexKeys(iterator_->Key(), cursor_options_.low_key);
|
| if (cursor_options_.low_open) {
|
| return compare <= 0;
|
| }
|
| @@ -2068,14 +2030,14 @@ class ObjectStoreKeyCursorImpl : public IndexedDBBackingStore::Cursor {
|
| }
|
|
|
| // IndexedDBBackingStore::Cursor
|
| - virtual std::vector<char>* Value() OVERRIDE {
|
| + virtual std::string* Value() OVERRIDE {
|
| NOTREACHED();
|
| return NULL;
|
| }
|
| virtual bool LoadCurrentRow() OVERRIDE;
|
|
|
| protected:
|
| - virtual std::vector<char> EncodeKey(const IndexedDBKey& key) OVERRIDE {
|
| + virtual std::string EncodeKey(const IndexedDBKey& key) OVERRIDE {
|
| return ObjectStoreDataKey::Encode(
|
| cursor_options_.database_id, cursor_options_.object_store_id, key);
|
| }
|
| @@ -2100,14 +2062,14 @@ bool ObjectStoreKeyCursorImpl::LoadCurrentRow() {
|
| current_key_ = object_store_data_key.user_key();
|
|
|
| int64 version;
|
| - StringPiece slice(iterator_->Value().AsStringPiece());
|
| + StringPiece slice(iterator_->Value());
|
| if (!DecodeVarInt(&slice, &version)) {
|
| INTERNAL_READ_ERROR(LOAD_CURRENT_ROW);
|
| return false;
|
| }
|
|
|
| // TODO(jsbell): This re-encodes what was just decoded; try and optimize.
|
| - std::vector<char> encoded_key;
|
| + std::string encoded_key;
|
| EncodeIDBKey(*current_key_, &encoded_key);
|
| record_identifier_.Reset(encoded_key, version);
|
|
|
| @@ -2124,11 +2086,11 @@ class ObjectStoreCursorImpl : public IndexedDBBackingStore::Cursor {
|
| virtual Cursor* Clone() OVERRIDE { return new ObjectStoreCursorImpl(this); }
|
|
|
| // IndexedDBBackingStore::Cursor
|
| - virtual std::vector<char>* Value() OVERRIDE { return ¤t_value_; }
|
| + virtual std::string* Value() OVERRIDE { return ¤t_value_; }
|
| virtual bool LoadCurrentRow() OVERRIDE;
|
|
|
| protected:
|
| - virtual std::vector<char> EncodeKey(const IndexedDBKey& key) OVERRIDE {
|
| + virtual std::string EncodeKey(const IndexedDBKey& key) OVERRIDE {
|
| return ObjectStoreDataKey::Encode(
|
| cursor_options_.database_id, cursor_options_.object_store_id, key);
|
| }
|
| @@ -2138,7 +2100,7 @@ class ObjectStoreCursorImpl : public IndexedDBBackingStore::Cursor {
|
| : IndexedDBBackingStore::Cursor(other),
|
| current_value_(other->current_value_) {}
|
|
|
| - std::vector<char> current_value_;
|
| + std::string current_value_;
|
| };
|
|
|
| bool ObjectStoreCursorImpl::LoadCurrentRow() {
|
| @@ -2156,20 +2118,18 @@ bool ObjectStoreCursorImpl::LoadCurrentRow() {
|
| current_key_ = object_store_data_key.user_key();
|
|
|
| int64 version;
|
| - StringPiece slice(iterator_->Value().AsStringPiece());
|
| + StringPiece slice(iterator_->Value());
|
| if (!DecodeVarInt(&slice, &version)) {
|
| INTERNAL_READ_ERROR(LOAD_CURRENT_ROW);
|
| return false;
|
| }
|
|
|
| // TODO(jsbell): This re-encodes what was just decoded; try and optimize.
|
| - std::vector<char> encoded_key;
|
| + std::string encoded_key;
|
| EncodeIDBKey(*current_key_, &encoded_key);
|
| record_identifier_.Reset(encoded_key, version);
|
|
|
| - std::vector<char> value;
|
| - value.insert(value.end(), slice.begin(), slice.end());
|
| - current_value_.swap(value);
|
| + current_value_ = slice.as_string();
|
| return true;
|
| }
|
|
|
| @@ -2183,7 +2143,7 @@ class IndexKeyCursorImpl : public IndexedDBBackingStore::Cursor {
|
| virtual Cursor* Clone() OVERRIDE { return new IndexKeyCursorImpl(this); }
|
|
|
| // IndexedDBBackingStore::Cursor
|
| - virtual std::vector<char>* Value() OVERRIDE {
|
| + virtual std::string* Value() OVERRIDE {
|
| NOTREACHED();
|
| return NULL;
|
| }
|
| @@ -2198,7 +2158,7 @@ class IndexKeyCursorImpl : public IndexedDBBackingStore::Cursor {
|
| virtual bool LoadCurrentRow() OVERRIDE;
|
|
|
| protected:
|
| - virtual std::vector<char> EncodeKey(const IndexedDBKey& key) OVERRIDE {
|
| + virtual std::string EncodeKey(const IndexedDBKey& key) OVERRIDE {
|
| return IndexDataKey::Encode(cursor_options_.database_id,
|
| cursor_options_.object_store_id,
|
| cursor_options_.index_id,
|
| @@ -2223,7 +2183,7 @@ bool IndexKeyCursorImpl::LoadCurrentRow() {
|
| current_key_ = index_data_key.user_key();
|
| DCHECK(current_key_);
|
|
|
| - StringPiece slice(iterator_->Value().AsStringPiece());
|
| + StringPiece slice(iterator_->Value());
|
| int64 index_data_version;
|
| if (!DecodeVarInt(&slice, &index_data_version)) {
|
| INTERNAL_READ_ERROR(LOAD_CURRENT_ROW);
|
| @@ -2235,15 +2195,14 @@ bool IndexKeyCursorImpl::LoadCurrentRow() {
|
| return false;
|
| }
|
|
|
| - std::vector<char> primary_leveldb_key =
|
| + std::string primary_leveldb_key =
|
| ObjectStoreDataKey::Encode(index_data_key.DatabaseId(),
|
| index_data_key.ObjectStoreId(),
|
| *primary_key_);
|
|
|
| std::string result;
|
| bool found = false;
|
| - bool ok =
|
| - transaction_->Get(LevelDBSlice(primary_leveldb_key), &result, &found);
|
| + bool ok = transaction_->Get(primary_leveldb_key, &result, &found);
|
| if (!ok) {
|
| INTERNAL_READ_ERROR(LOAD_CURRENT_ROW);
|
| return false;
|
| @@ -2282,7 +2241,7 @@ class IndexCursorImpl : public IndexedDBBackingStore::Cursor {
|
| virtual Cursor* Clone() OVERRIDE { return new IndexCursorImpl(this); }
|
|
|
| // IndexedDBBackingStore::Cursor
|
| - virtual std::vector<char>* Value() OVERRIDE { return ¤t_value_; }
|
| + virtual std::string* Value() OVERRIDE { return ¤t_value_; }
|
| virtual const IndexedDBKey& primary_key() const OVERRIDE {
|
| return *primary_key_;
|
| }
|
| @@ -2294,7 +2253,7 @@ class IndexCursorImpl : public IndexedDBBackingStore::Cursor {
|
| virtual bool LoadCurrentRow() OVERRIDE;
|
|
|
| protected:
|
| - virtual std::vector<char> EncodeKey(const IndexedDBKey& key) OVERRIDE {
|
| + virtual std::string EncodeKey(const IndexedDBKey& key) OVERRIDE {
|
| return IndexDataKey::Encode(cursor_options_.database_id,
|
| cursor_options_.object_store_id,
|
| cursor_options_.index_id,
|
| @@ -2309,8 +2268,8 @@ class IndexCursorImpl : public IndexedDBBackingStore::Cursor {
|
| primary_leveldb_key_(other->primary_leveldb_key_) {}
|
|
|
| scoped_ptr<IndexedDBKey> primary_key_;
|
| - std::vector<char> current_value_;
|
| - std::vector<char> primary_leveldb_key_;
|
| + std::string current_value_;
|
| + std::string primary_leveldb_key_;
|
| };
|
|
|
| bool IndexCursorImpl::LoadCurrentRow() {
|
| @@ -2323,7 +2282,7 @@ bool IndexCursorImpl::LoadCurrentRow() {
|
| current_key_ = index_data_key.user_key();
|
| DCHECK(current_key_);
|
|
|
| - StringPiece slice(iterator_->Value().AsStringPiece());
|
| + StringPiece slice(iterator_->Value());
|
| int64 index_data_version;
|
| if (!DecodeVarInt(&slice, &index_data_version)) {
|
| INTERNAL_READ_ERROR(LOAD_CURRENT_ROW);
|
| @@ -2341,8 +2300,7 @@ bool IndexCursorImpl::LoadCurrentRow() {
|
|
|
| std::string result;
|
| bool found = false;
|
| - bool ok =
|
| - transaction_->Get(LevelDBSlice(primary_leveldb_key_), &result, &found);
|
| + bool ok = transaction_->Get(primary_leveldb_key_, &result, &found);
|
| if (!ok) {
|
| INTERNAL_READ_ERROR(LOAD_CURRENT_ROW);
|
| return false;
|
| @@ -2368,8 +2326,7 @@ bool IndexCursorImpl::LoadCurrentRow() {
|
| return false;
|
| }
|
|
|
| - current_value_.clear();
|
| - current_value_.insert(current_value_.end(), slice.begin(), slice.end());
|
| + current_value_ = slice.as_string();
|
| return true;
|
| }
|
|
|
| @@ -2421,7 +2378,7 @@ bool ObjectStoreCursorOptions(
|
|
|
| if (!cursor_options->forward) {
|
| // For reverse cursors, we need a key that exists.
|
| - std::vector<char> found_high_key;
|
| + std::string found_high_key;
|
| if (!FindGreatestKeyLessThanOrEqual(
|
| transaction, cursor_options->high_key, &found_high_key))
|
| return false;
|
| @@ -2429,9 +2386,7 @@ bool ObjectStoreCursorOptions(
|
| // If the target key should not be included, but we end up with a smaller
|
| // key, we should include that.
|
| if (cursor_options->high_open &&
|
| - CompareIndexKeys(LevelDBSlice(found_high_key),
|
| - LevelDBSlice(cursor_options->high_key)) <
|
| - 0)
|
| + CompareIndexKeys(found_high_key, cursor_options->high_key) < 0)
|
| cursor_options->high_open = false;
|
|
|
| cursor_options->high_key = found_high_key;
|
| @@ -2491,7 +2446,7 @@ bool IndexCursorOptions(
|
| database_id, object_store_id, index_id, range.upper());
|
| cursor_options->high_open = range.upperOpen();
|
|
|
| - std::vector<char> found_high_key;
|
| + std::string found_high_key;
|
| // Seek to the *last* key in the set of non-unique keys
|
| if (!FindGreatestKeyLessThanOrEqual(
|
| transaction, cursor_options->high_key, &found_high_key))
|
| @@ -2500,9 +2455,7 @@ bool IndexCursorOptions(
|
| // If the target key should not be included, but we end up with a smaller
|
| // key, we should include that.
|
| if (cursor_options->high_open &&
|
| - CompareIndexKeys(LevelDBSlice(found_high_key),
|
| - LevelDBSlice(cursor_options->high_key)) <
|
| - 0)
|
| + CompareIndexKeys(found_high_key, cursor_options->high_key) < 0)
|
| cursor_options->high_open = false;
|
|
|
| cursor_options->high_key = found_high_key;
|
|
|