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

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

Issue 102593002: Convert string16 to base::string16 in content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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"
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 CONTENT_EXPORT void EncodeByte(unsigned char value, std::string* into); 26 CONTENT_EXPORT void EncodeByte(unsigned char value, std::string* into);
27 CONTENT_EXPORT void EncodeBool(bool value, std::string* into); 27 CONTENT_EXPORT void EncodeBool(bool value, std::string* into);
28 CONTENT_EXPORT void EncodeInt(int64 value, std::string* into); 28 CONTENT_EXPORT void EncodeInt(int64 value, std::string* into);
29 CONTENT_EXPORT void EncodeVarInt(int64 value, std::string* into); 29 CONTENT_EXPORT void EncodeVarInt(int64 value, std::string* into);
30 CONTENT_EXPORT void EncodeString(const string16& value, std::string* into); 30 CONTENT_EXPORT void EncodeString(const base::string16& value,
31 CONTENT_EXPORT void EncodeStringWithLength(const string16& value, 31 std::string* into);
32 CONTENT_EXPORT void EncodeStringWithLength(const base::string16& value,
32 std::string* into); 33 std::string* into);
33 CONTENT_EXPORT void EncodeBinary(const std::string& value, std::string* into); 34 CONTENT_EXPORT void EncodeBinary(const std::string& value, std::string* into);
34 CONTENT_EXPORT void EncodeDouble(double value, std::string* into); 35 CONTENT_EXPORT void EncodeDouble(double value, std::string* into);
35 CONTENT_EXPORT void EncodeIDBKey(const IndexedDBKey& value, std::string* into); 36 CONTENT_EXPORT void EncodeIDBKey(const IndexedDBKey& value, std::string* into);
36 CONTENT_EXPORT void EncodeIDBKeyPath(const IndexedDBKeyPath& value, 37 CONTENT_EXPORT void EncodeIDBKeyPath(const IndexedDBKeyPath& value,
37 std::string* into); 38 std::string* into);
38 39
39 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeByte(base::StringPiece* slice, 40 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeByte(base::StringPiece* slice,
40 unsigned char* value); 41 unsigned char* value);
41 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeBool(base::StringPiece* slice, 42 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeBool(base::StringPiece* slice,
42 bool* value); 43 bool* value);
43 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeInt(base::StringPiece* slice, 44 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeInt(base::StringPiece* slice,
44 int64* value); 45 int64* value);
45 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeVarInt(base::StringPiece* slice, 46 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeVarInt(base::StringPiece* slice,
46 int64* value); 47 int64* value);
47 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeString(base::StringPiece* slice, 48 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeString(base::StringPiece* slice,
48 string16* value); 49 base::string16* value);
49 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeStringWithLength( 50 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeStringWithLength(
50 base::StringPiece* slice, 51 base::StringPiece* slice,
51 string16* value); 52 base::string16* value);
52 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeBinary(base::StringPiece* slice, 53 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeBinary(base::StringPiece* slice,
53 std::string* value); 54 std::string* value);
54 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeDouble(base::StringPiece* slice, 55 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeDouble(base::StringPiece* slice,
55 double* value); 56 double* value);
56 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeIDBKey( 57 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeIDBKey(
57 base::StringPiece* slice, 58 base::StringPiece* slice,
58 scoped_ptr<IndexedDBKey>* value); 59 scoped_ptr<IndexedDBKey>* value);
59 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeIDBKeyPath( 60 CONTENT_EXPORT WARN_UNUSED_RESULT bool DecodeIDBKeyPath(
60 base::StringPiece* slice, 61 base::StringPiece* slice,
61 IndexedDBKeyPath* value); 62 IndexedDBKeyPath* value);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 int Compare(const DatabaseFreeListKey& other) const; 182 int Compare(const DatabaseFreeListKey& other) const;
182 183
183 private: 184 private:
184 int64 database_id_; 185 int64 database_id_;
185 }; 186 };
186 187
187 class DatabaseNameKey { 188 class DatabaseNameKey {
188 public: 189 public:
189 static bool Decode(base::StringPiece* slice, DatabaseNameKey* result); 190 static bool Decode(base::StringPiece* slice, DatabaseNameKey* result);
190 CONTENT_EXPORT static std::string Encode(const std::string& origin_identifier, 191 CONTENT_EXPORT static std::string Encode(const std::string& origin_identifier,
191 const string16& database_name); 192 const base::string16& database_name);
192 static std::string EncodeMinKeyForOrigin( 193 static std::string EncodeMinKeyForOrigin(
193 const std::string& origin_identifier); 194 const std::string& origin_identifier);
194 static std::string EncodeStopKeyForOrigin( 195 static std::string EncodeStopKeyForOrigin(
195 const std::string& origin_identifier); 196 const std::string& origin_identifier);
196 string16 origin() const { return origin_; } 197 base::string16 origin() const { return origin_; }
197 string16 database_name() const { return database_name_; } 198 base::string16 database_name() const { return database_name_; }
198 int Compare(const DatabaseNameKey& other); 199 int Compare(const DatabaseNameKey& other);
199 200
200 private: 201 private:
201 string16 origin_; // TODO(jsbell): Store encoded strings, or just pointers. 202 base::string16 origin_; // TODO(jsbell): Store encoded strings, or just
202 string16 database_name_; 203 // pointers.
204 base::string16 database_name_;
203 }; 205 };
204 206
205 class DatabaseMetaDataKey { 207 class DatabaseMetaDataKey {
206 public: 208 public:
207 enum MetaDataType { 209 enum MetaDataType {
208 ORIGIN_NAME = 0, 210 ORIGIN_NAME = 0,
209 DATABASE_NAME = 1, 211 DATABASE_NAME = 1,
210 USER_VERSION = 2, 212 USER_VERSION = 2,
211 MAX_OBJECT_STORE_ID = 3, 213 MAX_OBJECT_STORE_ID = 3,
212 USER_INT_VERSION = 4, 214 USER_INT_VERSION = 4,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 int64 object_store_id_; 310 int64 object_store_id_;
309 int64 index_id_; 311 int64 index_id_;
310 }; 312 };
311 313
312 class ObjectStoreNamesKey { 314 class ObjectStoreNamesKey {
313 public: 315 public:
314 // TODO(jsbell): We never use this to look up object store ids, 316 // TODO(jsbell): We never use this to look up object store ids,
315 // because a mapping is kept in the IndexedDBDatabase. Can the 317 // because a mapping is kept in the IndexedDBDatabase. Can the
316 // mapping become unreliable? Can we remove this? 318 // mapping become unreliable? Can we remove this?
317 static bool Decode(base::StringPiece* slice, ObjectStoreNamesKey* result); 319 static bool Decode(base::StringPiece* slice, ObjectStoreNamesKey* result);
318 CONTENT_EXPORT static std::string Encode(int64 database_id, 320 CONTENT_EXPORT static std::string Encode(
319 const string16& object_store_name); 321 int64 database_id,
322 const base::string16& object_store_name);
320 int Compare(const ObjectStoreNamesKey& other); 323 int Compare(const ObjectStoreNamesKey& other);
321 string16 object_store_name() const { return object_store_name_; } 324 base::string16 object_store_name() const { return object_store_name_; }
322 325
323 private: 326 private:
324 // TODO(jsbell): Store the encoded string, or just pointers to it. 327 // TODO(jsbell): Store the encoded string, or just pointers to it.
325 string16 object_store_name_; 328 base::string16 object_store_name_;
326 }; 329 };
327 330
328 class IndexNamesKey { 331 class IndexNamesKey {
329 public: 332 public:
330 IndexNamesKey(); 333 IndexNamesKey();
331 // TODO(jsbell): We never use this to look up index ids, because a mapping 334 // TODO(jsbell): We never use this to look up index ids, because a mapping
332 // is kept at a higher level. 335 // is kept at a higher level.
333 static bool Decode(base::StringPiece* slice, IndexNamesKey* result); 336 static bool Decode(base::StringPiece* slice, IndexNamesKey* result);
334 CONTENT_EXPORT static std::string Encode(int64 database_id, 337 CONTENT_EXPORT static std::string Encode(int64 database_id,
335 int64 object_store_id, 338 int64 object_store_id,
336 const string16& index_name); 339 const base::string16& index_name);
337 int Compare(const IndexNamesKey& other); 340 int Compare(const IndexNamesKey& other);
338 string16 index_name() const { return index_name_; } 341 base::string16 index_name() const { return index_name_; }
339 342
340 private: 343 private:
341 int64 object_store_id_; 344 int64 object_store_id_;
342 string16 index_name_; 345 base::string16 index_name_;
343 }; 346 };
344 347
345 class ObjectStoreDataKey { 348 class ObjectStoreDataKey {
346 public: 349 public:
347 static bool Decode(base::StringPiece* slice, ObjectStoreDataKey* result); 350 static bool Decode(base::StringPiece* slice, ObjectStoreDataKey* result);
348 CONTENT_EXPORT static std::string Encode(int64 database_id, 351 CONTENT_EXPORT static std::string Encode(int64 database_id,
349 int64 object_store_id, 352 int64 object_store_id,
350 const std::string encoded_user_key); 353 const std::string encoded_user_key);
351 static std::string Encode(int64 database_id, 354 static std::string Encode(int64 database_id,
352 int64 object_store_id, 355 int64 object_store_id,
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 std::string encoded_user_key_; 429 std::string encoded_user_key_;
427 std::string encoded_primary_key_; 430 std::string encoded_primary_key_;
428 int64 sequence_number_; 431 int64 sequence_number_;
429 432
430 DISALLOW_COPY_AND_ASSIGN(IndexDataKey); 433 DISALLOW_COPY_AND_ASSIGN(IndexDataKey);
431 }; 434 };
432 435
433 } // namespace content 436 } // namespace content
434 437
435 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_ 438 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_LEVELDB_CODING_H_
OLDNEW
« no previous file with comments | « content/browser/indexed_db/indexed_db_index_writer.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