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

Unified Diff: components/leveldb_proto/leveldb_database.cc

Issue 2049573003: Implement ProtoDatabase::GetEntry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add tests Created 4 years, 6 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: components/leveldb_proto/leveldb_database.cc
diff --git a/components/leveldb_proto/leveldb_database.cc b/components/leveldb_proto/leveldb_database.cc
index aada409447f51653cbd80a38bb0737555fbe8974..b819d463dd6907feaffa77c731e4fae833da54c5 100644
--- a/components/leveldb_proto/leveldb_database.cc
+++ b/components/leveldb_proto/leveldb_database.cc
@@ -123,4 +123,21 @@ bool LevelDB::Load(std::vector<std::string>* entries) {
return true;
}
+bool LevelDB::Get(const std::string& key, std::string* entry) {
+ DFAKE_SCOPED_LOCK(thread_checker_);
+ if (!db_)
+ return false;
+
+ leveldb::ReadOptions options;
+ leveldb::Status status = db_->Get(options, key, entry);
+ if (status.ok())
+ return true;
+ if (status.IsNotFound())
+ return false;
+
+ DLOG(WARNING) << "Failed loading leveldb_proto entry with key \"" << key
+ << "\": " << status.ToString();
+ return false;
+}
+
} // namespace leveldb_proto

Powered by Google App Engine
This is Rietveld 408576698