| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_LEVELDB_PUBLIC_CPP_REMOTE_ITERATOR_H_ |
| 6 #define COMPONENTS_LEVELDB_PUBLIC_CPP_REMOTE_ITERATOR_H_ |
| 7 |
| 8 #include "components/leveldb/public/interfaces/leveldb.mojom.h" |
| 9 #include "mojo/public/cpp/bindings/array.h" |
| 10 #include "third_party/leveldatabase/src/include/leveldb/iterator.h" |
| 11 |
| 12 namespace leveldb { |
| 13 |
| 14 class LevelDBDatabase; |
| 15 |
| 16 // A wrapper around the raw iterator movement methods on the mojo leveldb |
| 17 // interface to allow drop in replacement to current leveldb usage. |
| 18 // |
| 19 // Note: Next(), Prev() and all the Seek*() calls cause mojo sync calls. |
| 20 class RemoteIterator : public Iterator { |
| 21 public: |
| 22 RemoteIterator(LevelDBDatabase* database, uint64_t iterator_id); |
| 23 ~RemoteIterator() override; |
| 24 |
| 25 // Overridden from leveldb::Iterator: |
| 26 bool Valid() const override; |
| 27 void SeekToFirst() override; |
| 28 void SeekToLast() override; |
| 29 void Seek(const Slice& target) override; |
| 30 void Next() override; |
| 31 void Prev() override; |
| 32 Slice key() const override; |
| 33 Slice value() const override; |
| 34 Status status() const override; |
| 35 |
| 36 private: |
| 37 LevelDBDatabase* database_; |
| 38 uint64_t iterator_id_; |
| 39 |
| 40 bool valid_; |
| 41 DatabaseError status_; |
| 42 mojo::Array<uint8_t> key_; |
| 43 mojo::Array<uint8_t> value_; |
| 44 |
| 45 DISALLOW_COPY_AND_ASSIGN(RemoteIterator); |
| 46 }; |
| 47 |
| 48 } // namespace leveldb |
| 49 |
| 50 #endif // COMPONENTS_LEVELDB_PUBLIC_CPP_REMOTE_ITERATOR_H_ |
| OLD | NEW |