Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1038)

Side by Side Diff: components/leveldb/leveldb_database_impl.h

Issue 1823813002: mojo leveldb: Add support to use in memory database. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: how did i miss that... Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/leveldb/leveldb_database_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef COMPONENTS_LEVELDB_LEVELDB_DATABASE_IMPL_H_ 5 #ifndef COMPONENTS_LEVELDB_LEVELDB_DATABASE_IMPL_H_
6 #define COMPONENTS_LEVELDB_LEVELDB_DATABASE_IMPL_H_ 6 #define COMPONENTS_LEVELDB_LEVELDB_DATABASE_IMPL_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "components/leveldb/public/interfaces/leveldb.mojom.h" 9 #include "components/leveldb/public/interfaces/leveldb.mojom.h"
10 #include "mojo/public/cpp/bindings/interface_request.h" 10 #include "mojo/public/cpp/bindings/interface_request.h"
11 #include "mojo/public/cpp/bindings/strong_binding.h" 11 #include "mojo/public/cpp/bindings/strong_binding.h"
12 #include "third_party/leveldatabase/src/include/leveldb/db.h" 12 #include "third_party/leveldatabase/src/include/leveldb/db.h"
13 13
14 namespace leveldb { 14 namespace leveldb {
15 15
16 class MojoEnv; 16 class MojoEnv;
17 17
18 // The backing to a database object that we pass to our called. 18 // The backing to a database object that we pass to our called.
19 class LevelDBDatabaseImpl : public LevelDBDatabase { 19 class LevelDBDatabaseImpl : public LevelDBDatabase {
20 public: 20 public:
21 LevelDBDatabaseImpl(leveldb::LevelDBDatabaseRequest request, 21 LevelDBDatabaseImpl(leveldb::LevelDBDatabaseRequest request,
22 scoped_ptr<MojoEnv> environment, 22 scoped_ptr<leveldb::Env> environment,
23 scoped_ptr<leveldb::DB> db); 23 scoped_ptr<leveldb::DB> db);
24 ~LevelDBDatabaseImpl() override; 24 ~LevelDBDatabaseImpl() override;
25 25
26 // Overridden from LevelDBDatabase: 26 // Overridden from LevelDBDatabase:
27 void Put(mojo::Array<uint8_t> key, 27 void Put(mojo::Array<uint8_t> key,
28 mojo::Array<uint8_t> value, 28 mojo::Array<uint8_t> value,
29 const PutCallback& callback) override; 29 const PutCallback& callback) override;
30 void Delete(mojo::Array<uint8_t> key, 30 void Delete(mojo::Array<uint8_t> key,
31 const DeleteCallback& callback) override; 31 const DeleteCallback& callback) override;
32 void Write(mojo::Array<BatchedOperationPtr> operations, 32 void Write(mojo::Array<BatchedOperationPtr> operations,
33 const WriteCallback& callback) override; 33 const WriteCallback& callback) override;
34 void Get(mojo::Array<uint8_t> key, const GetCallback& callback) override; 34 void Get(mojo::Array<uint8_t> key, const GetCallback& callback) override;
35 void GetSnapshot(const GetSnapshotCallback& callback) override; 35 void GetSnapshot(const GetSnapshotCallback& callback) override;
36 void ReleaseSnapshot(uint64_t snapshot_id) override; 36 void ReleaseSnapshot(uint64_t snapshot_id) override;
37 void GetFromSnapshot(uint64_t snapshot_id, 37 void GetFromSnapshot(uint64_t snapshot_id,
38 mojo::Array<uint8_t> key, 38 mojo::Array<uint8_t> key,
39 const GetCallback& callback) override; 39 const GetCallback& callback) override;
40 40
41 private: 41 private:
42 mojo::StrongBinding<LevelDBDatabase> binding_; 42 mojo::StrongBinding<LevelDBDatabase> binding_;
43 scoped_ptr<MojoEnv> environment_; 43 scoped_ptr<leveldb::Env> environment_;
44 scoped_ptr<leveldb::DB> db_; 44 scoped_ptr<leveldb::DB> db_;
45 45
46 std::map<uint64_t, const Snapshot*> snapshot_map_; 46 std::map<uint64_t, const Snapshot*> snapshot_map_;
47 47
48 // TODO(erg): If we have an existing iterator which depends on a snapshot, 48 // TODO(erg): If we have an existing iterator which depends on a snapshot,
49 // and delete the snapshot from the client side, that shouldn't delete the 49 // and delete the snapshot from the client side, that shouldn't delete the
50 // snapshot maybe? At worse it's a DDoS if there's multiple users of the 50 // snapshot maybe? At worse it's a DDoS if there's multiple users of the
51 // system, but this maybe should be fixed... 51 // system, but this maybe should be fixed...
52 52
53 std::map<uint64_t, Iterator*> iterator_map_; 53 std::map<uint64_t, Iterator*> iterator_map_;
54 54
55 DISALLOW_COPY_AND_ASSIGN(LevelDBDatabaseImpl); 55 DISALLOW_COPY_AND_ASSIGN(LevelDBDatabaseImpl);
56 }; 56 };
57 57
58 } // namespace leveldb 58 } // namespace leveldb
59 59
60 #endif // COMPONENTS_LEVELDB_LEVELDB_DATABASE_IMPL_H_ 60 #endif // COMPONENTS_LEVELDB_LEVELDB_DATABASE_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | components/leveldb/leveldb_database_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698