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

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

Issue 2285623002: [Leveldb] Use std::{string,vector} instead of mojo::{String,Array}. (Closed)
Patch Set: Address comments from Yuzhu Created 4 years, 3 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 | « components/leveldb/BUILD.gn ('k') | 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 <memory> 8 #include <memory>
9 9
10 #include "components/leveldb/public/interfaces/leveldb.mojom.h" 10 #include "components/leveldb/public/interfaces/leveldb.mojom.h"
11 #include "mojo/public/cpp/bindings/interface_request.h" 11 #include "mojo/public/cpp/bindings/interface_request.h"
12 #include "mojo/public/cpp/bindings/strong_binding.h" 12 #include "mojo/public/cpp/bindings/strong_binding.h"
13 #include "third_party/leveldatabase/src/include/leveldb/db.h" 13 #include "third_party/leveldatabase/src/include/leveldb/db.h"
14 14
15 namespace leveldb { 15 namespace leveldb {
16 16
17 class MojoEnv; 17 class MojoEnv;
18 18
19 // The backing to a database object that we pass to our called. 19 // The backing to a database object that we pass to our called.
20 class LevelDBDatabaseImpl : public mojom::LevelDBDatabase { 20 class LevelDBDatabaseImpl : public mojom::LevelDBDatabase {
21 public: 21 public:
22 LevelDBDatabaseImpl(leveldb::mojom::LevelDBDatabaseRequest request, 22 LevelDBDatabaseImpl(leveldb::mojom::LevelDBDatabaseRequest request,
23 std::unique_ptr<leveldb::Env> environment, 23 std::unique_ptr<leveldb::Env> environment,
24 std::unique_ptr<leveldb::DB> db); 24 std::unique_ptr<leveldb::DB> db);
25 ~LevelDBDatabaseImpl() override; 25 ~LevelDBDatabaseImpl() override;
26 26
27 // Overridden from LevelDBDatabase: 27 // Overridden from LevelDBDatabase:
28 void Put(mojo::Array<uint8_t> key, 28 void Put(const std::vector<uint8_t>& key,
29 mojo::Array<uint8_t> value, 29 const std::vector<uint8_t>& value,
30 const PutCallback& callback) override; 30 const PutCallback& callback) override;
31 void Delete(mojo::Array<uint8_t> key, 31 void Delete(const std::vector<uint8_t>& key,
32 const DeleteCallback& callback) override; 32 const DeleteCallback& callback) override;
33 void DeletePrefixed(mojo::Array<uint8_t> key_prefix, 33 void DeletePrefixed(const std::vector<uint8_t>& key_prefix,
34 const DeletePrefixedCallback& callback) override; 34 const DeletePrefixedCallback& callback) override;
35 void Write(mojo::Array<mojom::BatchedOperationPtr> operations, 35 void Write(std::vector<mojom::BatchedOperationPtr> operations,
36 const WriteCallback& callback) override; 36 const WriteCallback& callback) override;
37 void Get(mojo::Array<uint8_t> key, const GetCallback& callback) override; 37 void Get(const std::vector<uint8_t>& key,
38 void GetPrefixed(mojo::Array<uint8_t> key_prefix, 38 const GetCallback& callback) override;
39 void GetPrefixed(const std::vector<uint8_t>& key_prefix,
39 const GetPrefixedCallback& callback) override; 40 const GetPrefixedCallback& callback) override;
40 void GetSnapshot(const GetSnapshotCallback& callback) override; 41 void GetSnapshot(const GetSnapshotCallback& callback) override;
41 void ReleaseSnapshot(uint64_t snapshot_id) override; 42 void ReleaseSnapshot(uint64_t snapshot_id) override;
42 void GetFromSnapshot(uint64_t snapshot_id, 43 void GetFromSnapshot(uint64_t snapshot_id,
43 mojo::Array<uint8_t> key, 44 const std::vector<uint8_t>& key,
44 const GetCallback& callback) override; 45 const GetCallback& callback) override;
45 void NewIterator(const NewIteratorCallback& callback) override; 46 void NewIterator(const NewIteratorCallback& callback) override;
46 void NewIteratorFromSnapshot(uint64_t snapshot_id, 47 void NewIteratorFromSnapshot(uint64_t snapshot_id,
47 const NewIteratorCallback& callback) override; 48 const NewIteratorCallback& callback) override;
48 void ReleaseIterator(uint64_t iterator_id) override; 49 void ReleaseIterator(uint64_t iterator_id) override;
49 void IteratorSeekToFirst( 50 void IteratorSeekToFirst(
50 uint64_t iterator_id, 51 uint64_t iterator_id,
51 const IteratorSeekToFirstCallback& callback) override; 52 const IteratorSeekToFirstCallback& callback) override;
52 void IteratorSeekToLast(uint64_t iterator_id, 53 void IteratorSeekToLast(uint64_t iterator_id,
53 const IteratorSeekToLastCallback& callback) override; 54 const IteratorSeekToLastCallback& callback) override;
54 void IteratorSeek(uint64_t iterator_id, 55 void IteratorSeek(uint64_t iterator_id,
55 mojo::Array<uint8_t> target, 56 const std::vector<uint8_t>& target,
56 const IteratorSeekToLastCallback& callback) override; 57 const IteratorSeekToLastCallback& callback) override;
57 void IteratorNext(uint64_t iterator_id, 58 void IteratorNext(uint64_t iterator_id,
58 const IteratorNextCallback& callback) override; 59 const IteratorNextCallback& callback) override;
59 void IteratorPrev(uint64_t iterator_id, 60 void IteratorPrev(uint64_t iterator_id,
60 const IteratorPrevCallback& callback) override; 61 const IteratorPrevCallback& callback) override;
61 62
62 private: 63 private:
63 // Returns the state of |it| to a caller. Note: This assumes that all the 64 // Returns the state of |it| to a caller. Note: This assumes that all the
64 // iterator movement methods have the same callback signature. We don't 65 // iterator movement methods have the same callback signature. We don't
65 // directly reference the underlying type in case of bindings change. 66 // directly reference the underlying type in case of bindings change.
(...skipping 15 matching lines...) Expand all
81 // system, but this maybe should be fixed... 82 // system, but this maybe should be fixed...
82 83
83 std::map<uint64_t, Iterator*> iterator_map_; 84 std::map<uint64_t, Iterator*> iterator_map_;
84 85
85 DISALLOW_COPY_AND_ASSIGN(LevelDBDatabaseImpl); 86 DISALLOW_COPY_AND_ASSIGN(LevelDBDatabaseImpl);
86 }; 87 };
87 88
88 } // namespace leveldb 89 } // namespace leveldb
89 90
90 #endif // COMPONENTS_LEVELDB_LEVELDB_DATABASE_IMPL_H_ 91 #endif // COMPONENTS_LEVELDB_LEVELDB_DATABASE_IMPL_H_
OLDNEW
« no previous file with comments | « components/leveldb/BUILD.gn ('k') | components/leveldb/leveldb_database_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698