| 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/optional.h" | 10 #include "base/optional.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 if (!it->key().starts_with(key_prefix)) | 39 if (!it->key().starts_with(key_prefix)) |
| 40 break; | 40 break; |
| 41 function(it->key(), it->value()); | 41 function(it->key(), it->value()); |
| 42 } | 42 } |
| 43 return it->status(); | 43 return it->status(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 } // namespace | 46 } // namespace |
| 47 | 47 |
| 48 LevelDBDatabaseImpl::LevelDBDatabaseImpl( | 48 LevelDBDatabaseImpl::LevelDBDatabaseImpl( |
| 49 leveldb::mojom::LevelDBDatabaseRequest request, | |
| 50 std::unique_ptr<leveldb::Env> environment, | 49 std::unique_ptr<leveldb::Env> environment, |
| 51 std::unique_ptr<leveldb::DB> db) | 50 std::unique_ptr<leveldb::DB> db) |
| 52 : binding_(this, std::move(request)), | 51 : environment_(std::move(environment)), db_(std::move(db)) {} |
| 53 environment_(std::move(environment)), | |
| 54 db_(std::move(db)) {} | |
| 55 | 52 |
| 56 LevelDBDatabaseImpl::~LevelDBDatabaseImpl() { | 53 LevelDBDatabaseImpl::~LevelDBDatabaseImpl() { |
| 57 for (auto& p : iterator_map_) | 54 for (auto& p : iterator_map_) |
| 58 delete p.second; | 55 delete p.second; |
| 59 for (auto& p : snapshot_map_) | 56 for (auto& p : snapshot_map_) |
| 60 db_->ReleaseSnapshot(p.second); | 57 db_->ReleaseSnapshot(p.second); |
| 61 } | 58 } |
| 62 | 59 |
| 63 void LevelDBDatabaseImpl::Put(const std::vector<uint8_t>& key, | 60 void LevelDBDatabaseImpl::Put(const std::vector<uint8_t>& key, |
| 64 const std::vector<uint8_t>& value, | 61 const std::vector<uint8_t>& value, |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 const leveldb::Slice& key_prefix, | 294 const leveldb::Slice& key_prefix, |
| 298 leveldb::WriteBatch* batch) { | 295 leveldb::WriteBatch* batch) { |
| 299 leveldb::Status status = ForEachWithPrefix(db_.get(), key_prefix, | 296 leveldb::Status status = ForEachWithPrefix(db_.get(), key_prefix, |
| 300 [batch](const leveldb::Slice& key, const leveldb::Slice& value) { | 297 [batch](const leveldb::Slice& key, const leveldb::Slice& value) { |
| 301 batch->Delete(key); | 298 batch->Delete(key); |
| 302 }); | 299 }); |
| 303 return status; | 300 return status; |
| 304 } | 301 } |
| 305 | 302 |
| 306 } // namespace leveldb | 303 } // namespace leveldb |
| OLD | NEW |