Chromium Code Reviews| Index: content/browser/indexed_db/indexed_db_leveldb_coding.cc |
| diff --git a/content/browser/indexed_db/indexed_db_leveldb_coding.cc b/content/browser/indexed_db/indexed_db_leveldb_coding.cc |
| index 44556833f69543eb6ee523724a9c01e9dc8e4f44..2de9b6d585db798e7ecc3fee710bae07de6e5bc0 100644 |
| --- a/content/browser/indexed_db/indexed_db_leveldb_coding.cc |
| +++ b/content/browser/indexed_db/indexed_db_leveldb_coding.cc |
| @@ -375,6 +375,14 @@ void EncodeIDBKeyPath(const IndexedDBKeyPath& value, std::string* into) { |
| } |
| } |
| +void EncodeBlobJournal(const BlobJournalType& journal, std::string* into) { |
| + BlobJournalType::const_iterator iter; |
| + for (iter = journal.begin(); iter != journal.end(); ++iter) { |
|
cmumford
2014/04/30 21:29:30
If the journal is empty (which may not be possible
ericu
2014/04/30 22:16:10
Yes. The convention in this file is that all Enco
|
| + EncodeVarInt(iter->first, into); |
| + EncodeVarInt(iter->second, into); |
| + } |
| +} |
| + |
| bool DecodeByte(StringPiece* slice, unsigned char* value) { |
| if (slice->empty()) |
| return false; |
| @@ -607,6 +615,27 @@ bool DecodeIDBKeyPath(StringPiece* slice, IndexedDBKeyPath* value) { |
| return false; |
| } |
| +bool DecodeBlobJournal(StringPiece* slice, BlobJournalType* journal) { |
| + BlobJournalType output; |
|
cmumford
2014/04/30 21:29:30
Should an empty slice be considered an error?
ericu
2014/04/30 22:16:10
No, that's an empty journal.
|
| + while (!slice->empty()) { |
| + int64 database_id = -1; |
| + int64 blob_key = -1; |
| + if (!DecodeVarInt(slice, &database_id)) |
| + return false; |
| + if (!KeyPrefix::IsValidDatabaseId(database_id)) |
| + return false; |
| + if (!DecodeVarInt(slice, &blob_key)) |
| + return false; |
| + if (!DatabaseMetaDataKey::IsValidBlobKey(blob_key) && |
| + (blob_key != DatabaseMetaDataKey::kAllBlobsKey)) { |
| + return false; |
| + } |
| + output.push_back(std::make_pair(database_id, blob_key)); |
| + } |
| + journal->swap(output); |
| + return true; |
| +} |
| + |
| bool ConsumeEncodedIDBKey(StringPiece* slice) { |
| unsigned char type = (*slice)[0]; |
| slice->remove_prefix(1); |