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_
10 #include "content/browser/indexed_db/indexed_db_backing_store.h"
18 class IndexedDBFactory
;
20 class IndexedDBFakeBackingStore
: public IndexedDBBackingStore
{
22 IndexedDBFakeBackingStore();
23 IndexedDBFakeBackingStore(IndexedDBFactory
* factory
,
24 base::TaskRunner
* task_runner
);
25 virtual std::vector
<base::string16
> GetDatabaseNames(leveldb::Status
* s
)
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
,
34 int64
* row_id
) OVERRIDE
;
35 virtual bool UpdateIDBDatabaseIntVersion(Transaction
*,
37 int64 version
) OVERRIDE
;
38 virtual leveldb::Status
DeleteDatabase(const base::string16
& name
) OVERRIDE
;
40 virtual leveldb::Status
CreateObjectStore(Transaction
*,
42 int64 object_store_id
,
43 const base::string16
& name
,
44 const IndexedDBKeyPath
&,
45 bool auto_increment
) OVERRIDE
;
47 virtual leveldb::Status
ClearObjectStore(Transaction
*,
49 int64 object_store_id
) OVERRIDE
;
50 virtual leveldb::Status
DeleteRecord(Transaction
*,
52 int64 object_store_id
,
53 const RecordIdentifier
&) OVERRIDE
;
54 virtual leveldb::Status
GetKeyGeneratorCurrentNumber(Transaction
*,
56 int64 object_store_id
,
57 int64
* current_number
)
59 virtual leveldb::Status
MaybeUpdateKeyGeneratorCurrentNumber(
62 int64 object_store_id
,
64 bool check_current
) OVERRIDE
;
65 virtual leveldb::Status
KeyExistsInObjectStore(
68 int64 object_store_id
,
70 RecordIdentifier
* found_record_identifier
,
71 bool* found
) OVERRIDE
;
73 virtual leveldb::Status
CreateIndex(Transaction
*,
75 int64 object_store_id
,
77 const base::string16
& name
,
78 const IndexedDBKeyPath
&,
80 bool is_multi_entry
) OVERRIDE
;
81 virtual leveldb::Status
DeleteIndex(Transaction
*,
83 int64 object_store_id
,
84 int64 index_id
) OVERRIDE
;
85 virtual leveldb::Status
PutIndexDataForRecord(Transaction
*,
87 int64 object_store_id
,
90 const RecordIdentifier
&)
92 virtual void ReportBlobUnused(int64 database_id
, int64 blob_key
) OVERRIDE
;
94 virtual scoped_ptr
<Cursor
> OpenObjectStoreKeyCursor(
95 Transaction
* transaction
,
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
,
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
,
111 int64 object_store_id
,
113 const IndexedDBKeyRange
& key_range
,
114 indexed_db::CursorDirection
,
115 leveldb::Status
*) OVERRIDE
;
116 virtual scoped_ptr
<Cursor
> OpenIndexCursor(Transaction
* transaction
,
118 int64 object_store_id
,
120 const IndexedDBKeyRange
& key_range
,
121 indexed_db::CursorDirection
,
122 leveldb::Status
*) OVERRIDE
;
124 class FakeTransaction
: public IndexedDBBackingStore::Transaction
{
126 FakeTransaction(bool result
);
127 virtual void Begin() OVERRIDE
;
128 virtual leveldb::Status
Commit() OVERRIDE
;
129 virtual void Rollback() OVERRIDE
;
136 friend class base::RefCounted
<IndexedDBFakeBackingStore
>;
137 virtual ~IndexedDBFakeBackingStore();
140 } // namespace content
142 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_