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"
13 class SequencedTaskRunner
;
18 class IndexedDBFactory
;
20 class IndexedDBFakeBackingStore
: public IndexedDBBackingStore
{
22 IndexedDBFakeBackingStore();
23 IndexedDBFakeBackingStore(IndexedDBFactory
* factory
,
24 base::SequencedTaskRunner
* 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
DeleteObjectStore(Transaction
* transaction
,
49 int64 object_store_id
) OVERRIDE
;
51 virtual leveldb::Status
PutRecord(
52 IndexedDBBackingStore::Transaction
* transaction
,
54 int64 object_store_id
,
55 const IndexedDBKey
& key
,
56 IndexedDBValue
* value
,
57 ScopedVector
<storage::BlobDataHandle
>* handles
,
58 RecordIdentifier
* record
) OVERRIDE
;
60 virtual leveldb::Status
ClearObjectStore(Transaction
*,
62 int64 object_store_id
) OVERRIDE
;
63 virtual leveldb::Status
DeleteRecord(Transaction
*,
65 int64 object_store_id
,
66 const RecordIdentifier
&) OVERRIDE
;
67 virtual leveldb::Status
GetKeyGeneratorCurrentNumber(Transaction
*,
69 int64 object_store_id
,
70 int64
* current_number
)
72 virtual leveldb::Status
MaybeUpdateKeyGeneratorCurrentNumber(
75 int64 object_store_id
,
77 bool check_current
) OVERRIDE
;
78 virtual leveldb::Status
KeyExistsInObjectStore(
81 int64 object_store_id
,
83 RecordIdentifier
* found_record_identifier
,
84 bool* found
) OVERRIDE
;
86 virtual leveldb::Status
CreateIndex(Transaction
*,
88 int64 object_store_id
,
90 const base::string16
& name
,
91 const IndexedDBKeyPath
&,
93 bool is_multi_entry
) OVERRIDE
;
94 virtual leveldb::Status
DeleteIndex(Transaction
*,
96 int64 object_store_id
,
97 int64 index_id
) OVERRIDE
;
98 virtual leveldb::Status
PutIndexDataForRecord(Transaction
*,
100 int64 object_store_id
,
103 const RecordIdentifier
&)
105 virtual void ReportBlobUnused(int64 database_id
, int64 blob_key
) OVERRIDE
;
106 virtual scoped_ptr
<Cursor
> OpenObjectStoreKeyCursor(
107 Transaction
* transaction
,
109 int64 object_store_id
,
110 const IndexedDBKeyRange
& key_range
,
111 blink::WebIDBCursorDirection
,
112 leveldb::Status
*) OVERRIDE
;
113 virtual scoped_ptr
<Cursor
> OpenObjectStoreCursor(
114 Transaction
* transaction
,
116 int64 object_store_id
,
117 const IndexedDBKeyRange
& key_range
,
118 blink::WebIDBCursorDirection
,
119 leveldb::Status
*) OVERRIDE
;
120 virtual scoped_ptr
<Cursor
> OpenIndexKeyCursor(
121 Transaction
* transaction
,
123 int64 object_store_id
,
125 const IndexedDBKeyRange
& key_range
,
126 blink::WebIDBCursorDirection
,
127 leveldb::Status
*) OVERRIDE
;
128 virtual scoped_ptr
<Cursor
> OpenIndexCursor(Transaction
* transaction
,
130 int64 object_store_id
,
132 const IndexedDBKeyRange
& key_range
,
133 blink::WebIDBCursorDirection
,
134 leveldb::Status
*) OVERRIDE
;
136 class FakeTransaction
: public IndexedDBBackingStore::Transaction
{
138 explicit FakeTransaction(leveldb::Status phase_two_result
);
139 virtual void Begin() OVERRIDE
;
140 virtual leveldb::Status
CommitPhaseOne(
141 scoped_refptr
<BlobWriteCallback
>) OVERRIDE
;
142 virtual leveldb::Status
CommitPhaseTwo() OVERRIDE
;
143 virtual void Rollback() OVERRIDE
;
146 leveldb::Status result_
;
148 DISALLOW_COPY_AND_ASSIGN(FakeTransaction
);
152 friend class base::RefCounted
<IndexedDBFakeBackingStore
>;
153 virtual ~IndexedDBFakeBackingStore();
156 DISALLOW_COPY_AND_ASSIGN(IndexedDBFakeBackingStore
);
159 } // namespace content
161 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_