OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/leveldb_database_impl.h" | 5 #include "components/leveldb/leveldb_database_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 while ((new_id == 0) || (m.find(new_id) != m.end())) | 25 while ((new_id == 0) || (m.find(new_id) != m.end())) |
26 new_id = base::RandUint64(); | 26 new_id = base::RandUint64(); |
27 | 27 |
28 return new_id; | 28 return new_id; |
29 } | 29 } |
30 | 30 |
31 } // namespace | 31 } // namespace |
32 | 32 |
33 LevelDBDatabaseImpl::LevelDBDatabaseImpl( | 33 LevelDBDatabaseImpl::LevelDBDatabaseImpl( |
34 leveldb::LevelDBDatabaseRequest request, | 34 leveldb::LevelDBDatabaseRequest request, |
35 scoped_ptr<leveldb::Env> environment, | 35 std::unique_ptr<leveldb::Env> environment, |
36 scoped_ptr<leveldb::DB> db) | 36 std::unique_ptr<leveldb::DB> db) |
37 : binding_(this, std::move(request)), | 37 : binding_(this, std::move(request)), |
38 environment_(std::move(environment)), | 38 environment_(std::move(environment)), |
39 db_(std::move(db)) {} | 39 db_(std::move(db)) {} |
40 | 40 |
41 LevelDBDatabaseImpl::~LevelDBDatabaseImpl() { | 41 LevelDBDatabaseImpl::~LevelDBDatabaseImpl() { |
42 for (auto& p : iterator_map_) | 42 for (auto& p : iterator_map_) |
43 delete p.second; | 43 delete p.second; |
44 for (auto& p : snapshot_map_) | 44 for (auto& p : snapshot_map_) |
45 db_->ReleaseSnapshot(p.second); | 45 db_->ReleaseSnapshot(p.second); |
46 } | 46 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 if (!it->Valid()) { | 231 if (!it->Valid()) { |
232 callback.Run(false, LeveldbStatusToError(it->status()), nullptr, nullptr); | 232 callback.Run(false, LeveldbStatusToError(it->status()), nullptr, nullptr); |
233 return; | 233 return; |
234 } | 234 } |
235 | 235 |
236 callback.Run(true, LeveldbStatusToError(it->status()), GetArrayFor(it->key()), | 236 callback.Run(true, LeveldbStatusToError(it->status()), GetArrayFor(it->key()), |
237 GetArrayFor(it->value())); | 237 GetArrayFor(it->value())); |
238 } | 238 } |
239 | 239 |
240 } // namespace leveldb | 240 } // namespace leveldb |
OLD | NEW |