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

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: not found vs error 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
« no previous file with comments | « components/leveldb_proto/leveldb_database.h ('k') | components/leveldb_proto/proto_database.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6a8586f87059b0697cde433968e58676a9a77004 100644
--- a/components/leveldb_proto/leveldb_database.cc
+++ b/components/leveldb_proto/leveldb_database.cc
@@ -123,4 +123,25 @@ bool LevelDB::Load(std::vector<std::string>* entries) {
return true;
}
+bool LevelDB::Get(const std::string& key, bool* found, 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()) {
+ *found = true;
+ return true;
+ }
+ if (status.IsNotFound()) {
+ *found = false;
+ return true;
+ }
+
+ DLOG(WARNING) << "Failed loading leveldb_proto entry with key \"" << key
+ << "\": " << status.ToString();
+ return false;
+}
+
} // namespace leveldb_proto
« no previous file with comments | « components/leveldb_proto/leveldb_database.h ('k') | components/leveldb_proto/proto_database.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698