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

Side by Side Diff: content/browser/indexed_db/indexed_db_leveldb_coding.h

Issue 18023022: Blob support for IDB [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge fixes [builds, untested] Created 7 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 static bool Decode(base::StringPiece* slice, KeyPrefix* result); 86 static bool Decode(base::StringPiece* slice, KeyPrefix* result);
87 std::string Encode() const; 87 std::string Encode() const;
88 static std::string EncodeEmpty(); 88 static std::string EncodeEmpty();
89 int Compare(const KeyPrefix& other) const; 89 int Compare(const KeyPrefix& other) const;
90 90
91 enum Type { 91 enum Type {
92 GLOBAL_METADATA, 92 GLOBAL_METADATA,
93 DATABASE_METADATA, 93 DATABASE_METADATA,
94 OBJECT_STORE_DATA, 94 OBJECT_STORE_DATA,
95 EXISTS_ENTRY, 95 EXISTS_ENTRY,
96 BLOB_ENTRY,
96 INDEX_DATA, 97 INDEX_DATA,
97 INVALID_TYPE 98 INVALID_TYPE
98 }; 99 };
99 100
100 static const size_t kMaxDatabaseIdSizeBits = 3; 101 static const size_t kMaxDatabaseIdSizeBits = 3;
101 static const size_t kMaxObjectStoreIdSizeBits = 3; 102 static const size_t kMaxObjectStoreIdSizeBits = 3;
102 static const size_t kMaxIndexIdSizeBits = 2; 103 static const size_t kMaxIndexIdSizeBits = 2;
103 104
104 static const size_t kMaxDatabaseIdSizeBytes = 105 static const size_t kMaxDatabaseIdSizeBytes =
105 1ULL << kMaxDatabaseIdSizeBits; // 8 106 1ULL << kMaxDatabaseIdSizeBits; // 8
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 class MaxDatabaseIdKey { 162 class MaxDatabaseIdKey {
162 public: 163 public:
163 CONTENT_EXPORT static std::string Encode(); 164 CONTENT_EXPORT static std::string Encode();
164 }; 165 };
165 166
166 class DataVersionKey { 167 class DataVersionKey {
167 public: 168 public:
168 static std::string Encode(); 169 static std::string Encode();
169 }; 170 };
170 171
172 class BlobJournalKey {
173 public:
174 static std::string Encode();
175 };
176
177 class LiveBlobJournalKey {
178 public:
179 static std::string Encode();
180 };
181
171 class DatabaseFreeListKey { 182 class DatabaseFreeListKey {
172 public: 183 public:
173 DatabaseFreeListKey(); 184 DatabaseFreeListKey();
174 static bool Decode(base::StringPiece* slice, DatabaseFreeListKey* result); 185 static bool Decode(base::StringPiece* slice, DatabaseFreeListKey* result);
175 CONTENT_EXPORT static std::string Encode(int64 database_id); 186 CONTENT_EXPORT static std::string Encode(int64 database_id);
176 static CONTENT_EXPORT std::string EncodeMaxKey(); 187 static CONTENT_EXPORT std::string EncodeMaxKey();
177 int64 DatabaseId() const; 188 int64 DatabaseId() const;
178 int Compare(const DatabaseFreeListKey& other) const; 189 int Compare(const DatabaseFreeListKey& other) const;
179 190
180 private: 191 private:
(...skipping 19 matching lines...) Expand all
200 }; 211 };
201 212
202 class DatabaseMetaDataKey { 213 class DatabaseMetaDataKey {
203 public: 214 public:
204 enum MetaDataType { 215 enum MetaDataType {
205 ORIGIN_NAME = 0, 216 ORIGIN_NAME = 0,
206 DATABASE_NAME = 1, 217 DATABASE_NAME = 1,
207 USER_VERSION = 2, 218 USER_VERSION = 2,
208 MAX_OBJECT_STORE_ID = 3, 219 MAX_OBJECT_STORE_ID = 3,
209 USER_INT_VERSION = 4, 220 USER_INT_VERSION = 4,
210 MAX_SIMPLE_METADATA_TYPE = 5 221 BLOB_KEY_GENERATOR_CURRENT_NUMBER = 5,
222 MAX_SIMPLE_METADATA_TYPE = 6
211 }; 223 };
212 224
225 static const int64 kAllBlobsKey = 1;
226 static const int64 kBlobKeyGeneratorInitialNumber = 2;
227 static const int64 kInvalidBlobKey = -1; // All keys <= 0 are invalid.
228
229 static bool IsValidBlobKey(int64 blobKey);
213 CONTENT_EXPORT static std::string Encode(int64 database_id, 230 CONTENT_EXPORT static std::string Encode(int64 database_id,
214 MetaDataType type); 231 MetaDataType type);
215 }; 232 };
216 233
217 class ObjectStoreMetaDataKey { 234 class ObjectStoreMetaDataKey {
218 public: 235 public:
219 enum MetaDataType { 236 enum MetaDataType {
220 NAME = 0, 237 NAME = 0,
221 KEY_PATH = 1, 238 KEY_PATH = 1,
222 AUTO_INCREMENT = 2, 239 AUTO_INCREMENT = 2,
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 int Compare(const ExistsEntryKey& other, bool* ok); 390 int Compare(const ExistsEntryKey& other, bool* ok);
374 scoped_ptr<IndexedDBKey> user_key() const; 391 scoped_ptr<IndexedDBKey> user_key() const;
375 392
376 static const int64 kSpecialIndexNumber; 393 static const int64 kSpecialIndexNumber;
377 394
378 private: 395 private:
379 std::string encoded_user_key_; 396 std::string encoded_user_key_;
380 DISALLOW_COPY_AND_ASSIGN(ExistsEntryKey); 397 DISALLOW_COPY_AND_ASSIGN(ExistsEntryKey);
381 }; 398 };
382 399
400 class BlobEntryKey {
401 public:
402 BlobEntryKey()
403 : database_id_(0),
404 object_store_id_(0)
405 {
406 }
407 static bool Decode(base::StringPiece* slice, BlobEntryKey* result);
408 static bool FromObjectStoreDataKey(base::StringPiece* slice,
409 BlobEntryKey* result);
410 static std::string EncodeToObjectStoreDataKey(base::StringPiece* slice);
411 static std::string EncodeMinForObjectStore(int64 database_id,
412 int64 object_store_id);
413 static std::string EncodeMaxForObjectStore(int64 database_id,
414 int64 object_store_id);
415 static std::string Encode(int64 database_id,
416 int64 object_store_id,
417 const IndexedDBKey& user_key);
418 std::string Encode() const;
419 int64 database_id() const { return database_id_; }
420 int64 object_store_id() const { return object_store_id_; }
421 int Compare(const BlobEntryKey& other, bool* ok);
422
423 static const int64 kSpecialIndexNumber;
424
425 private:
426 static std::string Encode(int64 database_id,
427 int64 object_store_id,
428 const std::string& encoded_user_key);
429 int64 database_id_;
430 int64 object_store_id_;
431 // This is the user's ObjectStoreDataKey, not the BlobEntryKey itself.
432 std::string encoded_user_key_;
433 };
434
383 class IndexDataKey { 435 class IndexDataKey {
384 public: 436 public:
385 IndexDataKey(); 437 IndexDataKey();
386 ~IndexDataKey(); 438 ~IndexDataKey();
387 static bool Decode(base::StringPiece* slice, IndexDataKey* result); 439 static bool Decode(base::StringPiece* slice, IndexDataKey* result);
388 CONTENT_EXPORT static std::string Encode( 440 CONTENT_EXPORT static std::string Encode(
389 int64 database_id, 441 int64 database_id,
390 int64 object_store_id, 442 int64 object_store_id,
391 int64 index_id, 443 int64 index_id,
392 const std::string& encoded_user_key, 444 const std::string& encoded_user_key,
(...skipping 25 matching lines...) Expand all
418 std::string encoded_user_key_; 470 std::string encoded_user_key_;
419 std::string encoded_primary_key_; 471 std::string encoded_primary_key_;
420 int64 sequence_number_; 472 int64 sequence_number_;
421 473
422 DISALLOW_COPY_AND_ASSIGN(IndexDataKey); 474 DISALLOW_COPY_AND_ASSIGN(IndexDataKey);
423 }; 475 };
424 476
425 } // namespace content 477 } // namespace content
426 478
427 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_ 479 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698