OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2013 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 CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_ |
| 6 #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/files/file_path.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/string16.h" |
| 13 #include "content/common/content_export.h" |
| 14 |
| 15 namespace leveldb { |
| 16 class Comparator; |
| 17 class DB; |
| 18 class Env; |
| 19 class Snapshot; |
| 20 } |
| 21 |
| 22 namespace content { |
| 23 |
| 24 class LevelDBComparator; |
| 25 class LevelDBDatabase; |
| 26 class LevelDBIterator; |
| 27 class LevelDBSlice; |
| 28 class LevelDBWriteBatch; |
| 29 |
| 30 class LevelDBSnapshot { |
| 31 private: |
| 32 friend class LevelDBDatabase; |
| 33 friend class LevelDBTransaction; |
| 34 |
| 35 explicit LevelDBSnapshot(LevelDBDatabase*); |
| 36 ~LevelDBSnapshot(); |
| 37 |
| 38 leveldb::DB* db_; |
| 39 const leveldb::Snapshot* snapshot_; |
| 40 }; |
| 41 |
| 42 class CONTENT_EXPORT LevelDBDatabase { |
| 43 public: |
| 44 static scoped_ptr<LevelDBDatabase> Open(const base::FilePath&, |
| 45 const LevelDBComparator*); |
| 46 static scoped_ptr<LevelDBDatabase> OpenInMemory(const LevelDBComparator*); |
| 47 static bool Destroy(const base::FilePath&); |
| 48 virtual ~LevelDBDatabase(); |
| 49 |
| 50 bool Put(const LevelDBSlice& key, const std::vector<char>& value); |
| 51 bool Remove(const LevelDBSlice& key); |
| 52 virtual bool Get(const LevelDBSlice& key, |
| 53 std::vector<char>& value, |
| 54 bool& found, |
| 55 const LevelDBSnapshot* = 0); |
| 56 bool Write(LevelDBWriteBatch&); |
| 57 scoped_ptr<LevelDBIterator> CreateIterator(const LevelDBSnapshot* = 0); |
| 58 const LevelDBComparator* Comparator() const; |
| 59 |
| 60 protected: |
| 61 LevelDBDatabase(); |
| 62 |
| 63 private: |
| 64 friend class LevelDBSnapshot; |
| 65 |
| 66 scoped_ptr<leveldb::Env> env_; |
| 67 scoped_ptr<leveldb::Comparator> comparator_adapter_; |
| 68 scoped_ptr<leveldb::DB> db_; |
| 69 const LevelDBComparator* comparator_; |
| 70 }; |
| 71 |
| 72 } // namespace content |
| 73 |
| 74 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_ |
OLD | NEW |