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

Unified Diff: chrome/browser/chromeos/drive/resource_metadata_storage.cc

Issue 20266003: drive: Add ResourceMetadataStorage::Iterator::GetCacheEntry() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove unneeded cache argument Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/drive/resource_metadata_storage.cc
diff --git a/chrome/browser/chromeos/drive/resource_metadata_storage.cc b/chrome/browser/chromeos/drive/resource_metadata_storage.cc
index 6f7c74d61608c16dd8135bcdb2276e85cc064143..56a6bc96966354e2e0c62dd4f0f4c080586a6612 100644
--- a/chrome/browser/chromeos/drive/resource_metadata_storage.cc
+++ b/chrome/browser/chromeos/drive/resource_metadata_storage.cc
@@ -121,6 +121,28 @@ const ResourceEntry& ResourceMetadataStorage::Iterator::Get() const {
return entry_;
}
+bool ResourceMetadataStorage::Iterator::GetCacheEntry(
+ FileCacheEntry* cache_entry) {
+ base::ThreadRestrictions::AssertIOAllowed();
+ DCHECK(!IsAtEnd());
+
+ // Try to seek to the cache entry.
+ std::string current_key = it_->key().ToString();
+ std::string cache_entry_key = GetCacheEntryKey(current_key);
+ it_->Seek(leveldb::Slice(cache_entry_key));
+
+ bool success = it_->Valid() &&
+ it_->key().compare(cache_entry_key) == 0 &&
+ cache_entry->ParseFromArray(it_->value().data(), it_->value().size());
+
+ // Seek back to the original position.
+ it_->Seek(leveldb::Slice(current_key));
+ DCHECK(!IsAtEnd());
+ DCHECK_EQ(current_key, it_->key().ToString());
+
+ return success;
+}
+
void ResourceMetadataStorage::Iterator::Advance() {
base::ThreadRestrictions::AssertIOAllowed();
DCHECK(!IsAtEnd());

Powered by Google App Engine
This is Rietveld 408576698