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

Unified Diff: components/leveldb_proto/leveldb_database.cc

Issue 2379113002: Extended the ProtoDatabase to provide LoadKeys() functionality. (Closed)
Patch Set: Garbage Collect orphaned images on service start-up. Created 4 years, 2 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 0dfb5e3654bde26def296914425eae1d3c7db87e..5769710cb170a517364e92289b4e9aa701092aea 100644
--- a/components/leveldb_proto/leveldb_database.cc
+++ b/components/leveldb_proto/leveldb_database.cc
@@ -138,6 +138,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_)
« 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