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

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

Issue 475063004: IndexedDB + Coding Style: re-order enums/typedefs/... to match guide (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Restore CONTENT_EXPORT to Transaction Created 6 years, 4 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 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 CONTENT_EXPORT int CompareEncodedIDBKeys(base::StringPiece* slice1, 83 CONTENT_EXPORT int CompareEncodedIDBKeys(base::StringPiece* slice1,
84 base::StringPiece* slice2, 84 base::StringPiece* slice2,
85 bool* ok); 85 bool* ok);
86 86
87 CONTENT_EXPORT int Compare(const base::StringPiece& a, 87 CONTENT_EXPORT int Compare(const base::StringPiece& a,
88 const base::StringPiece& b, 88 const base::StringPiece& b,
89 bool index_keys); 89 bool index_keys);
90 90
91 class KeyPrefix { 91 class KeyPrefix {
92 public: 92 public:
93 KeyPrefix();
94 explicit KeyPrefix(int64 database_id);
95 KeyPrefix(int64 database_id, int64 object_store_id);
96 KeyPrefix(int64 database_id, int64 object_store_id, int64 index_id);
97 static KeyPrefix CreateWithSpecialIndex(int64 database_id,
98 int64 object_store_id,
99 int64 index_id);
100
101 static bool Decode(base::StringPiece* slice, KeyPrefix* result);
102 std::string Encode() const;
103 static std::string EncodeEmpty();
104 int Compare(const KeyPrefix& other) const;
105
106 // These are serialized to disk; any new items must be appended, and none can 93 // These are serialized to disk; any new items must be appended, and none can
107 // be deleted. 94 // be deleted.
108 enum Type { 95 enum Type {
109 GLOBAL_METADATA, 96 GLOBAL_METADATA,
110 DATABASE_METADATA, 97 DATABASE_METADATA,
111 OBJECT_STORE_DATA, 98 OBJECT_STORE_DATA,
112 EXISTS_ENTRY, 99 EXISTS_ENTRY,
113 INDEX_DATA, 100 INDEX_DATA,
114 INVALID_TYPE, 101 INVALID_TYPE,
115 BLOB_ENTRY 102 BLOB_ENTRY
(...skipping 15 matching lines...) Expand all
131 kMaxObjectStoreIdSizeBytes * 8 - 1; // 63 118 kMaxObjectStoreIdSizeBytes * 8 - 1; // 63
132 static const size_t kMaxIndexIdBits = kMaxIndexIdSizeBytes * 8 - 1; // 31 119 static const size_t kMaxIndexIdBits = kMaxIndexIdSizeBytes * 8 - 1; // 31
133 120
134 static const int64 kMaxDatabaseId = 121 static const int64 kMaxDatabaseId =
135 (1ULL << kMaxDatabaseIdBits) - 1; // max signed int64 122 (1ULL << kMaxDatabaseIdBits) - 1; // max signed int64
136 static const int64 kMaxObjectStoreId = 123 static const int64 kMaxObjectStoreId =
137 (1ULL << kMaxObjectStoreIdBits) - 1; // max signed int64 124 (1ULL << kMaxObjectStoreIdBits) - 1; // max signed int64
138 static const int64 kMaxIndexId = 125 static const int64 kMaxIndexId =
139 (1ULL << kMaxIndexIdBits) - 1; // max signed int32 126 (1ULL << kMaxIndexIdBits) - 1; // max signed int32
140 127
128 static const int64 kInvalidId = -1;
129
130 KeyPrefix();
131 explicit KeyPrefix(int64 database_id);
132 KeyPrefix(int64 database_id, int64 object_store_id);
133 KeyPrefix(int64 database_id, int64 object_store_id, int64 index_id);
134 static KeyPrefix CreateWithSpecialIndex(int64 database_id,
135 int64 object_store_id,
136 int64 index_id);
137
138 static bool Decode(base::StringPiece* slice, KeyPrefix* result);
139 std::string Encode() const;
140 static std::string EncodeEmpty();
141 int Compare(const KeyPrefix& other) const;
142
141 CONTENT_EXPORT static bool IsValidDatabaseId(int64 database_id); 143 CONTENT_EXPORT static bool IsValidDatabaseId(int64 database_id);
142 static bool IsValidObjectStoreId(int64 index_id); 144 static bool IsValidObjectStoreId(int64 index_id);
143 static bool IsValidIndexId(int64 index_id); 145 static bool IsValidIndexId(int64 index_id);
144 static bool ValidIds(int64 database_id, 146 static bool ValidIds(int64 database_id,
145 int64 object_store_id, 147 int64 object_store_id,
146 int64 index_id) { 148 int64 index_id) {
147 return IsValidDatabaseId(database_id) && 149 return IsValidDatabaseId(database_id) &&
148 IsValidObjectStoreId(object_store_id) && IsValidIndexId(index_id); 150 IsValidObjectStoreId(object_store_id) && IsValidIndexId(index_id);
149 } 151 }
150 static bool ValidIds(int64 database_id, int64 object_store_id) { 152 static bool ValidIds(int64 database_id, int64 object_store_id) {
151 return IsValidDatabaseId(database_id) && 153 return IsValidDatabaseId(database_id) &&
152 IsValidObjectStoreId(object_store_id); 154 IsValidObjectStoreId(object_store_id);
153 } 155 }
154 156
155 Type type() const; 157 Type type() const;
156 158
157 int64 database_id_; 159 int64 database_id_;
158 int64 object_store_id_; 160 int64 object_store_id_;
159 int64 index_id_; 161 int64 index_id_;
160 162
161 static const int64 kInvalidId = -1;
162
163 private: 163 private:
164 static std::string EncodeInternal(int64 database_id,
165 int64 object_store_id,
166 int64 index_id);
167 // Special constructor for CreateWithSpecialIndex() 164 // Special constructor for CreateWithSpecialIndex()
168 KeyPrefix(enum Type, 165 KeyPrefix(enum Type,
169 int64 database_id, 166 int64 database_id,
170 int64 object_store_id, 167 int64 object_store_id,
171 int64 index_id); 168 int64 index_id);
169
170 static std::string EncodeInternal(int64 database_id,
171 int64 object_store_id,
172 int64 index_id);
172 }; 173 };
173 174
174 class SchemaVersionKey { 175 class SchemaVersionKey {
175 public: 176 public:
176 CONTENT_EXPORT static std::string Encode(); 177 CONTENT_EXPORT static std::string Encode();
177 }; 178 };
178 179
179 class MaxDatabaseIdKey { 180 class MaxDatabaseIdKey {
180 public: 181 public:
181 CONTENT_EXPORT static std::string Encode(); 182 CONTENT_EXPORT static std::string Encode();
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 int Compare(const IndexNamesKey& other); 372 int Compare(const IndexNamesKey& other);
372 base::string16 index_name() const { return index_name_; } 373 base::string16 index_name() const { return index_name_; }
373 374
374 private: 375 private:
375 int64 object_store_id_; 376 int64 object_store_id_;
376 base::string16 index_name_; 377 base::string16 index_name_;
377 }; 378 };
378 379
379 class ObjectStoreDataKey { 380 class ObjectStoreDataKey {
380 public: 381 public:
382 static const int64 kSpecialIndexNumber;
383
384 ObjectStoreDataKey();
385 ~ObjectStoreDataKey();
386
381 static bool Decode(base::StringPiece* slice, ObjectStoreDataKey* result); 387 static bool Decode(base::StringPiece* slice, ObjectStoreDataKey* result);
382 CONTENT_EXPORT static std::string Encode(int64 database_id, 388 CONTENT_EXPORT static std::string Encode(int64 database_id,
383 int64 object_store_id, 389 int64 object_store_id,
384 const std::string encoded_user_key); 390 const std::string encoded_user_key);
385 static std::string Encode(int64 database_id, 391 static std::string Encode(int64 database_id,
386 int64 object_store_id, 392 int64 object_store_id,
387 const IndexedDBKey& user_key); 393 const IndexedDBKey& user_key);
388 scoped_ptr<IndexedDBKey> user_key() const; 394 scoped_ptr<IndexedDBKey> user_key() const;
389 static const int64 kSpecialIndexNumber;
390 ObjectStoreDataKey();
391 ~ObjectStoreDataKey();
392
393 private: 395 private:
394 std::string encoded_user_key_; 396 std::string encoded_user_key_;
395 }; 397 };
396 398
397 class ExistsEntryKey { 399 class ExistsEntryKey {
398 public: 400 public:
401 static const int64 kSpecialIndexNumber;
cmumford 2014/08/20 19:43:05 Unrelated to your change, but can be private? Same
jsbell 2014/08/22 20:50:01 Compiler says... 2/3 can be made private, another
402
399 ExistsEntryKey(); 403 ExistsEntryKey();
400 ~ExistsEntryKey(); 404 ~ExistsEntryKey();
401 405
402 static bool Decode(base::StringPiece* slice, ExistsEntryKey* result); 406 static bool Decode(base::StringPiece* slice, ExistsEntryKey* result);
403 CONTENT_EXPORT static std::string Encode(int64 database_id, 407 CONTENT_EXPORT static std::string Encode(int64 database_id,
404 int64 object_store_id, 408 int64 object_store_id,
405 const std::string& encoded_key); 409 const std::string& encoded_key);
406 static std::string Encode(int64 database_id, 410 static std::string Encode(int64 database_id,
407 int64 object_store_id, 411 int64 object_store_id,
408 const IndexedDBKey& user_key); 412 const IndexedDBKey& user_key);
409 scoped_ptr<IndexedDBKey> user_key() const; 413 scoped_ptr<IndexedDBKey> user_key() const;
410 414
411 static const int64 kSpecialIndexNumber;
412
413 private: 415 private:
414 std::string encoded_user_key_; 416 std::string encoded_user_key_;
415 DISALLOW_COPY_AND_ASSIGN(ExistsEntryKey); 417 DISALLOW_COPY_AND_ASSIGN(ExistsEntryKey);
416 }; 418 };
417 419
418 class BlobEntryKey { 420 class BlobEntryKey {
419 public: 421 public:
422 static const int64 kSpecialIndexNumber;
423
420 BlobEntryKey() : database_id_(0), object_store_id_(0) {} 424 BlobEntryKey() : database_id_(0), object_store_id_(0) {}
421 static bool Decode(base::StringPiece* slice, BlobEntryKey* result); 425 static bool Decode(base::StringPiece* slice, BlobEntryKey* result);
422 static bool FromObjectStoreDataKey(base::StringPiece* slice, 426 static bool FromObjectStoreDataKey(base::StringPiece* slice,
423 BlobEntryKey* result); 427 BlobEntryKey* result);
424 static std::string ReencodeToObjectStoreDataKey(base::StringPiece* slice); 428 static std::string ReencodeToObjectStoreDataKey(base::StringPiece* slice);
425 static std::string EncodeMinKeyForObjectStore(int64 database_id, 429 static std::string EncodeMinKeyForObjectStore(int64 database_id,
426 int64 object_store_id); 430 int64 object_store_id);
427 static std::string EncodeStopKeyForObjectStore(int64 database_id, 431 static std::string EncodeStopKeyForObjectStore(int64 database_id,
428 int64 object_store_id); 432 int64 object_store_id);
429 static std::string Encode(int64 database_id, 433 static std::string Encode(int64 database_id,
430 int64 object_store_id, 434 int64 object_store_id,
431 const IndexedDBKey& user_key); 435 const IndexedDBKey& user_key);
432 std::string Encode() const; 436 std::string Encode() const;
433 int64 database_id() const { return database_id_; } 437 int64 database_id() const { return database_id_; }
434 int64 object_store_id() const { return object_store_id_; } 438 int64 object_store_id() const { return object_store_id_; }
435 439
436 static const int64 kSpecialIndexNumber;
437
438 private: 440 private:
439 static std::string Encode(int64 database_id, 441 static std::string Encode(int64 database_id,
440 int64 object_store_id, 442 int64 object_store_id,
441 const std::string& encoded_user_key); 443 const std::string& encoded_user_key);
442 int64 database_id_; 444 int64 database_id_;
443 int64 object_store_id_; 445 int64 object_store_id_;
444 // This is the user's ObjectStoreDataKey, not the BlobEntryKey itself. 446 // This is the user's ObjectStoreDataKey, not the BlobEntryKey itself.
445 std::string encoded_user_key_; 447 std::string encoded_user_key_;
446 }; 448 };
447 449
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 std::string encoded_user_key_; 487 std::string encoded_user_key_;
486 std::string encoded_primary_key_; 488 std::string encoded_primary_key_;
487 int64 sequence_number_; 489 int64 sequence_number_;
488 490
489 DISALLOW_COPY_AND_ASSIGN(IndexDataKey); 491 DISALLOW_COPY_AND_ASSIGN(IndexDataKey);
490 }; 492 };
491 493
492 } // namespace content 494 } // namespace content
493 495
494 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_ 496 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698