| 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 "base/rand_util.h" | 7 #include "base/rand_util.h" |
| 8 #include "components/leveldb/env_mojo.h" | 8 #include "components/leveldb/env_mojo.h" |
| 9 #include "components/leveldb/util.h" | 9 #include "components/leveldb/util.h" |
| 10 #include "mojo/common/common_type_converters.h" | 10 #include "mojo/common/common_type_converters.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 while ((new_id == 0) || (m.find(new_id) != m.end())) | 22 while ((new_id == 0) || (m.find(new_id) != m.end())) |
| 23 new_id = base::RandUint64(); | 23 new_id = base::RandUint64(); |
| 24 | 24 |
| 25 return new_id; | 25 return new_id; |
| 26 } | 26 } |
| 27 | 27 |
| 28 } // namespace | 28 } // namespace |
| 29 | 29 |
| 30 LevelDBDatabaseImpl::LevelDBDatabaseImpl( | 30 LevelDBDatabaseImpl::LevelDBDatabaseImpl( |
| 31 leveldb::LevelDBDatabaseRequest request, | 31 leveldb::LevelDBDatabaseRequest request, |
| 32 scoped_ptr<MojoEnv> environment, | 32 scoped_ptr<leveldb::Env> environment, |
| 33 scoped_ptr<leveldb::DB> db) | 33 scoped_ptr<leveldb::DB> db) |
| 34 : binding_(this, std::move(request)), | 34 : binding_(this, std::move(request)), |
| 35 environment_(std::move(environment)), | 35 environment_(std::move(environment)), |
| 36 db_(std::move(db)) {} | 36 db_(std::move(db)) {} |
| 37 | 37 |
| 38 LevelDBDatabaseImpl::~LevelDBDatabaseImpl() { | 38 LevelDBDatabaseImpl::~LevelDBDatabaseImpl() { |
| 39 for (auto& p : iterator_map_) | 39 for (auto& p : iterator_map_) |
| 40 delete p.second; | 40 delete p.second; |
| 41 for (auto& p : snapshot_map_) | 41 for (auto& p : snapshot_map_) |
| 42 db_->ReleaseSnapshot(p.second); | 42 db_->ReleaseSnapshot(p.second); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 callback.Run(DatabaseError::INVALID_ARGUMENT, mojo::Array<uint8_t>()); | 111 callback.Run(DatabaseError::INVALID_ARGUMENT, mojo::Array<uint8_t>()); |
| 112 | 112 |
| 113 std::string value; | 113 std::string value; |
| 114 leveldb::ReadOptions options; | 114 leveldb::ReadOptions options; |
| 115 options.snapshot = it->second; | 115 options.snapshot = it->second; |
| 116 leveldb::Status status = db_->Get(options, GetSliceFor(key), &value); | 116 leveldb::Status status = db_->Get(options, GetSliceFor(key), &value); |
| 117 callback.Run(LeveldbStatusToError(status), mojo::Array<uint8_t>::From(value)); | 117 callback.Run(LeveldbStatusToError(status), mojo::Array<uint8_t>::From(value)); |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace leveldb | 120 } // namespace leveldb |
| OLD | NEW |