Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / content / browser / indexed_db / indexed_db_leveldb_coding.cc
index 4455683..2de9b6d 100644 (file)
@@ -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) {
+    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;
+  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);