OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/leveldb_proto/leveldb_database.h" | 5 #include "components/leveldb_proto/leveldb_database.h" |
6 | 6 |
7 #include <inttypes.h> | 7 #include <inttypes.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 leveldb::ReadOptions options; | 131 leveldb::ReadOptions options; |
132 std::unique_ptr<leveldb::Iterator> db_iterator(db_->NewIterator(options)); | 132 std::unique_ptr<leveldb::Iterator> db_iterator(db_->NewIterator(options)); |
133 for (db_iterator->SeekToFirst(); db_iterator->Valid(); db_iterator->Next()) { | 133 for (db_iterator->SeekToFirst(); db_iterator->Valid(); db_iterator->Next()) { |
134 leveldb::Slice value_slice = db_iterator->value(); | 134 leveldb::Slice value_slice = db_iterator->value(); |
135 std::string entry(value_slice.data(), value_slice.size()); | 135 std::string entry(value_slice.data(), value_slice.size()); |
136 entries->push_back(entry); | 136 entries->push_back(entry); |
137 } | 137 } |
138 return true; | 138 return true; |
139 } | 139 } |
140 | 140 |
| 141 bool LevelDB::LoadKeys(std::vector<std::string>* keys) { |
| 142 DFAKE_SCOPED_LOCK(thread_checker_); |
| 143 if (!db_) |
| 144 return false; |
| 145 |
| 146 leveldb::ReadOptions options; |
| 147 options.fill_cache = false; |
| 148 std::unique_ptr<leveldb::Iterator> db_iterator(db_->NewIterator(options)); |
| 149 for (db_iterator->SeekToFirst(); db_iterator->Valid(); db_iterator->Next()) { |
| 150 leveldb::Slice key_slice = db_iterator->key(); |
| 151 keys->push_back(std::string(key_slice.data(), key_slice.size())); |
| 152 } |
| 153 return true; |
| 154 } |
| 155 |
141 bool LevelDB::Get(const std::string& key, bool* found, std::string* entry) { | 156 bool LevelDB::Get(const std::string& key, bool* found, std::string* entry) { |
142 DFAKE_SCOPED_LOCK(thread_checker_); | 157 DFAKE_SCOPED_LOCK(thread_checker_); |
143 if (!db_) | 158 if (!db_) |
144 return false; | 159 return false; |
145 | 160 |
146 leveldb::ReadOptions options; | 161 leveldb::ReadOptions options; |
147 leveldb::Status status = db_->Get(options, key, entry); | 162 leveldb::Status status = db_->Get(options, key, entry); |
148 if (status.ok()) { | 163 if (status.ok()) { |
149 *found = true; | 164 *found = true; |
150 return true; | 165 return true; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 const char* system_allocator_pool_name = | 202 const char* system_allocator_pool_name = |
188 base::trace_event::MemoryDumpManager::GetInstance() | 203 base::trace_event::MemoryDumpManager::GetInstance() |
189 ->system_allocator_pool_name(); | 204 ->system_allocator_pool_name(); |
190 if (system_allocator_pool_name) | 205 if (system_allocator_pool_name) |
191 pmd->AddSuballocation(dump->guid(), system_allocator_pool_name); | 206 pmd->AddSuballocation(dump->guid(), system_allocator_pool_name); |
192 | 207 |
193 return true; | 208 return true; |
194 } | 209 } |
195 | 210 |
196 } // namespace leveldb_proto | 211 } // namespace leveldb_proto |
OLD | NEW |