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

Unified Diff: components/leveldb/public/cpp/remote_iterator.h

Issue 1861903002: mojo leveldb: Add an iteration interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + comments Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/leveldb/public/cpp/BUILD.gn ('k') | components/leveldb/public/cpp/remote_iterator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/leveldb/public/cpp/remote_iterator.h
diff --git a/components/leveldb/public/cpp/remote_iterator.h b/components/leveldb/public/cpp/remote_iterator.h
new file mode 100644
index 0000000000000000000000000000000000000000..056a2bf96cfa16d52550c6e6a56dbebd794abbc9
--- /dev/null
+++ b/components/leveldb/public/cpp/remote_iterator.h
@@ -0,0 +1,50 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef COMPONENTS_LEVELDB_PUBLIC_CPP_REMOTE_ITERATOR_H_
+#define COMPONENTS_LEVELDB_PUBLIC_CPP_REMOTE_ITERATOR_H_
+
+#include "components/leveldb/public/interfaces/leveldb.mojom.h"
+#include "mojo/public/cpp/bindings/array.h"
+#include "third_party/leveldatabase/src/include/leveldb/iterator.h"
+
+namespace leveldb {
+
+class LevelDBDatabase;
+
+// A wrapper around the raw iterator movement methods on the mojo leveldb
+// interface to allow drop in replacement to current leveldb usage.
+//
+// Note: Next(), Prev() and all the Seek*() calls cause mojo sync calls.
+class RemoteIterator : public Iterator {
+ public:
+ RemoteIterator(LevelDBDatabase* database, uint64_t iterator_id);
+ ~RemoteIterator() override;
+
+ // Overridden from leveldb::Iterator:
+ bool Valid() const override;
+ void SeekToFirst() override;
+ void SeekToLast() override;
+ void Seek(const Slice& target) override;
+ void Next() override;
+ void Prev() override;
+ Slice key() const override;
+ Slice value() const override;
+ Status status() const override;
+
+ private:
+ LevelDBDatabase* database_;
+ uint64_t iterator_id_;
+
+ bool valid_;
+ DatabaseError status_;
+ mojo::Array<uint8_t> key_;
+ mojo::Array<uint8_t> value_;
+
+ DISALLOW_COPY_AND_ASSIGN(RemoteIterator);
+};
+
+} // namespace leveldb
+
+#endif // COMPONENTS_LEVELDB_PUBLIC_CPP_REMOTE_ITERATOR_H_
« no previous file with comments | « components/leveldb/public/cpp/BUILD.gn ('k') | components/leveldb/public/cpp/remote_iterator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698