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

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

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 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
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 <stddef.h>
9 #include <stdint.h>
10
8 #include <string> 11 #include <string>
9 #include <utility> 12 #include <utility>
10 #include <vector> 13 #include <vector>
11 14
12 #include "base/basictypes.h"
13 #include "base/logging.h" 15 #include "base/logging.h"
16 #include "base/macros.h"
14 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
15 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
16 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
17 #include "base/strings/string_piece.h" 20 #include "base/strings/string_piece.h"
18 #include "content/common/indexed_db/indexed_db_key.h" 21 #include "content/common/indexed_db/indexed_db_key.h"
19 #include "content/common/indexed_db/indexed_db_key_path.h" 22 #include "content/common/indexed_db/indexed_db_key_path.h"
20 23
21 namespace content { 24 namespace content {
22 25
23 CONTENT_EXPORT extern const unsigned char kMinimumIndexId; 26 CONTENT_EXPORT extern const unsigned char kMinimumIndexId;
24 27
25 CONTENT_EXPORT std::string MaxIDBKey(); 28 CONTENT_EXPORT std::string MaxIDBKey();
26 CONTENT_EXPORT std::string MinIDBKey(); 29 CONTENT_EXPORT std::string MinIDBKey();
27 30
28 // DatabaseId, BlobKey 31 // DatabaseId, BlobKey
29 typedef std::pair<int64_t, int64_t> BlobJournalEntryType; 32 typedef std::pair<int64_t, int64_t> BlobJournalEntryType;
30 typedef std::vector<BlobJournalEntryType> BlobJournalType; 33 typedef std::vector<BlobJournalEntryType> BlobJournalType;
31 34
32 CONTENT_EXPORT void EncodeByte(unsigned char value, std::string* into); 35 CONTENT_EXPORT void EncodeByte(unsigned char value, std::string* into);
33 CONTENT_EXPORT void EncodeBool(bool value, std::string* into); 36 CONTENT_EXPORT void EncodeBool(bool value, std::string* into);
34 CONTENT_EXPORT void EncodeInt(int64 value, std::string* into); 37 CONTENT_EXPORT void EncodeInt(int64_t value, std::string* into);
35 CONTENT_EXPORT void EncodeVarInt(int64 value, std::string* into); 38 CONTENT_EXPORT void EncodeVarInt(int64_t value, std::string* into);
36 CONTENT_EXPORT void EncodeString(const base::string16& value, 39 CONTENT_EXPORT void EncodeString(const base::string16& value,
37 std::string* into); 40 std::string* into);
38 CONTENT_EXPORT void EncodeStringWithLength(const base::string16& value, 41 CONTENT_EXPORT void EncodeStringWithLength(const base::string16& value,
39 std::string* into); 42 std::string* into);
40 CONTENT_EXPORT void EncodeBinary(const std::string& value, std::string* into); 43 CONTENT_EXPORT void EncodeBinary(const std::string& value, std::string* into);
41 CONTENT_EXPORT void EncodeDouble(double value, std::string* into); 44 CONTENT_EXPORT void EncodeDouble(double value, std::string* into);
42 CONTENT_EXPORT void EncodeIDBKey(const IndexedDBKey& value, std::string* into); 45 CONTENT_EXPORT void EncodeIDBKey(const IndexedDBKey& value, std::string* into);
43 CONTENT_EXPORT void EncodeIDBKeyPath(const IndexedDBKeyPath& value, 46 CONTENT_EXPORT void EncodeIDBKeyPath(const IndexedDBKeyPath& value,
44 std::string* into); 47 std::string* into);
45 CONTENT_EXPORT void EncodeBlobJournal(const BlobJournalType& journal, 48 CONTENT_EXPORT void EncodeBlobJournal(const BlobJournalType& journal,
46 std::string* into); 49 std::string* into);
47 50
48 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeByte(base::StringPiece* slice, 51 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeByte(base::StringPiece* slice,
49 unsigned char* value); 52 unsigned char* value);
50 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeBool(base::StringPiece* slice, 53 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeBool(base::StringPiece* slice,
51 bool* value); 54 bool* value);
52 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeInt(base::StringPiece* slice, 55 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeInt(base::StringPiece* slice,
53 int64* value); 56 int64_t* value);
54 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeVarInt(base::StringPiece* slice, 57 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeVarInt(base::StringPiece* slice,
55 int64* value); 58 int64_t* value);
56 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeString(base::StringPiece* slice, 59 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeString(base::StringPiece* slice,
57 base::string16* value); 60 base::string16* value);
58 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeStringWithLength( 61 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeStringWithLength(
59 base::StringPiece* slice, 62 base::StringPiece* slice,
60 base::string16* value); 63 base::string16* value);
61 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeBinary(base::StringPiece* slice, 64 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeBinary(base::StringPiece* slice,
62 std::string* value); 65 std::string* value);
63 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeDouble(base::StringPiece* slice, 66 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeDouble(base::StringPiece* slice,
64 double* value); 67 double* value);
65 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeIDBKey( 68 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeIDBKey(
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 static const size_t kMaxObjectStoreIdSizeBytes = 114 static const size_t kMaxObjectStoreIdSizeBytes =
112 1ULL << kMaxObjectStoreIdSizeBits; // 8 115 1ULL << kMaxObjectStoreIdSizeBits; // 8
113 static const size_t kMaxIndexIdSizeBytes = 1ULL << kMaxIndexIdSizeBits; // 4 116 static const size_t kMaxIndexIdSizeBytes = 1ULL << kMaxIndexIdSizeBits; // 4
114 117
115 static const size_t kMaxDatabaseIdBits = 118 static const size_t kMaxDatabaseIdBits =
116 kMaxDatabaseIdSizeBytes * 8 - 1; // 63 119 kMaxDatabaseIdSizeBytes * 8 - 1; // 63
117 static const size_t kMaxObjectStoreIdBits = 120 static const size_t kMaxObjectStoreIdBits =
118 kMaxObjectStoreIdSizeBytes * 8 - 1; // 63 121 kMaxObjectStoreIdSizeBytes * 8 - 1; // 63
119 static const size_t kMaxIndexIdBits = kMaxIndexIdSizeBytes * 8 - 1; // 31 122 static const size_t kMaxIndexIdBits = kMaxIndexIdSizeBytes * 8 - 1; // 31
120 123
121 static const int64 kMaxDatabaseId = 124 static const int64_t kMaxDatabaseId =
122 (1ULL << kMaxDatabaseIdBits) - 1; // max signed int64 125 (1ULL << kMaxDatabaseIdBits) - 1; // max signed int64_t
123 static const int64 kMaxObjectStoreId = 126 static const int64_t kMaxObjectStoreId =
124 (1ULL << kMaxObjectStoreIdBits) - 1; // max signed int64 127 (1ULL << kMaxObjectStoreIdBits) - 1; // max signed int64_t
125 static const int64 kMaxIndexId = 128 static const int64_t kMaxIndexId =
126 (1ULL << kMaxIndexIdBits) - 1; // max signed int32 129 (1ULL << kMaxIndexIdBits) - 1; // max signed int32_t
127 130
128 static const int64 kInvalidId = -1; 131 static const int64_t kInvalidId = -1;
129 132
130 KeyPrefix(); 133 KeyPrefix();
131 explicit KeyPrefix(int64 database_id); 134 explicit KeyPrefix(int64_t database_id);
132 KeyPrefix(int64 database_id, int64 object_store_id); 135 KeyPrefix(int64_t database_id, int64_t object_store_id);
133 KeyPrefix(int64 database_id, int64 object_store_id, int64 index_id); 136 KeyPrefix(int64_t database_id, int64_t object_store_id, int64_t index_id);
134 static KeyPrefix CreateWithSpecialIndex(int64 database_id, 137 static KeyPrefix CreateWithSpecialIndex(int64_t database_id,
135 int64 object_store_id, 138 int64_t object_store_id,
136 int64 index_id); 139 int64_t index_id);
137 140
138 static bool Decode(base::StringPiece* slice, KeyPrefix* result); 141 static bool Decode(base::StringPiece* slice, KeyPrefix* result);
139 std::string Encode() const; 142 std::string Encode() const;
140 static std::string EncodeEmpty(); 143 static std::string EncodeEmpty();
141 int Compare(const KeyPrefix& other) const; 144 int Compare(const KeyPrefix& other) const;
142 145
143 CONTENT_EXPORT static bool IsValidDatabaseId(int64 database_id); 146 CONTENT_EXPORT static bool IsValidDatabaseId(int64_t database_id);
144 static bool IsValidObjectStoreId(int64 index_id); 147 static bool IsValidObjectStoreId(int64_t index_id);
145 static bool IsValidIndexId(int64 index_id); 148 static bool IsValidIndexId(int64_t index_id);
146 static bool ValidIds(int64 database_id, 149 static bool ValidIds(int64_t database_id,
147 int64 object_store_id, 150 int64_t object_store_id,
148 int64 index_id) { 151 int64_t index_id) {
149 return IsValidDatabaseId(database_id) && 152 return IsValidDatabaseId(database_id) &&
150 IsValidObjectStoreId(object_store_id) && IsValidIndexId(index_id); 153 IsValidObjectStoreId(object_store_id) && IsValidIndexId(index_id);
151 } 154 }
152 static bool ValidIds(int64 database_id, int64 object_store_id) { 155 static bool ValidIds(int64_t database_id, int64_t object_store_id) {
153 return IsValidDatabaseId(database_id) && 156 return IsValidDatabaseId(database_id) &&
154 IsValidObjectStoreId(object_store_id); 157 IsValidObjectStoreId(object_store_id);
155 } 158 }
156 159
157 Type type() const; 160 Type type() const;
158 161
159 int64 database_id_; 162 int64_t database_id_;
160 int64 object_store_id_; 163 int64_t object_store_id_;
161 int64 index_id_; 164 int64_t index_id_;
162 165
163 private: 166 private:
164 // Special constructor for CreateWithSpecialIndex() 167 // Special constructor for CreateWithSpecialIndex()
165 KeyPrefix(enum Type, 168 KeyPrefix(enum Type,
166 int64 database_id, 169 int64_t database_id,
167 int64 object_store_id, 170 int64_t object_store_id,
168 int64 index_id); 171 int64_t index_id);
169 172
170 static std::string EncodeInternal(int64 database_id, 173 static std::string EncodeInternal(int64_t database_id,
171 int64 object_store_id, 174 int64_t object_store_id,
172 int64 index_id); 175 int64_t index_id);
173 }; 176 };
174 177
175 class SchemaVersionKey { 178 class SchemaVersionKey {
176 public: 179 public:
177 CONTENT_EXPORT static std::string Encode(); 180 CONTENT_EXPORT static std::string Encode();
178 }; 181 };
179 182
180 class MaxDatabaseIdKey { 183 class MaxDatabaseIdKey {
181 public: 184 public:
182 CONTENT_EXPORT static std::string Encode(); 185 CONTENT_EXPORT static std::string Encode();
(...skipping 11 matching lines...) Expand all
194 197
195 class LiveBlobJournalKey { 198 class LiveBlobJournalKey {
196 public: 199 public:
197 static std::string Encode(); 200 static std::string Encode();
198 }; 201 };
199 202
200 class DatabaseFreeListKey { 203 class DatabaseFreeListKey {
201 public: 204 public:
202 DatabaseFreeListKey(); 205 DatabaseFreeListKey();
203 static bool Decode(base::StringPiece* slice, DatabaseFreeListKey* result); 206 static bool Decode(base::StringPiece* slice, DatabaseFreeListKey* result);
204 CONTENT_EXPORT static std::string Encode(int64 database_id); 207 CONTENT_EXPORT static std::string Encode(int64_t database_id);
205 static CONTENT_EXPORT std::string EncodeMaxKey(); 208 static CONTENT_EXPORT std::string EncodeMaxKey();
206 int64 DatabaseId() const; 209 int64_t DatabaseId() const;
207 int Compare(const DatabaseFreeListKey& other) const; 210 int Compare(const DatabaseFreeListKey& other) const;
208 211
209 private: 212 private:
210 int64 database_id_; 213 int64_t database_id_;
211 }; 214 };
212 215
213 class DatabaseNameKey { 216 class DatabaseNameKey {
214 public: 217 public:
215 static bool Decode(base::StringPiece* slice, DatabaseNameKey* result); 218 static bool Decode(base::StringPiece* slice, DatabaseNameKey* result);
216 CONTENT_EXPORT static std::string Encode(const std::string& origin_identifier, 219 CONTENT_EXPORT static std::string Encode(const std::string& origin_identifier,
217 const base::string16& database_name); 220 const base::string16& database_name);
218 static std::string EncodeMinKeyForOrigin( 221 static std::string EncodeMinKeyForOrigin(
219 const std::string& origin_identifier); 222 const std::string& origin_identifier);
220 static std::string EncodeStopKeyForOrigin( 223 static std::string EncodeStopKeyForOrigin(
(...skipping 13 matching lines...) Expand all
234 enum MetaDataType { 237 enum MetaDataType {
235 ORIGIN_NAME = 0, 238 ORIGIN_NAME = 0,
236 DATABASE_NAME = 1, 239 DATABASE_NAME = 1,
237 USER_VERSION = 2, 240 USER_VERSION = 2,
238 MAX_OBJECT_STORE_ID = 3, 241 MAX_OBJECT_STORE_ID = 3,
239 USER_INT_VERSION = 4, 242 USER_INT_VERSION = 4,
240 BLOB_KEY_GENERATOR_CURRENT_NUMBER = 5, 243 BLOB_KEY_GENERATOR_CURRENT_NUMBER = 5,
241 MAX_SIMPLE_METADATA_TYPE = 6 244 MAX_SIMPLE_METADATA_TYPE = 6
242 }; 245 };
243 246
244 CONTENT_EXPORT static const int64 kAllBlobsKey; 247 CONTENT_EXPORT static const int64_t kAllBlobsKey;
245 static const int64 kBlobKeyGeneratorInitialNumber; 248 static const int64_t kBlobKeyGeneratorInitialNumber;
246 // All keys <= 0 are invalid. This one's just a convenient example. 249 // All keys <= 0 are invalid. This one's just a convenient example.
247 static const int64 kInvalidBlobKey; 250 static const int64_t kInvalidBlobKey;
248 251
249 static bool IsValidBlobKey(int64 blob_key); 252 static bool IsValidBlobKey(int64_t blob_key);
250 CONTENT_EXPORT static std::string Encode(int64 database_id, 253 CONTENT_EXPORT static std::string Encode(int64_t database_id,
251 MetaDataType type); 254 MetaDataType type);
252 }; 255 };
253 256
254 class ObjectStoreMetaDataKey { 257 class ObjectStoreMetaDataKey {
255 public: 258 public:
256 enum MetaDataType { 259 enum MetaDataType {
257 NAME = 0, 260 NAME = 0,
258 KEY_PATH = 1, 261 KEY_PATH = 1,
259 AUTO_INCREMENT = 2, 262 AUTO_INCREMENT = 2,
260 EVICTABLE = 3, 263 EVICTABLE = 3,
261 LAST_VERSION = 4, 264 LAST_VERSION = 4,
262 MAX_INDEX_ID = 5, 265 MAX_INDEX_ID = 5,
263 HAS_KEY_PATH = 6, 266 HAS_KEY_PATH = 6,
264 KEY_GENERATOR_CURRENT_NUMBER = 7 267 KEY_GENERATOR_CURRENT_NUMBER = 7
265 }; 268 };
266 269
267 ObjectStoreMetaDataKey(); 270 ObjectStoreMetaDataKey();
268 static bool Decode(base::StringPiece* slice, ObjectStoreMetaDataKey* result); 271 static bool Decode(base::StringPiece* slice, ObjectStoreMetaDataKey* result);
269 CONTENT_EXPORT static std::string Encode(int64 database_id, 272 CONTENT_EXPORT static std::string Encode(int64_t database_id,
270 int64 object_store_id, 273 int64_t object_store_id,
271 unsigned char meta_data_type); 274 unsigned char meta_data_type);
272 CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id); 275 CONTENT_EXPORT static std::string EncodeMaxKey(int64_t database_id);
273 CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id, 276 CONTENT_EXPORT static std::string EncodeMaxKey(int64_t database_id,
274 int64 object_store_id); 277 int64_t object_store_id);
275 int64 ObjectStoreId() const; 278 int64_t ObjectStoreId() const;
276 unsigned char MetaDataType() const; 279 unsigned char MetaDataType() const;
277 int Compare(const ObjectStoreMetaDataKey& other); 280 int Compare(const ObjectStoreMetaDataKey& other);
278 281
279 private: 282 private:
280 int64 object_store_id_; 283 int64_t object_store_id_;
281 unsigned char meta_data_type_; 284 unsigned char meta_data_type_;
282 }; 285 };
283 286
284 class IndexMetaDataKey { 287 class IndexMetaDataKey {
285 public: 288 public:
286 enum MetaDataType { 289 enum MetaDataType {
287 NAME = 0, 290 NAME = 0,
288 UNIQUE = 1, 291 UNIQUE = 1,
289 KEY_PATH = 2, 292 KEY_PATH = 2,
290 MULTI_ENTRY = 3 293 MULTI_ENTRY = 3
291 }; 294 };
292 295
293 IndexMetaDataKey(); 296 IndexMetaDataKey();
294 static bool Decode(base::StringPiece* slice, IndexMetaDataKey* result); 297 static bool Decode(base::StringPiece* slice, IndexMetaDataKey* result);
295 CONTENT_EXPORT static std::string Encode(int64 database_id, 298 CONTENT_EXPORT static std::string Encode(int64_t database_id,
296 int64 object_store_id, 299 int64_t object_store_id,
297 int64 index_id, 300 int64_t index_id,
298 unsigned char meta_data_type); 301 unsigned char meta_data_type);
299 CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id, 302 CONTENT_EXPORT static std::string EncodeMaxKey(int64_t database_id,
300 int64 object_store_id); 303 int64_t object_store_id);
301 CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id, 304 CONTENT_EXPORT static std::string EncodeMaxKey(int64_t database_id,
302 int64 object_store_id, 305 int64_t object_store_id,
303 int64 index_id); 306 int64_t index_id);
304 int Compare(const IndexMetaDataKey& other); 307 int Compare(const IndexMetaDataKey& other);
305 int64 IndexId() const; 308 int64_t IndexId() const;
306 unsigned char meta_data_type() const { return meta_data_type_; } 309 unsigned char meta_data_type() const { return meta_data_type_; }
307 310
308 private: 311 private:
309 int64 object_store_id_; 312 int64_t object_store_id_;
310 int64 index_id_; 313 int64_t index_id_;
311 unsigned char meta_data_type_; 314 unsigned char meta_data_type_;
312 }; 315 };
313 316
314 class ObjectStoreFreeListKey { 317 class ObjectStoreFreeListKey {
315 public: 318 public:
316 ObjectStoreFreeListKey(); 319 ObjectStoreFreeListKey();
317 static bool Decode(base::StringPiece* slice, ObjectStoreFreeListKey* result); 320 static bool Decode(base::StringPiece* slice, ObjectStoreFreeListKey* result);
318 CONTENT_EXPORT static std::string Encode(int64 database_id, 321 CONTENT_EXPORT static std::string Encode(int64_t database_id,
319 int64 object_store_id); 322 int64_t object_store_id);
320 CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id); 323 CONTENT_EXPORT static std::string EncodeMaxKey(int64_t database_id);
321 int64 ObjectStoreId() const; 324 int64_t ObjectStoreId() const;
322 int Compare(const ObjectStoreFreeListKey& other); 325 int Compare(const ObjectStoreFreeListKey& other);
323 326
324 private: 327 private:
325 int64 object_store_id_; 328 int64_t object_store_id_;
326 }; 329 };
327 330
328 class IndexFreeListKey { 331 class IndexFreeListKey {
329 public: 332 public:
330 IndexFreeListKey(); 333 IndexFreeListKey();
331 static bool Decode(base::StringPiece* slice, IndexFreeListKey* result); 334 static bool Decode(base::StringPiece* slice, IndexFreeListKey* result);
332 CONTENT_EXPORT static std::string Encode(int64 database_id, 335 CONTENT_EXPORT static std::string Encode(int64_t database_id,
333 int64 object_store_id, 336 int64_t object_store_id,
334 int64 index_id); 337 int64_t index_id);
335 CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id, 338 CONTENT_EXPORT static std::string EncodeMaxKey(int64_t database_id,
336 int64 object_store_id); 339 int64_t object_store_id);
337 int Compare(const IndexFreeListKey& other); 340 int Compare(const IndexFreeListKey& other);
338 int64 ObjectStoreId() const; 341 int64_t ObjectStoreId() const;
339 int64 IndexId() const; 342 int64_t IndexId() const;
340 343
341 private: 344 private:
342 int64 object_store_id_; 345 int64_t object_store_id_;
343 int64 index_id_; 346 int64_t index_id_;
344 }; 347 };
345 348
346 class ObjectStoreNamesKey { 349 class ObjectStoreNamesKey {
347 public: 350 public:
348 // TODO(jsbell): We never use this to look up object store ids, 351 // TODO(jsbell): We never use this to look up object store ids,
349 // because a mapping is kept in the IndexedDBDatabase. Can the 352 // because a mapping is kept in the IndexedDBDatabase. Can the
350 // mapping become unreliable? Can we remove this? 353 // mapping become unreliable? Can we remove this?
351 static bool Decode(base::StringPiece* slice, ObjectStoreNamesKey* result); 354 static bool Decode(base::StringPiece* slice, ObjectStoreNamesKey* result);
352 CONTENT_EXPORT static std::string Encode( 355 CONTENT_EXPORT static std::string Encode(
353 int64 database_id, 356 int64_t database_id,
354 const base::string16& object_store_name); 357 const base::string16& object_store_name);
355 int Compare(const ObjectStoreNamesKey& other); 358 int Compare(const ObjectStoreNamesKey& other);
356 base::string16 object_store_name() const { return object_store_name_; } 359 base::string16 object_store_name() const { return object_store_name_; }
357 360
358 private: 361 private:
359 // TODO(jsbell): Store the encoded string, or just pointers to it. 362 // TODO(jsbell): Store the encoded string, or just pointers to it.
360 base::string16 object_store_name_; 363 base::string16 object_store_name_;
361 }; 364 };
362 365
363 class IndexNamesKey { 366 class IndexNamesKey {
364 public: 367 public:
365 IndexNamesKey(); 368 IndexNamesKey();
366 // TODO(jsbell): We never use this to look up index ids, because a mapping 369 // TODO(jsbell): We never use this to look up index ids, because a mapping
367 // is kept at a higher level. 370 // is kept at a higher level.
368 static bool Decode(base::StringPiece* slice, IndexNamesKey* result); 371 static bool Decode(base::StringPiece* slice, IndexNamesKey* result);
369 CONTENT_EXPORT static std::string Encode(int64 database_id, 372 CONTENT_EXPORT static std::string Encode(int64_t database_id,
370 int64 object_store_id, 373 int64_t object_store_id,
371 const base::string16& index_name); 374 const base::string16& index_name);
372 int Compare(const IndexNamesKey& other); 375 int Compare(const IndexNamesKey& other);
373 base::string16 index_name() const { return index_name_; } 376 base::string16 index_name() const { return index_name_; }
374 377
375 private: 378 private:
376 int64 object_store_id_; 379 int64_t object_store_id_;
377 base::string16 index_name_; 380 base::string16 index_name_;
378 }; 381 };
379 382
380 class ObjectStoreDataKey { 383 class ObjectStoreDataKey {
381 public: 384 public:
382 static const int64 kSpecialIndexNumber; 385 static const int64_t kSpecialIndexNumber;
383 386
384 ObjectStoreDataKey(); 387 ObjectStoreDataKey();
385 ~ObjectStoreDataKey(); 388 ~ObjectStoreDataKey();
386 389
387 static bool Decode(base::StringPiece* slice, ObjectStoreDataKey* result); 390 static bool Decode(base::StringPiece* slice, ObjectStoreDataKey* result);
388 CONTENT_EXPORT static std::string Encode(int64 database_id, 391 CONTENT_EXPORT static std::string Encode(int64_t database_id,
389 int64 object_store_id, 392 int64_t object_store_id,
390 const std::string encoded_user_key); 393 const std::string encoded_user_key);
391 static std::string Encode(int64 database_id, 394 static std::string Encode(int64_t database_id,
392 int64 object_store_id, 395 int64_t object_store_id,
393 const IndexedDBKey& user_key); 396 const IndexedDBKey& user_key);
394 scoped_ptr<IndexedDBKey> user_key() const; 397 scoped_ptr<IndexedDBKey> user_key() const;
395 private: 398 private:
396 std::string encoded_user_key_; 399 std::string encoded_user_key_;
397 }; 400 };
398 401
399 class ExistsEntryKey { 402 class ExistsEntryKey {
400 public: 403 public:
401 ExistsEntryKey(); 404 ExistsEntryKey();
402 ~ExistsEntryKey(); 405 ~ExistsEntryKey();
403 406
404 static bool Decode(base::StringPiece* slice, ExistsEntryKey* result); 407 static bool Decode(base::StringPiece* slice, ExistsEntryKey* result);
405 CONTENT_EXPORT static std::string Encode(int64 database_id, 408 CONTENT_EXPORT static std::string Encode(int64_t database_id,
406 int64 object_store_id, 409 int64_t object_store_id,
407 const std::string& encoded_key); 410 const std::string& encoded_key);
408 static std::string Encode(int64 database_id, 411 static std::string Encode(int64_t database_id,
409 int64 object_store_id, 412 int64_t object_store_id,
410 const IndexedDBKey& user_key); 413 const IndexedDBKey& user_key);
411 scoped_ptr<IndexedDBKey> user_key() const; 414 scoped_ptr<IndexedDBKey> user_key() const;
412 415
413 private: 416 private:
414 static const int64 kSpecialIndexNumber; 417 static const int64_t kSpecialIndexNumber;
415 418
416 std::string encoded_user_key_; 419 std::string encoded_user_key_;
417 DISALLOW_COPY_AND_ASSIGN(ExistsEntryKey); 420 DISALLOW_COPY_AND_ASSIGN(ExistsEntryKey);
418 }; 421 };
419 422
420 class BlobEntryKey { 423 class BlobEntryKey {
421 public: 424 public:
422 BlobEntryKey() : database_id_(0), object_store_id_(0) {} 425 BlobEntryKey() : database_id_(0), object_store_id_(0) {}
423 static bool Decode(base::StringPiece* slice, BlobEntryKey* result); 426 static bool Decode(base::StringPiece* slice, BlobEntryKey* result);
424 static bool FromObjectStoreDataKey(base::StringPiece* slice, 427 static bool FromObjectStoreDataKey(base::StringPiece* slice,
425 BlobEntryKey* result); 428 BlobEntryKey* result);
426 static std::string ReencodeToObjectStoreDataKey(base::StringPiece* slice); 429 static std::string ReencodeToObjectStoreDataKey(base::StringPiece* slice);
427 static std::string EncodeMinKeyForObjectStore(int64 database_id, 430 static std::string EncodeMinKeyForObjectStore(int64_t database_id,
428 int64 object_store_id); 431 int64_t object_store_id);
429 static std::string EncodeStopKeyForObjectStore(int64 database_id, 432 static std::string EncodeStopKeyForObjectStore(int64_t database_id,
430 int64 object_store_id); 433 int64_t object_store_id);
431 static std::string Encode(int64 database_id, 434 static std::string Encode(int64_t database_id,
432 int64 object_store_id, 435 int64_t object_store_id,
433 const IndexedDBKey& user_key); 436 const IndexedDBKey& user_key);
434 std::string Encode() const; 437 std::string Encode() const;
435 int64 database_id() const { return database_id_; } 438 int64_t database_id() const { return database_id_; }
436 int64 object_store_id() const { return object_store_id_; } 439 int64_t object_store_id() const { return object_store_id_; }
437 440
438 private: 441 private:
439 static const int64 kSpecialIndexNumber; 442 static const int64_t kSpecialIndexNumber;
440 443
441 static std::string Encode(int64 database_id, 444 static std::string Encode(int64_t database_id,
442 int64 object_store_id, 445 int64_t object_store_id,
443 const std::string& encoded_user_key); 446 const std::string& encoded_user_key);
444 int64 database_id_; 447 int64_t database_id_;
445 int64 object_store_id_; 448 int64_t object_store_id_;
446 // This is the user's ObjectStoreDataKey, not the BlobEntryKey itself. 449 // This is the user's ObjectStoreDataKey, not the BlobEntryKey itself.
447 std::string encoded_user_key_; 450 std::string encoded_user_key_;
448 }; 451 };
449 452
450 class IndexDataKey { 453 class IndexDataKey {
451 public: 454 public:
452 IndexDataKey(); 455 IndexDataKey();
453 ~IndexDataKey(); 456 ~IndexDataKey();
454 static bool Decode(base::StringPiece* slice, IndexDataKey* result); 457 static bool Decode(base::StringPiece* slice, IndexDataKey* result);
455 CONTENT_EXPORT static std::string Encode( 458 CONTENT_EXPORT static std::string Encode(
456 int64 database_id, 459 int64_t database_id,
457 int64 object_store_id, 460 int64_t object_store_id,
458 int64 index_id, 461 int64_t index_id,
459 const std::string& encoded_user_key, 462 const std::string& encoded_user_key,
460 const std::string& encoded_primary_key, 463 const std::string& encoded_primary_key,
461 int64 sequence_number); 464 int64_t sequence_number);
462 static std::string Encode(int64 database_id, 465 static std::string Encode(int64_t database_id,
463 int64 object_store_id, 466 int64_t object_store_id,
464 int64 index_id, 467 int64_t index_id,
465 const IndexedDBKey& user_key); 468 const IndexedDBKey& user_key);
466 static std::string Encode(int64 database_id, 469 static std::string Encode(int64_t database_id,
467 int64 object_store_id, 470 int64_t object_store_id,
468 int64 index_id, 471 int64_t index_id,
469 const IndexedDBKey& user_key, 472 const IndexedDBKey& user_key,
470 const IndexedDBKey& user_primary_key); 473 const IndexedDBKey& user_primary_key);
471 static std::string EncodeMinKey(int64 database_id, 474 static std::string EncodeMinKey(int64_t database_id,
472 int64 object_store_id, 475 int64_t object_store_id,
473 int64 index_id); 476 int64_t index_id);
474 CONTENT_EXPORT static std::string EncodeMaxKey(int64 database_id, 477 CONTENT_EXPORT static std::string EncodeMaxKey(int64_t database_id,
475 int64 object_store_id, 478 int64_t object_store_id,
476 int64 index_id); 479 int64_t index_id);
477 int64 DatabaseId() const; 480 int64_t DatabaseId() const;
478 int64 ObjectStoreId() const; 481 int64_t ObjectStoreId() const;
479 int64 IndexId() const; 482 int64_t IndexId() const;
480 scoped_ptr<IndexedDBKey> user_key() const; 483 scoped_ptr<IndexedDBKey> user_key() const;
481 scoped_ptr<IndexedDBKey> primary_key() const; 484 scoped_ptr<IndexedDBKey> primary_key() const;
482 485
483 private: 486 private:
484 int64 database_id_; 487 int64_t database_id_;
485 int64 object_store_id_; 488 int64_t object_store_id_;
486 int64 index_id_; 489 int64_t index_id_;
487 std::string encoded_user_key_; 490 std::string encoded_user_key_;
488 std::string encoded_primary_key_; 491 std::string encoded_primary_key_;
489 int64 sequence_number_; 492 int64_t sequence_number_;
490 493
491 DISALLOW_COPY_AND_ASSIGN(IndexDataKey); 494 DISALLOW_COPY_AND_ASSIGN(IndexDataKey);
492 }; 495 };
493 496
494 } // namespace content 497 } // namespace content
495 498
496 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_ 499 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_internals_ui.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