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 <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
11 #include "base/files/file_util.h" | 11 #include "base/files/file_util.h" |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
14 #include "base/strings/string_split.h" | 13 #include "base/strings/string_split.h" |
15 #include "base/threading/thread_checker.h" | 14 #include "base/threading/thread_checker.h" |
16 #include "third_party/leveldatabase/env_chromium.h" | 15 #include "third_party/leveldatabase/env_chromium.h" |
17 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" | 16 #include "third_party/leveldatabase/src/helpers/memenv/memenv.h" |
18 #include "third_party/leveldatabase/src/include/leveldb/db.h" | 17 #include "third_party/leveldatabase/src/include/leveldb/db.h" |
19 #include "third_party/leveldatabase/src/include/leveldb/env.h" | 18 #include "third_party/leveldatabase/src/include/leveldb/env.h" |
20 #include "third_party/leveldatabase/src/include/leveldb/iterator.h" | 19 #include "third_party/leveldatabase/src/include/leveldb/iterator.h" |
21 #include "third_party/leveldatabase/src/include/leveldb/options.h" | 20 #include "third_party/leveldatabase/src/include/leveldb/options.h" |
22 #include "third_party/leveldatabase/src/include/leveldb/slice.h" | 21 #include "third_party/leveldatabase/src/include/leveldb/slice.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 << status.ToString(); | 107 << status.ToString(); |
109 return false; | 108 return false; |
110 } | 109 } |
111 | 110 |
112 bool LevelDB::Load(std::vector<std::string>* entries) { | 111 bool LevelDB::Load(std::vector<std::string>* entries) { |
113 DFAKE_SCOPED_LOCK(thread_checker_); | 112 DFAKE_SCOPED_LOCK(thread_checker_); |
114 if (!db_) | 113 if (!db_) |
115 return false; | 114 return false; |
116 | 115 |
117 leveldb::ReadOptions options; | 116 leveldb::ReadOptions options; |
118 scoped_ptr<leveldb::Iterator> db_iterator(db_->NewIterator(options)); | 117 std::unique_ptr<leveldb::Iterator> db_iterator(db_->NewIterator(options)); |
119 for (db_iterator->SeekToFirst(); db_iterator->Valid(); db_iterator->Next()) { | 118 for (db_iterator->SeekToFirst(); db_iterator->Valid(); db_iterator->Next()) { |
120 leveldb::Slice value_slice = db_iterator->value(); | 119 leveldb::Slice value_slice = db_iterator->value(); |
121 std::string entry(value_slice.data(), value_slice.size()); | 120 std::string entry(value_slice.data(), value_slice.size()); |
122 entries->push_back(entry); | 121 entries->push_back(entry); |
123 } | 122 } |
124 return true; | 123 return true; |
125 } | 124 } |
126 | 125 |
127 } // namespace leveldb_proto | 126 } // namespace leveldb_proto |
OLD | NEW |