Revert 268405 "Make sure that ScratchBuffer::Allocate() always r..."
[chromium-blink-merge.git] / content / browser / indexed_db / indexed_db_fake_backing_store.h
blob5c64370563f3ac6896ecd31104c0715f064c8f8e
1 // Copyright 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_INDEXED_DB_FAKE_BACKING_STORE_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_
8 #include <vector>
10 #include "content/browser/indexed_db/indexed_db_backing_store.h"
12 namespace base {
13 class TaskRunner;
16 namespace content {
18 class IndexedDBFactory;
20 class IndexedDBFakeBackingStore : public IndexedDBBackingStore {
21 public:
22 IndexedDBFakeBackingStore();
23 IndexedDBFakeBackingStore(IndexedDBFactory* factory,
24 base::TaskRunner* task_runner);
25 virtual std::vector<base::string16> GetDatabaseNames(leveldb::Status* s)
26 OVERRIDE;
27 virtual leveldb::Status GetIDBDatabaseMetaData(const base::string16& name,
28 IndexedDBDatabaseMetadata*,
29 bool* found) OVERRIDE;
30 virtual leveldb::Status CreateIDBDatabaseMetaData(
31 const base::string16& name,
32 const base::string16& version,
33 int64 int_version,
34 int64* row_id) OVERRIDE;
35 virtual bool UpdateIDBDatabaseIntVersion(Transaction*,
36 int64 row_id,
37 int64 version) OVERRIDE;
38 virtual leveldb::Status DeleteDatabase(const base::string16& name) OVERRIDE;
40 virtual leveldb::Status CreateObjectStore(Transaction*,
41 int64 database_id,
42 int64 object_store_id,
43 const base::string16& name,
44 const IndexedDBKeyPath&,
45 bool auto_increment) OVERRIDE;
47 virtual leveldb::Status ClearObjectStore(Transaction*,
48 int64 database_id,
49 int64 object_store_id) OVERRIDE;
50 virtual leveldb::Status DeleteRecord(Transaction*,
51 int64 database_id,
52 int64 object_store_id,
53 const RecordIdentifier&) OVERRIDE;
54 virtual leveldb::Status GetKeyGeneratorCurrentNumber(Transaction*,
55 int64 database_id,
56 int64 object_store_id,
57 int64* current_number)
58 OVERRIDE;
59 virtual leveldb::Status MaybeUpdateKeyGeneratorCurrentNumber(
60 Transaction*,
61 int64 database_id,
62 int64 object_store_id,
63 int64 new_number,
64 bool check_current) OVERRIDE;
65 virtual leveldb::Status KeyExistsInObjectStore(
66 Transaction*,
67 int64 database_id,
68 int64 object_store_id,
69 const IndexedDBKey&,
70 RecordIdentifier* found_record_identifier,
71 bool* found) OVERRIDE;
73 virtual leveldb::Status CreateIndex(Transaction*,
74 int64 database_id,
75 int64 object_store_id,
76 int64 index_id,
77 const base::string16& name,
78 const IndexedDBKeyPath&,
79 bool is_unique,
80 bool is_multi_entry) OVERRIDE;
81 virtual leveldb::Status DeleteIndex(Transaction*,
82 int64 database_id,
83 int64 object_store_id,
84 int64 index_id) OVERRIDE;
85 virtual leveldb::Status PutIndexDataForRecord(Transaction*,
86 int64 database_id,
87 int64 object_store_id,
88 int64 index_id,
89 const IndexedDBKey&,
90 const RecordIdentifier&)
91 OVERRIDE;
92 virtual void ReportBlobUnused(int64 database_id, int64 blob_key) OVERRIDE;
94 virtual scoped_ptr<Cursor> OpenObjectStoreKeyCursor(
95 Transaction* transaction,
96 int64 database_id,
97 int64 object_store_id,
98 const IndexedDBKeyRange& key_range,
99 indexed_db::CursorDirection,
100 leveldb::Status*) OVERRIDE;
101 virtual scoped_ptr<Cursor> OpenObjectStoreCursor(
102 Transaction* transaction,
103 int64 database_id,
104 int64 object_store_id,
105 const IndexedDBKeyRange& key_range,
106 indexed_db::CursorDirection,
107 leveldb::Status*) OVERRIDE;
108 virtual scoped_ptr<Cursor> OpenIndexKeyCursor(
109 Transaction* transaction,
110 int64 database_id,
111 int64 object_store_id,
112 int64 index_id,
113 const IndexedDBKeyRange& key_range,
114 indexed_db::CursorDirection,
115 leveldb::Status*) OVERRIDE;
116 virtual scoped_ptr<Cursor> OpenIndexCursor(Transaction* transaction,
117 int64 database_id,
118 int64 object_store_id,
119 int64 index_id,
120 const IndexedDBKeyRange& key_range,
121 indexed_db::CursorDirection,
122 leveldb::Status*) OVERRIDE;
124 class FakeTransaction : public IndexedDBBackingStore::Transaction {
125 public:
126 FakeTransaction(bool result);
127 virtual void Begin() OVERRIDE;
128 virtual leveldb::Status Commit() OVERRIDE;
129 virtual void Rollback() OVERRIDE;
131 private:
132 bool result_;
135 protected:
136 friend class base::RefCounted<IndexedDBFakeBackingStore>;
137 virtual ~IndexedDBFakeBackingStore();
140 } // namespace content
142 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_