Cast: Skip receiver log messages with time delta that can't be encoded.
[chromium-blink-merge.git] / content / browser / indexed_db / leveldb / leveldb_database.h
blobd2f08697ee402a28a697f9e1bfbdbde485afc159
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.
5 #ifndef CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_
6 #define CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_
8 #include <string>
10 #include "base/files/file_path.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/strings/string16.h"
13 #include "base/strings/string_piece.h"
14 #include "content/common/content_export.h"
15 #include "third_party/leveldatabase/src/include/leveldb/status.h"
17 namespace leveldb {
18 class Comparator;
19 class DB;
20 class Env;
21 class Snapshot;
24 namespace content {
26 class LevelDBComparator;
27 class LevelDBDatabase;
28 class LevelDBIterator;
29 class LevelDBWriteBatch;
31 class LevelDBSnapshot {
32 private:
33 friend class LevelDBDatabase;
34 friend class LevelDBTransaction;
36 explicit LevelDBSnapshot(LevelDBDatabase* db);
37 ~LevelDBSnapshot();
39 leveldb::DB* db_;
40 const leveldb::Snapshot* snapshot_;
43 class CONTENT_EXPORT LevelDBLock {
44 public:
45 virtual ~LevelDBLock() {}
48 class CONTENT_EXPORT LevelDBDatabase {
49 public:
50 static leveldb::Status Open(const base::FilePath& file_name,
51 const LevelDBComparator* comparator,
52 scoped_ptr<LevelDBDatabase>* db,
53 bool* is_disk_full = 0);
54 static scoped_ptr<LevelDBDatabase> OpenInMemory(
55 const LevelDBComparator* comparator);
56 static leveldb::Status Destroy(const base::FilePath& file_name);
57 static scoped_ptr<LevelDBLock> LockForTesting(
58 const base::FilePath& file_name);
59 virtual ~LevelDBDatabase();
61 leveldb::Status Put(const base::StringPiece& key, std::string* value);
62 leveldb::Status Remove(const base::StringPiece& key);
63 virtual leveldb::Status Get(const base::StringPiece& key,
64 std::string* value,
65 bool* found,
66 const LevelDBSnapshot* = 0);
67 leveldb::Status Write(const LevelDBWriteBatch& write_batch);
68 scoped_ptr<LevelDBIterator> CreateIterator(const LevelDBSnapshot* = 0);
69 const LevelDBComparator* Comparator() const;
70 void Compact(const base::StringPiece& start, const base::StringPiece& stop);
72 protected:
73 LevelDBDatabase();
75 private:
76 friend class LevelDBSnapshot;
78 scoped_ptr<leveldb::Env> env_;
79 scoped_ptr<leveldb::Comparator> comparator_adapter_;
80 scoped_ptr<leveldb::DB> db_;
81 const LevelDBComparator* comparator_;
84 } // namespace content
86 #endif // CONTENT_BROWSER_INDEXED_DB_LEVELDB_LEVELDB_DATABASE_H_