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 15 matching lines...) Expand all Loading... |
26 } | 26 } |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 LevelDBDatabaseImpl::LevelDBDatabaseImpl( | 30 LevelDBDatabaseImpl::LevelDBDatabaseImpl( |
31 mojo::InterfaceRequest<LevelDBDatabase> request, | 31 mojo::InterfaceRequest<LevelDBDatabase> request, |
32 scoped_ptr<MojoEnv> environment, | 32 scoped_ptr<MojoEnv> 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 |
38 LevelDBDatabaseImpl::~LevelDBDatabaseImpl() { | 39 LevelDBDatabaseImpl::~LevelDBDatabaseImpl() { |
39 for (auto& p : iterator_map_) | 40 for (auto& p : iterator_map_) |
40 delete p.second; | 41 delete p.second; |
41 for (auto& p : snapshot_map_) | 42 for (auto& p : snapshot_map_) |
42 db_->ReleaseSnapshot(p.second); | 43 db_->ReleaseSnapshot(p.second); |
43 } | 44 } |
44 | 45 |
45 void LevelDBDatabaseImpl::Put(mojo::Array<uint8_t> key, | 46 void LevelDBDatabaseImpl::Put(mojo::Array<uint8_t> key, |
46 mojo::Array<uint8_t> value, | 47 mojo::Array<uint8_t> value, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 callback.Run(DatabaseError::INVALID_ARGUMENT, mojo::Array<uint8_t>()); | 112 callback.Run(DatabaseError::INVALID_ARGUMENT, mojo::Array<uint8_t>()); |
112 | 113 |
113 std::string value; | 114 std::string value; |
114 leveldb::ReadOptions options; | 115 leveldb::ReadOptions options; |
115 options.snapshot = it->second; | 116 options.snapshot = it->second; |
116 leveldb::Status status = db_->Get(options, GetSliceFor(key), &value); | 117 leveldb::Status status = db_->Get(options, GetSliceFor(key), &value); |
117 callback.Run(LeveldbStatusToError(status), mojo::Array<uint8_t>::From(value)); | 118 callback.Run(LeveldbStatusToError(status), mojo::Array<uint8_t>::From(value)); |
118 } | 119 } |
119 | 120 |
120 } // namespace leveldb | 121 } // namespace leveldb |
OLD | NEW |