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 std::vector
<base::string16
> GetDatabaseNames(leveldb::Status
* s
) override
;
26 leveldb::Status
GetIDBDatabaseMetaData(const base::string16
& name
,
27 IndexedDBDatabaseMetadata
*,
28 bool* found
) override
;
29 leveldb::Status
CreateIDBDatabaseMetaData(const base::string16
& name
,
30 const base::string16
& version
,
32 int64
* row_id
) override
;
33 bool UpdateIDBDatabaseIntVersion(Transaction
*,
35 int64 version
) override
;
36 leveldb::Status
DeleteDatabase(const base::string16
& name
) override
;
38 leveldb::Status
CreateObjectStore(Transaction
*,
40 int64 object_store_id
,
41 const base::string16
& name
,
42 const IndexedDBKeyPath
&,
43 bool auto_increment
) override
;
45 leveldb::Status
DeleteObjectStore(Transaction
* transaction
,
47 int64 object_store_id
) override
;
49 leveldb::Status
PutRecord(IndexedDBBackingStore::Transaction
* transaction
,
51 int64 object_store_id
,
52 const IndexedDBKey
& key
,
53 IndexedDBValue
* value
,
54 ScopedVector
<storage::BlobDataHandle
>* handles
,
55 RecordIdentifier
* record
) override
;
57 leveldb::Status
ClearObjectStore(Transaction
*,
59 int64 object_store_id
) override
;
60 leveldb::Status
DeleteRecord(Transaction
*,
62 int64 object_store_id
,
63 const RecordIdentifier
&) override
;
64 leveldb::Status
GetKeyGeneratorCurrentNumber(Transaction
*,
66 int64 object_store_id
,
67 int64
* current_number
) override
;
68 leveldb::Status
MaybeUpdateKeyGeneratorCurrentNumber(
71 int64 object_store_id
,
73 bool check_current
) override
;
74 leveldb::Status
KeyExistsInObjectStore(
77 int64 object_store_id
,
79 RecordIdentifier
* found_record_identifier
,
80 bool* found
) override
;
82 leveldb::Status
CreateIndex(Transaction
*,
84 int64 object_store_id
,
86 const base::string16
& name
,
87 const IndexedDBKeyPath
&,
89 bool is_multi_entry
) override
;
90 leveldb::Status
DeleteIndex(Transaction
*,
92 int64 object_store_id
,
93 int64 index_id
) override
;
94 leveldb::Status
PutIndexDataForRecord(Transaction
*,
96 int64 object_store_id
,
99 const RecordIdentifier
&) override
;
100 void ReportBlobUnused(int64 database_id
, int64 blob_key
) override
;
101 scoped_ptr
<Cursor
> OpenObjectStoreKeyCursor(
102 Transaction
* transaction
,
104 int64 object_store_id
,
105 const IndexedDBKeyRange
& key_range
,
106 blink::WebIDBCursorDirection
,
107 leveldb::Status
*) override
;
108 scoped_ptr
<Cursor
> OpenObjectStoreCursor(Transaction
* transaction
,
110 int64 object_store_id
,
111 const IndexedDBKeyRange
& key_range
,
112 blink::WebIDBCursorDirection
,
113 leveldb::Status
*) override
;
114 scoped_ptr
<Cursor
> OpenIndexKeyCursor(Transaction
* transaction
,
116 int64 object_store_id
,
118 const IndexedDBKeyRange
& key_range
,
119 blink::WebIDBCursorDirection
,
120 leveldb::Status
*) override
;
121 scoped_ptr
<Cursor
> OpenIndexCursor(Transaction
* transaction
,
123 int64 object_store_id
,
125 const IndexedDBKeyRange
& key_range
,
126 blink::WebIDBCursorDirection
,
127 leveldb::Status
*) override
;
129 class FakeTransaction
: public IndexedDBBackingStore::Transaction
{
131 explicit FakeTransaction(leveldb::Status phase_two_result
);
132 void Begin() override
;
133 leveldb::Status
CommitPhaseOne(scoped_refptr
<BlobWriteCallback
>) override
;
134 leveldb::Status
CommitPhaseTwo() override
;
135 void Rollback() override
;
138 leveldb::Status result_
;
140 DISALLOW_COPY_AND_ASSIGN(FakeTransaction
);
144 friend class base::RefCounted
<IndexedDBFakeBackingStore
>;
145 ~IndexedDBFakeBackingStore() override
;
148 DISALLOW_COPY_AND_ASSIGN(IndexedDBFakeBackingStore
);
151 } // namespace content
153 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_