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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
15 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
16 #include "content/common/indexed_db/indexed_db_key.h" | 16 #include "content/common/indexed_db/indexed_db_key.h" |
17 #include "content/common/indexed_db/indexed_db_key_path.h" | 17 #include "content/common/indexed_db/indexed_db_key_path.h" |
18 | 18 |
19 namespace content { | 19 namespace content { |
20 | 20 |
21 CONTENT_EXPORT extern const unsigned char kMinimumIndexId; | 21 CONTENT_EXPORT extern const unsigned char kMinimumIndexId; |
22 | 22 |
23 CONTENT_EXPORT std::string MaxIDBKey(); | 23 CONTENT_EXPORT std::string MaxIDBKey(); |
24 CONTENT_EXPORT std::string MinIDBKey(); | 24 CONTENT_EXPORT std::string MinIDBKey(); |
25 | 25 |
| 26 // DatabaseId, BlobKey |
| 27 typedef std::pair<int64_t, int64_t> BlobJournalEntryType; |
| 28 typedef std::vector<BlobJournalEntryType> BlobJournalType; |
| 29 |
26 CONTENT_EXPORT void EncodeByte(unsigned char value, std::string* into); | 30 CONTENT_EXPORT void EncodeByte(unsigned char value, std::string* into); |
27 CONTENT_EXPORT void EncodeBool(bool value, std::string* into); | 31 CONTENT_EXPORT void EncodeBool(bool value, std::string* into); |
28 CONTENT_EXPORT void EncodeInt(int64 value, std::string* into); | 32 CONTENT_EXPORT void EncodeInt(int64 value, std::string* into); |
29 CONTENT_EXPORT void EncodeVarInt(int64 value, std::string* into); | 33 CONTENT_EXPORT void EncodeVarInt(int64 value, std::string* into); |
30 CONTENT_EXPORT void EncodeString(const base::string16& value, | 34 CONTENT_EXPORT void EncodeString(const base::string16& value, |
31 std::string* into); | 35 std::string* into); |
32 CONTENT_EXPORT void EncodeStringWithLength(const base::string16& value, | 36 CONTENT_EXPORT void EncodeStringWithLength(const base::string16& value, |
33 std::string* into); | 37 std::string* into); |
34 CONTENT_EXPORT void EncodeBinary(const std::string& value, std::string* into); | 38 CONTENT_EXPORT void EncodeBinary(const std::string& value, std::string* into); |
35 CONTENT_EXPORT void EncodeDouble(double value, std::string* into); | 39 CONTENT_EXPORT void EncodeDouble(double value, std::string* into); |
36 CONTENT_EXPORT void EncodeIDBKey(const IndexedDBKey& value, std::string* into); | 40 CONTENT_EXPORT void EncodeIDBKey(const IndexedDBKey& value, std::string* into); |
37 CONTENT_EXPORT void EncodeIDBKeyPath(const IndexedDBKeyPath& value, | 41 CONTENT_EXPORT void EncodeIDBKeyPath(const IndexedDBKeyPath& value, |
38 std::string* into); | 42 std::string* into); |
| 43 CONTENT_EXPORT void EncodeBlobJournal(const BlobJournalType& journal, |
| 44 std::string* into); |
39 | 45 |
40 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeByte(base::StringPiece* slice, | 46 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeByte(base::StringPiece* slice, |
41 unsigned char* value); | 47 unsigned char* value); |
42 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeBool(base::StringPiece* slice, | 48 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeBool(base::StringPiece* slice, |
43 bool* value); | 49 bool* value); |
44 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeInt(base::StringPiece* slice, | 50 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeInt(base::StringPiece* slice, |
45 int64* value); | 51 int64* value); |
46 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeVarInt(base::StringPiece* slice, | 52 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeVarInt(base::StringPiece* slice, |
47 int64* value); | 53 int64* value); |
48 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeString(base::StringPiece* slice, | 54 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeString(base::StringPiece* slice, |
49 base::string16* value); | 55 base::string16* value); |
50 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeStringWithLength( | 56 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeStringWithLength( |
51 base::StringPiece* slice, | 57 base::StringPiece* slice, |
52 base::string16* value); | 58 base::string16* value); |
53 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeBinary(base::StringPiece* slice, | 59 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeBinary(base::StringPiece* slice, |
54 std::string* value); | 60 std::string* value); |
55 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeDouble(base::StringPiece* slice, | 61 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeDouble(base::StringPiece* slice, |
56 double* value); | 62 double* value); |
57 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeIDBKey( | 63 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeIDBKey( |
58 base::StringPiece* slice, | 64 base::StringPiece* slice, |
59 scoped_ptr<IndexedDBKey>* value); | 65 scoped_ptr<IndexedDBKey>* value); |
60 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeIDBKeyPath( | 66 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeIDBKeyPath( |
61 base::StringPiece* slice, | 67 base::StringPiece* slice, |
62 IndexedDBKeyPath* value); | 68 IndexedDBKeyPath* value); |
| 69 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeBlobJournal( |
| 70 base::StringPiece* slice, |
| 71 BlobJournalType* journal); |
63 | 72 |
64 CONTENT_EXPORT int CompareEncodedStringsWithLength(base::StringPiece* slice1, | 73 CONTENT_EXPORT int CompareEncodedStringsWithLength(base::StringPiece* slice1, |
65 base::StringPiece* slice2, | 74 base::StringPiece* slice2, |
66 bool* ok); | 75 bool* ok); |
67 | 76 |
68 CONTENT_EXPORT WARN_UNUSED_RESULT bool ExtractEncodedIDBKey( | 77 CONTENT_EXPORT WARN_UNUSED_RESULT bool ExtractEncodedIDBKey( |
69 base::StringPiece* slice, | 78 base::StringPiece* slice, |
70 std::string* result); | 79 std::string* result); |
71 | 80 |
72 CONTENT_EXPORT int CompareEncodedIDBKeys(base::StringPiece* slice1, | 81 CONTENT_EXPORT int CompareEncodedIDBKeys(base::StringPiece* slice1, |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 enum MetaDataType { | 231 enum MetaDataType { |
223 ORIGIN_NAME = 0, | 232 ORIGIN_NAME = 0, |
224 DATABASE_NAME = 1, | 233 DATABASE_NAME = 1, |
225 USER_VERSION = 2, | 234 USER_VERSION = 2, |
226 MAX_OBJECT_STORE_ID = 3, | 235 MAX_OBJECT_STORE_ID = 3, |
227 USER_INT_VERSION = 4, | 236 USER_INT_VERSION = 4, |
228 BLOB_KEY_GENERATOR_CURRENT_NUMBER = 5, | 237 BLOB_KEY_GENERATOR_CURRENT_NUMBER = 5, |
229 MAX_SIMPLE_METADATA_TYPE = 6 | 238 MAX_SIMPLE_METADATA_TYPE = 6 |
230 }; | 239 }; |
231 | 240 |
232 static const int64 kAllBlobsKey; | 241 CONTENT_EXPORT static const int64 kAllBlobsKey; |
233 static const int64 kBlobKeyGeneratorInitialNumber; | 242 static const int64 kBlobKeyGeneratorInitialNumber; |
234 // All keys <= 0 are invalid. This one's just a convenient example. | 243 // All keys <= 0 are invalid. This one's just a convenient example. |
235 static const int64 kInvalidBlobKey; | 244 static const int64 kInvalidBlobKey; |
236 | 245 |
237 static bool IsValidBlobKey(int64 blobKey); | 246 static bool IsValidBlobKey(int64 blobKey); |
238 CONTENT_EXPORT static std::string Encode(int64 database_id, | 247 CONTENT_EXPORT static std::string Encode(int64 database_id, |
239 MetaDataType type); | 248 MetaDataType type); |
240 }; | 249 }; |
241 | 250 |
242 class ObjectStoreMetaDataKey { | 251 class ObjectStoreMetaDataKey { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 std::string encoded_user_key_; | 483 std::string encoded_user_key_; |
475 std::string encoded_primary_key_; | 484 std::string encoded_primary_key_; |
476 int64 sequence_number_; | 485 int64 sequence_number_; |
477 | 486 |
478 DISALLOW_COPY_AND_ASSIGN(IndexDataKey); | 487 DISALLOW_COPY_AND_ASSIGN(IndexDataKey); |
479 }; | 488 }; |
480 | 489 |
481 } // namespace content | 490 } // namespace content |
482 | 491 |
483 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_ | 492 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_ |
OLD | NEW |