OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 static bool Decode(base::StringPiece* slice, KeyPrefix* result); | 89 static bool Decode(base::StringPiece* slice, KeyPrefix* result); |
90 std::string Encode() const; | 90 std::string Encode() const; |
91 static std::string EncodeEmpty(); | 91 static std::string EncodeEmpty(); |
92 int Compare(const KeyPrefix& other) const; | 92 int Compare(const KeyPrefix& other) const; |
93 | 93 |
94 enum Type { | 94 enum Type { |
95 GLOBAL_METADATA, | 95 GLOBAL_METADATA, |
96 DATABASE_METADATA, | 96 DATABASE_METADATA, |
97 OBJECT_STORE_DATA, | 97 OBJECT_STORE_DATA, |
98 EXISTS_ENTRY, | 98 EXISTS_ENTRY, |
99 BLOB_ENTRY, | |
jsbell
2013/12/20 00:44:20
Needs to be appended, since these are serialized -
ericu
2014/02/20 00:50:29
Done.
| |
99 INDEX_DATA, | 100 INDEX_DATA, |
100 INVALID_TYPE | 101 INVALID_TYPE |
101 }; | 102 }; |
102 | 103 |
103 static const size_t kMaxDatabaseIdSizeBits = 3; | 104 static const size_t kMaxDatabaseIdSizeBits = 3; |
104 static const size_t kMaxObjectStoreIdSizeBits = 3; | 105 static const size_t kMaxObjectStoreIdSizeBits = 3; |
105 static const size_t kMaxIndexIdSizeBits = 2; | 106 static const size_t kMaxIndexIdSizeBits = 2; |
106 | 107 |
107 static const size_t kMaxDatabaseIdSizeBytes = | 108 static const size_t kMaxDatabaseIdSizeBytes = |
108 1ULL << kMaxDatabaseIdSizeBits; // 8 | 109 1ULL << kMaxDatabaseIdSizeBits; // 8 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
164 class MaxDatabaseIdKey { | 165 class MaxDatabaseIdKey { |
165 public: | 166 public: |
166 CONTENT_EXPORT static std::string Encode(); | 167 CONTENT_EXPORT static std::string Encode(); |
167 }; | 168 }; |
168 | 169 |
169 class DataVersionKey { | 170 class DataVersionKey { |
170 public: | 171 public: |
171 static std::string Encode(); | 172 static std::string Encode(); |
172 }; | 173 }; |
173 | 174 |
175 class BlobJournalKey { | |
176 public: | |
177 static std::string Encode(); | |
178 }; | |
179 | |
180 class LiveBlobJournalKey { | |
181 public: | |
182 static std::string Encode(); | |
183 }; | |
184 | |
174 class DatabaseFreeListKey { | 185 class DatabaseFreeListKey { |
175 public: | 186 public: |
176 DatabaseFreeListKey(); | 187 DatabaseFreeListKey(); |
177 static bool Decode(base::StringPiece* slice, DatabaseFreeListKey* result); | 188 static bool Decode(base::StringPiece* slice, DatabaseFreeListKey* result); |
178 CONTENT_EXPORT static std::string Encode(int64 database_id); | 189 CONTENT_EXPORT static std::string Encode(int64 database_id); |
179 static CONTENT_EXPORT std::string EncodeMaxKey(); | 190 static CONTENT_EXPORT std::string EncodeMaxKey(); |
180 int64 DatabaseId() const; | 191 int64 DatabaseId() const; |
181 int Compare(const DatabaseFreeListKey& other) const; | 192 int Compare(const DatabaseFreeListKey& other) const; |
182 | 193 |
183 private: | 194 private: |
(...skipping 19 matching lines...) Expand all Loading... | |
203 }; | 214 }; |
204 | 215 |
205 class DatabaseMetaDataKey { | 216 class DatabaseMetaDataKey { |
206 public: | 217 public: |
207 enum MetaDataType { | 218 enum MetaDataType { |
208 ORIGIN_NAME = 0, | 219 ORIGIN_NAME = 0, |
209 DATABASE_NAME = 1, | 220 DATABASE_NAME = 1, |
210 USER_VERSION = 2, | 221 USER_VERSION = 2, |
211 MAX_OBJECT_STORE_ID = 3, | 222 MAX_OBJECT_STORE_ID = 3, |
212 USER_INT_VERSION = 4, | 223 USER_INT_VERSION = 4, |
213 MAX_SIMPLE_METADATA_TYPE = 5 | 224 BLOB_KEY_GENERATOR_CURRENT_NUMBER = 5, |
225 MAX_SIMPLE_METADATA_TYPE = 6 | |
214 }; | 226 }; |
215 | 227 |
228 static const int64 kAllBlobsKey = 1; | |
229 static const int64 kBlobKeyGeneratorInitialNumber = 2; | |
230 static const int64 kInvalidBlobKey = -1; // All keys <= 0 are invalid. | |
231 | |
232 static bool IsValidBlobKey(int64 blobKey); | |
216 CONTENT_EXPORT static std::string Encode(int64 database_id, | 233 CONTENT_EXPORT static std::string Encode(int64 database_id, |
217 MetaDataType type); | 234 MetaDataType type); |
218 }; | 235 }; |
219 | 236 |
220 class ObjectStoreMetaDataKey { | 237 class ObjectStoreMetaDataKey { |
221 public: | 238 public: |
222 enum MetaDataType { | 239 enum MetaDataType { |
223 NAME = 0, | 240 NAME = 0, |
224 KEY_PATH = 1, | 241 KEY_PATH = 1, |
225 AUTO_INCREMENT = 2, | 242 AUTO_INCREMENT = 2, |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
376 int Compare(const ExistsEntryKey& other, bool* ok); | 393 int Compare(const ExistsEntryKey& other, bool* ok); |
377 scoped_ptr<IndexedDBKey> user_key() const; | 394 scoped_ptr<IndexedDBKey> user_key() const; |
378 | 395 |
379 static const int64 kSpecialIndexNumber; | 396 static const int64 kSpecialIndexNumber; |
380 | 397 |
381 private: | 398 private: |
382 std::string encoded_user_key_; | 399 std::string encoded_user_key_; |
383 DISALLOW_COPY_AND_ASSIGN(ExistsEntryKey); | 400 DISALLOW_COPY_AND_ASSIGN(ExistsEntryKey); |
384 }; | 401 }; |
385 | 402 |
403 class BlobEntryKey { | |
404 public: | |
405 BlobEntryKey() : database_id_(0), object_store_id_(0) {} | |
406 static bool Decode(base::StringPiece* slice, BlobEntryKey* result); | |
407 static bool FromObjectStoreDataKey(base::StringPiece* slice, | |
408 BlobEntryKey* result); | |
409 static std::string ReencodeToObjectStoreDataKey(base::StringPiece* slice); | |
410 static std::string EncodeMinForObjectStore(int64 database_id, | |
411 int64 object_store_id); | |
412 static std::string EncodeMaxForObjectStore(int64 database_id, | |
413 int64 object_store_id); | |
414 static std::string Encode(int64 database_id, | |
415 int64 object_store_id, | |
416 const IndexedDBKey& user_key); | |
417 std::string Encode() const; | |
418 int64 database_id() const { return database_id_; } | |
419 int64 object_store_id() const { return object_store_id_; } | |
420 int Compare(const BlobEntryKey& other, bool* ok); | |
421 | |
422 static const int64 kSpecialIndexNumber; | |
423 | |
424 private: | |
425 static std::string Encode(int64 database_id, | |
426 int64 object_store_id, | |
427 const std::string& encoded_user_key); | |
428 int64 database_id_; | |
429 int64 object_store_id_; | |
430 // This is the user's ObjectStoreDataKey, not the BlobEntryKey itself. | |
431 std::string encoded_user_key_; | |
432 }; | |
433 | |
386 class IndexDataKey { | 434 class IndexDataKey { |
387 public: | 435 public: |
388 IndexDataKey(); | 436 IndexDataKey(); |
389 ~IndexDataKey(); | 437 ~IndexDataKey(); |
390 static bool Decode(base::StringPiece* slice, IndexDataKey* result); | 438 static bool Decode(base::StringPiece* slice, IndexDataKey* result); |
391 CONTENT_EXPORT static std::string Encode( | 439 CONTENT_EXPORT static std::string Encode( |
392 int64 database_id, | 440 int64 database_id, |
393 int64 object_store_id, | 441 int64 object_store_id, |
394 int64 index_id, | 442 int64 index_id, |
395 const std::string& encoded_user_key, | 443 const std::string& encoded_user_key, |
(...skipping 30 matching lines...) Expand all Loading... | |
426 std::string encoded_user_key_; | 474 std::string encoded_user_key_; |
427 std::string encoded_primary_key_; | 475 std::string encoded_primary_key_; |
428 int64 sequence_number_; | 476 int64 sequence_number_; |
429 | 477 |
430 DISALLOW_COPY_AND_ASSIGN(IndexDataKey); | 478 DISALLOW_COPY_AND_ASSIGN(IndexDataKey); |
431 }; | 479 }; |
432 | 480 |
433 } // namespace content | 481 } // namespace content |
434 | 482 |
435 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_ | 483 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_ |
OLD | NEW |