Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1484)

Unified Diff: content/browser/indexed_db/indexed_db_leveldb_coding.h

Issue 18075008: IndexedDB: Switch key/value handling from vector<char> to std::string (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove C++11ism Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/indexed_db/indexed_db_leveldb_coding.h
diff --git a/content/browser/indexed_db/indexed_db_leveldb_coding.h b/content/browser/indexed_db/indexed_db_leveldb_coding.h
index caa932e97fe24be8fda3255b22f1edb407f0cae4..1c4d3ec9bc85e21650a4b635f033a640e3369538 100644
--- a/content/browser/indexed_db/indexed_db_leveldb_coding.h
+++ b/content/browser/indexed_db/indexed_db_leveldb_coding.h
@@ -5,7 +5,7 @@
#ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_
#define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_
-#include <vector>
+#include <string>
#include "base/basictypes.h"
#include "base/logging.h"
@@ -18,26 +18,22 @@
namespace content {
-class LevelDBSlice;
-
CONTENT_EXPORT extern const unsigned char kMinimumIndexId;
-CONTENT_EXPORT std::vector<char> MaxIDBKey();
-CONTENT_EXPORT std::vector<char> MinIDBKey();
+CONTENT_EXPORT std::string MaxIDBKey();
+CONTENT_EXPORT std::string MinIDBKey();
-CONTENT_EXPORT void EncodeByte(unsigned char value, std::vector<char>* into);
-CONTENT_EXPORT void EncodeBool(bool value, std::vector<char>* into);
-CONTENT_EXPORT void EncodeInt(int64 value, std::vector<char>* into);
-CONTENT_EXPORT void EncodeVarInt(int64 value, std::vector<char>* into);
-CONTENT_EXPORT void EncodeString(const string16& value,
- std::vector<char>* into);
+CONTENT_EXPORT void EncodeByte(unsigned char value, std::string* into);
+CONTENT_EXPORT void EncodeBool(bool value, std::string* into);
+CONTENT_EXPORT void EncodeInt(int64 value, std::string* into);
+CONTENT_EXPORT void EncodeVarInt(int64 value, std::string* into);
+CONTENT_EXPORT void EncodeString(const string16& value, std::string* into);
CONTENT_EXPORT void EncodeStringWithLength(const string16& value,
- std::vector<char>* into);
-CONTENT_EXPORT void EncodeDouble(double value, std::vector<char>* into);
-CONTENT_EXPORT void EncodeIDBKey(const IndexedDBKey& value,
- std::vector<char>* into);
+ std::string* into);
+CONTENT_EXPORT void EncodeDouble(double value, std::string* into);
+CONTENT_EXPORT void EncodeIDBKey(const IndexedDBKey& value, std::string* into);
CONTENT_EXPORT void EncodeIDBKeyPath(const IndexedDBKeyPath& value,
- std::vector<char>* into);
+ std::string* into);
CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeByte(base::StringPiece* slice,
unsigned char* value);
@@ -67,14 +63,14 @@ CONTENT_EXPORT int CompareEncodedStringsWithLength(base::StringPiece* slice1,
CONTENT_EXPORT WARN_UNUSED_RESULT bool ExtractEncodedIDBKey(
base::StringPiece* slice,
- std::vector<char>* result);
+ std::string* result);
-CONTENT_EXPORT int CompareEncodedIDBKeys(const std::vector<char>& a,
- const std::vector<char>& b,
+CONTENT_EXPORT int CompareEncodedIDBKeys(const std::string& a,
+ const std::string& b,
bool* ok);
-CONTENT_EXPORT int Compare(const LevelDBSlice& a,
- const LevelDBSlice& b,
+CONTENT_EXPORT int Compare(const base::StringPiece& a,
+ const base::StringPiece& b,
bool index_keys);
class KeyPrefix {
@@ -90,8 +86,8 @@ class KeyPrefix {
static const char* Decode(const char* start,
const char* limit,
KeyPrefix* result);
- std::vector<char> Encode() const;
- static std::vector<char> EncodeEmpty();
+ std::string Encode() const;
+ static std::string EncodeEmpty();
int Compare(const KeyPrefix& other) const;
enum Type {
@@ -149,9 +145,9 @@ class KeyPrefix {
static const int64 kInvalidId = -1;
private:
- static std::vector<char> EncodeInternal(int64 database_id,
- int64 object_store_id,
- int64 index_id);
+ static std::string EncodeInternal(int64 database_id,
+ int64 object_store_id,
+ int64 index_id);
// Special constructor for CreateWithSpecialIndex()
KeyPrefix(enum Type,
int64 database_id,
@@ -161,17 +157,17 @@ class KeyPrefix {
class SchemaVersionKey {
public:
- CONTENT_EXPORT static std::vector<char> Encode();
+ CONTENT_EXPORT static std::string Encode();
};
class MaxDatabaseIdKey {
public:
- CONTENT_EXPORT static std::vector<char> Encode();
+ CONTENT_EXPORT static std::string Encode();
};
class DataVersionKey {
public:
- static std::vector<char> Encode();
+ static std::string Encode();
};
class DatabaseFreeListKey {
@@ -180,8 +176,8 @@ class DatabaseFreeListKey {
static const char* Decode(const char* start,
const char* limit,
DatabaseFreeListKey* result);
- CONTENT_EXPORT static std::vector<char> Encode(int64 database_id);
- static CONTENT_EXPORT std::vector<char> EncodeMaxKey();
+ CONTENT_EXPORT static std::string Encode(int64 database_id);
+ static CONTENT_EXPORT std::string EncodeMaxKey();
int64 DatabaseId() const;
int Compare(const DatabaseFreeListKey& other) const;
@@ -194,12 +190,11 @@ class DatabaseNameKey {
static const char* Decode(const char* start,
const char* limit,
DatabaseNameKey* result);
- CONTENT_EXPORT static std::vector<char> Encode(
- const std::string& origin_identifier,
- const string16& database_name);
- static std::vector<char> EncodeMinKeyForOrigin(
+ CONTENT_EXPORT static std::string Encode(const std::string& origin_identifier,
+ const string16& database_name);
+ static std::string EncodeMinKeyForOrigin(
const std::string& origin_identifier);
- static std::vector<char> EncodeStopKeyForOrigin(
+ static std::string EncodeStopKeyForOrigin(
const std::string& origin_identifier);
string16 origin() const { return origin_; }
string16 database_name() const { return database_name_; }
@@ -221,8 +216,8 @@ class DatabaseMetaDataKey {
MAX_SIMPLE_METADATA_TYPE = 5
};
- CONTENT_EXPORT static std::vector<char> Encode(int64 database_id,
- MetaDataType type);
+ CONTENT_EXPORT static std::string Encode(int64 database_id,
+ MetaDataType type);
};
class ObjectStoreMetaDataKey {
@@ -242,12 +237,12 @@ class ObjectStoreMetaDataKey {
static const char* Decode(const char* start,
const char* limit,
ObjectStoreMetaDataKey* result);
- CONTENT_EXPORT static std::vector<char> Encode(int64 database_id,
- int64 object_store_id,
- unsigned char meta_data_type);
- CONTENT_EXPORT static std::vector<char> EncodeMaxKey(int64 database_id);
- CONTENT_EXPORT static std::vector<char> EncodeMaxKey(int64 database_id,
- int64 object_store_id);
+ CONTENT_EXPORT static std::string Encode(int64 database_id,
+ int64 object_store_id,
+ unsigned char meta_data_type);
+ CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id);
+ CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id,
+ int64 object_store_id);
int64 ObjectStoreId() const;
unsigned char MetaDataType() const;
int Compare(const ObjectStoreMetaDataKey& other);
@@ -270,15 +265,15 @@ class IndexMetaDataKey {
static const char* Decode(const char* start,
const char* limit,
IndexMetaDataKey* result);
- CONTENT_EXPORT static std::vector<char> Encode(int64 database_id,
+ CONTENT_EXPORT static std::string Encode(int64 database_id,
+ int64 object_store_id,
+ int64 index_id,
+ unsigned char meta_data_type);
+ CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id,
+ int64 object_store_id);
+ CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id,
int64 object_store_id,
- int64 index_id,
- unsigned char meta_data_type);
- CONTENT_EXPORT static std::vector<char> EncodeMaxKey(int64 database_id,
- int64 object_store_id);
- CONTENT_EXPORT static std::vector<char> EncodeMaxKey(int64 database_id,
- int64 object_store_id,
- int64 index_id);
+ int64 index_id);
int Compare(const IndexMetaDataKey& other);
int64 IndexId() const;
unsigned char meta_data_type() const { return meta_data_type_; }
@@ -295,9 +290,9 @@ class ObjectStoreFreeListKey {
static const char* Decode(const char* start,
const char* limit,
ObjectStoreFreeListKey* result);
- CONTENT_EXPORT static std::vector<char> Encode(int64 database_id,
- int64 object_store_id);
- CONTENT_EXPORT static std::vector<char> EncodeMaxKey(int64 database_id);
+ CONTENT_EXPORT static std::string Encode(int64 database_id,
+ int64 object_store_id);
+ CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id);
int64 ObjectStoreId() const;
int Compare(const ObjectStoreFreeListKey& other);
@@ -311,11 +306,11 @@ class IndexFreeListKey {
static const char* Decode(const char* start,
const char* limit,
IndexFreeListKey* result);
- CONTENT_EXPORT static std::vector<char> Encode(int64 database_id,
- int64 object_store_id,
- int64 index_id);
- CONTENT_EXPORT static std::vector<char> EncodeMaxKey(int64 database_id,
- int64 object_store_id);
+ CONTENT_EXPORT static std::string Encode(int64 database_id,
+ int64 object_store_id,
+ int64 index_id);
+ CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id,
+ int64 object_store_id);
int Compare(const IndexFreeListKey& other);
int64 ObjectStoreId() const;
int64 IndexId() const;
@@ -333,9 +328,8 @@ class ObjectStoreNamesKey {
static const char* Decode(const char* start,
const char* limit,
ObjectStoreNamesKey* result);
- CONTENT_EXPORT static std::vector<char> Encode(
- int64 database_id,
- const string16& object_store_name);
+ CONTENT_EXPORT static std::string Encode(int64 database_id,
+ const string16& object_store_name);
int Compare(const ObjectStoreNamesKey& other);
string16 object_store_name() const { return object_store_name_; }
@@ -352,9 +346,9 @@ class IndexNamesKey {
static const char* Decode(const char* start,
const char* limit,
IndexNamesKey* result);
- CONTENT_EXPORT static std::vector<char> Encode(int64 database_id,
- int64 object_store_id,
- const string16& index_name);
+ CONTENT_EXPORT static std::string Encode(int64 database_id,
+ int64 object_store_id,
+ const string16& index_name);
int Compare(const IndexNamesKey& other);
string16 index_name() const { return index_name_; }
@@ -368,13 +362,12 @@ class ObjectStoreDataKey {
static const char* Decode(const char* start,
const char* end,
ObjectStoreDataKey* result);
- CONTENT_EXPORT static std::vector<char> Encode(
- int64 database_id,
- int64 object_store_id,
- const std::vector<char> encoded_user_key);
- static std::vector<char> Encode(int64 database_id,
- int64 object_store_id,
- const IndexedDBKey& user_key);
+ CONTENT_EXPORT static std::string Encode(int64 database_id,
+ int64 object_store_id,
+ const std::string encoded_user_key);
+ static std::string Encode(int64 database_id,
+ int64 object_store_id,
+ const IndexedDBKey& user_key);
int Compare(const ObjectStoreDataKey& other, bool* ok);
scoped_ptr<IndexedDBKey> user_key() const;
static const int64 kSpecialIndexNumber;
@@ -382,7 +375,7 @@ class ObjectStoreDataKey {
~ObjectStoreDataKey();
private:
- std::vector<char> encoded_user_key_;
+ std::string encoded_user_key_;
};
class ExistsEntryKey {
@@ -393,20 +386,19 @@ class ExistsEntryKey {
static const char* Decode(const char* start,
const char* end,
ExistsEntryKey* result);
- CONTENT_EXPORT static std::vector<char> Encode(
- int64 database_id,
- int64 object_store_id,
- const std::vector<char>& encoded_key);
- static std::vector<char> Encode(int64 database_id,
- int64 object_store_id,
- const IndexedDBKey& user_key);
+ CONTENT_EXPORT static std::string Encode(int64 database_id,
+ int64 object_store_id,
+ const std::string& encoded_key);
+ static std::string Encode(int64 database_id,
+ int64 object_store_id,
+ const IndexedDBKey& user_key);
int Compare(const ExistsEntryKey& other, bool* ok);
scoped_ptr<IndexedDBKey> user_key() const;
static const int64 kSpecialIndexNumber;
private:
- std::vector<char> encoded_user_key_;
+ std::string encoded_user_key_;
DISALLOW_COPY_AND_ASSIGN(ExistsEntryKey);
};
@@ -417,23 +409,23 @@ class IndexDataKey {
static const char* Decode(const char* start,
const char* limit,
IndexDataKey* result);
- CONTENT_EXPORT static std::vector<char> Encode(
+ CONTENT_EXPORT static std::string Encode(
int64 database_id,
int64 object_store_id,
int64 index_id,
- const std::vector<char>& encoded_user_key,
- const std::vector<char>& encoded_primary_key,
+ const std::string& encoded_user_key,
+ const std::string& encoded_primary_key,
int64 sequence_number);
- static std::vector<char> Encode(int64 database_id,
+ static std::string Encode(int64 database_id,
+ int64 object_store_id,
+ int64 index_id,
+ const IndexedDBKey& user_key);
+ static std::string EncodeMinKey(int64 database_id,
int64 object_store_id,
- int64 index_id,
- const IndexedDBKey& user_key);
- static std::vector<char> EncodeMinKey(int64 database_id,
- int64 object_store_id,
- int64 index_id);
- CONTENT_EXPORT static std::vector<char> EncodeMaxKey(int64 database_id,
- int64 object_store_id,
- int64 index_id);
+ int64 index_id);
+ CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id,
+ int64 object_store_id,
+ int64 index_id);
int Compare(const IndexDataKey& other, bool ignore_duplicates, bool* ok);
int64 DatabaseId() const;
int64 ObjectStoreId() const;
@@ -445,8 +437,8 @@ class IndexDataKey {
int64 database_id_;
int64 object_store_id_;
int64 index_id_;
- std::vector<char> encoded_user_key_;
- std::vector<char> encoded_primary_key_;
+ std::string encoded_user_key_;
+ std::string encoded_primary_key_;
int64 sequence_number_;
DISALLOW_COPY_AND_ASSIGN(IndexDataKey);
« no previous file with comments | « content/browser/indexed_db/indexed_db_fake_backing_store.cc ('k') | content/browser/indexed_db/indexed_db_leveldb_coding.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698