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

Unified Diff: components/leveldb_proto/leveldb_database.cc

Issue 2379113002: Extended the ProtoDatabase to provide LoadKeys() functionality. (Closed)
Patch Set: minor cleanups Created 4 years, 3 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 6a8586f87059b0697cde433968e58676a9a77004..0b31e51c66146b10b69b57130006069798229339 100644
--- a/components/leveldb_proto/leveldb_database.cc
+++ b/components/leveldb_proto/leveldb_database.cc
@@ -123,6 +123,21 @@ bool LevelDB::Load(std::vector<std::string>* entries) {
return true;
}
+bool LevelDB::LoadKeys(std::vector<std::string>* keys) {
+ DFAKE_SCOPED_LOCK(thread_checker_);
+ if (!db_)
+ return false;
+
+ leveldb::ReadOptions options;
+ options.fill_cache = false;
+ std::unique_ptr<leveldb::Iterator> db_iterator(db_->NewIterator(options));
+ for (db_iterator->SeekToFirst(); db_iterator->Valid(); db_iterator->Next()) {
+ leveldb::Slice key_slice = db_iterator->key();
+ keys->push_back(std::string(key_slice.data(), key_slice.size()));
+ }
+ return true;
+}
+
bool LevelDB::Get(const std::string& key, bool* found, std::string* entry) {
DFAKE_SCOPED_LOCK(thread_checker_);
if (!db_)

Powered by Google App Engine
This is Rietveld 408576698