• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "content/browser/indexed_db/indexed_db_fake_backing_store.h"
6 
7 #include "base/files/file_path.h"
8 #include "base/memory/scoped_ptr.h"
9 
10 namespace content {
11 
IndexedDBFakeBackingStore()12 IndexedDBFakeBackingStore::IndexedDBFakeBackingStore()
13     : IndexedDBBackingStore(NULL /* indexed_db_factory */,
14                             GURL("http://localhost:81"),
15                             base::FilePath(),
16                             NULL /* request_context */,
17                             scoped_ptr<LevelDBDatabase>(),
18                             scoped_ptr<LevelDBComparator>(),
19                             NULL /* task_runner */) {
20 }
IndexedDBFakeBackingStore(IndexedDBFactory * factory,base::TaskRunner * task_runner)21 IndexedDBFakeBackingStore::IndexedDBFakeBackingStore(
22     IndexedDBFactory* factory,
23     base::TaskRunner* task_runner)
24     : IndexedDBBackingStore(factory,
25                             GURL("http://localhost:81"),
26                             base::FilePath(),
27                             NULL /* request_context */,
28                             scoped_ptr<LevelDBDatabase>(),
29                             scoped_ptr<LevelDBComparator>(),
30                             task_runner) {
31 }
~IndexedDBFakeBackingStore()32 IndexedDBFakeBackingStore::~IndexedDBFakeBackingStore() {}
33 
GetDatabaseNames(leveldb::Status * s)34 std::vector<base::string16> IndexedDBFakeBackingStore::GetDatabaseNames(
35     leveldb::Status* s) {
36   *s = leveldb::Status::OK();
37   return std::vector<base::string16>();
38 }
GetIDBDatabaseMetaData(const base::string16 & name,IndexedDBDatabaseMetadata *,bool * found)39 leveldb::Status IndexedDBFakeBackingStore::GetIDBDatabaseMetaData(
40     const base::string16& name,
41     IndexedDBDatabaseMetadata*,
42     bool* found) {
43   return leveldb::Status::OK();
44 }
45 
CreateIDBDatabaseMetaData(const base::string16 & name,const base::string16 & version,int64 int_version,int64 * row_id)46 leveldb::Status IndexedDBFakeBackingStore::CreateIDBDatabaseMetaData(
47     const base::string16& name,
48     const base::string16& version,
49     int64 int_version,
50     int64* row_id) {
51   return leveldb::Status::OK();
52 }
UpdateIDBDatabaseIntVersion(Transaction *,int64 row_id,int64 version)53 bool IndexedDBFakeBackingStore::UpdateIDBDatabaseIntVersion(Transaction*,
54                                                             int64 row_id,
55                                                             int64 version) {
56   return false;
57 }
DeleteDatabase(const base::string16 & name)58 leveldb::Status IndexedDBFakeBackingStore::DeleteDatabase(
59     const base::string16& name) {
60   return leveldb::Status::OK();
61 }
62 
CreateObjectStore(Transaction *,int64 database_id,int64 object_store_id,const base::string16 & name,const IndexedDBKeyPath &,bool auto_increment)63 leveldb::Status IndexedDBFakeBackingStore::CreateObjectStore(
64     Transaction*,
65     int64 database_id,
66     int64 object_store_id,
67     const base::string16& name,
68     const IndexedDBKeyPath&,
69     bool auto_increment) {
70   return leveldb::Status::OK();
71 }
72 
DeleteObjectStore(Transaction * transaction,int64 database_id,int64 object_store_id)73 leveldb::Status IndexedDBFakeBackingStore::DeleteObjectStore(
74     Transaction* transaction,
75     int64 database_id,
76     int64 object_store_id) {
77   return leveldb::Status::OK();
78 }
79 
PutRecord(IndexedDBBackingStore::Transaction * transaction,int64 database_id,int64 object_store_id,const IndexedDBKey & key,IndexedDBValue & value,ScopedVector<webkit_blob::BlobDataHandle> * handles,RecordIdentifier * record)80 leveldb::Status IndexedDBFakeBackingStore::PutRecord(
81     IndexedDBBackingStore::Transaction* transaction,
82     int64 database_id,
83     int64 object_store_id,
84     const IndexedDBKey& key,
85     IndexedDBValue& value,
86     ScopedVector<webkit_blob::BlobDataHandle>* handles,
87     RecordIdentifier* record) {
88   return leveldb::Status::OK();
89 }
90 
ClearObjectStore(Transaction *,int64 database_id,int64 object_store_id)91 leveldb::Status IndexedDBFakeBackingStore::ClearObjectStore(
92     Transaction*,
93     int64 database_id,
94     int64 object_store_id) {
95   return leveldb::Status::OK();
96 }
DeleteRecord(Transaction *,int64 database_id,int64 object_store_id,const RecordIdentifier &)97 leveldb::Status IndexedDBFakeBackingStore::DeleteRecord(
98     Transaction*,
99     int64 database_id,
100     int64 object_store_id,
101     const RecordIdentifier&) {
102   return leveldb::Status::OK();
103 }
GetKeyGeneratorCurrentNumber(Transaction *,int64 database_id,int64 object_store_id,int64 * current_number)104 leveldb::Status IndexedDBFakeBackingStore::GetKeyGeneratorCurrentNumber(
105     Transaction*,
106     int64 database_id,
107     int64 object_store_id,
108     int64* current_number) {
109   return leveldb::Status::OK();
110 }
MaybeUpdateKeyGeneratorCurrentNumber(Transaction *,int64 database_id,int64 object_store_id,int64 new_number,bool check_current)111 leveldb::Status IndexedDBFakeBackingStore::MaybeUpdateKeyGeneratorCurrentNumber(
112     Transaction*,
113     int64 database_id,
114     int64 object_store_id,
115     int64 new_number,
116     bool check_current) {
117   return leveldb::Status::OK();
118 }
KeyExistsInObjectStore(Transaction *,int64 database_id,int64 object_store_id,const IndexedDBKey &,RecordIdentifier * found_record_identifier,bool * found)119 leveldb::Status IndexedDBFakeBackingStore::KeyExistsInObjectStore(
120     Transaction*,
121     int64 database_id,
122     int64 object_store_id,
123     const IndexedDBKey&,
124     RecordIdentifier* found_record_identifier,
125     bool* found) {
126   return leveldb::Status::OK();
127 }
128 
CreateIndex(Transaction *,int64 database_id,int64 object_store_id,int64 index_id,const base::string16 & name,const IndexedDBKeyPath &,bool is_unique,bool is_multi_entry)129 leveldb::Status IndexedDBFakeBackingStore::CreateIndex(
130     Transaction*,
131     int64 database_id,
132     int64 object_store_id,
133     int64 index_id,
134     const base::string16& name,
135     const IndexedDBKeyPath&,
136     bool is_unique,
137     bool is_multi_entry) {
138   return leveldb::Status::OK();
139 }
140 
DeleteIndex(Transaction *,int64 database_id,int64 object_store_id,int64 index_id)141 leveldb::Status IndexedDBFakeBackingStore::DeleteIndex(Transaction*,
142                                                        int64 database_id,
143                                                        int64 object_store_id,
144                                                        int64 index_id) {
145   return leveldb::Status::OK();
146 }
PutIndexDataForRecord(Transaction *,int64 database_id,int64 object_store_id,int64 index_id,const IndexedDBKey &,const RecordIdentifier &)147 leveldb::Status IndexedDBFakeBackingStore::PutIndexDataForRecord(
148     Transaction*,
149     int64 database_id,
150     int64 object_store_id,
151     int64 index_id,
152     const IndexedDBKey&,
153     const RecordIdentifier&) {
154   return leveldb::Status::OK();
155 }
156 
ReportBlobUnused(int64 database_id,int64 blob_key)157 void IndexedDBFakeBackingStore::ReportBlobUnused(int64 database_id,
158                                                  int64 blob_key) {}
159 
160 scoped_ptr<IndexedDBBackingStore::Cursor>
OpenObjectStoreKeyCursor(IndexedDBBackingStore::Transaction * transaction,int64 database_id,int64 object_store_id,const IndexedDBKeyRange & key_range,indexed_db::CursorDirection,leveldb::Status * s)161 IndexedDBFakeBackingStore::OpenObjectStoreKeyCursor(
162     IndexedDBBackingStore::Transaction* transaction,
163     int64 database_id,
164     int64 object_store_id,
165     const IndexedDBKeyRange& key_range,
166     indexed_db::CursorDirection,
167     leveldb::Status* s) {
168   return scoped_ptr<IndexedDBBackingStore::Cursor>();
169 }
170 scoped_ptr<IndexedDBBackingStore::Cursor>
OpenObjectStoreCursor(IndexedDBBackingStore::Transaction * transaction,int64 database_id,int64 object_store_id,const IndexedDBKeyRange & key_range,indexed_db::CursorDirection,leveldb::Status * s)171 IndexedDBFakeBackingStore::OpenObjectStoreCursor(
172     IndexedDBBackingStore::Transaction* transaction,
173     int64 database_id,
174     int64 object_store_id,
175     const IndexedDBKeyRange& key_range,
176     indexed_db::CursorDirection,
177     leveldb::Status* s) {
178   return scoped_ptr<IndexedDBBackingStore::Cursor>();
179 }
180 scoped_ptr<IndexedDBBackingStore::Cursor>
OpenIndexKeyCursor(IndexedDBBackingStore::Transaction * transaction,int64 database_id,int64 object_store_id,int64 index_id,const IndexedDBKeyRange & key_range,indexed_db::CursorDirection,leveldb::Status * s)181 IndexedDBFakeBackingStore::OpenIndexKeyCursor(
182     IndexedDBBackingStore::Transaction* transaction,
183     int64 database_id,
184     int64 object_store_id,
185     int64 index_id,
186     const IndexedDBKeyRange& key_range,
187     indexed_db::CursorDirection,
188     leveldb::Status* s) {
189   return scoped_ptr<IndexedDBBackingStore::Cursor>();
190 }
191 scoped_ptr<IndexedDBBackingStore::Cursor>
OpenIndexCursor(IndexedDBBackingStore::Transaction * transaction,int64 database_id,int64 object_store_id,int64 index_id,const IndexedDBKeyRange & key_range,indexed_db::CursorDirection,leveldb::Status * s)192 IndexedDBFakeBackingStore::OpenIndexCursor(
193     IndexedDBBackingStore::Transaction* transaction,
194     int64 database_id,
195     int64 object_store_id,
196     int64 index_id,
197     const IndexedDBKeyRange& key_range,
198     indexed_db::CursorDirection,
199     leveldb::Status* s) {
200   return scoped_ptr<IndexedDBBackingStore::Cursor>();
201 }
202 
FakeTransaction(leveldb::Status result)203 IndexedDBFakeBackingStore::FakeTransaction::FakeTransaction(
204     leveldb::Status result)
205     : IndexedDBBackingStore::Transaction(NULL), result_(result) {
206 }
Begin()207 void IndexedDBFakeBackingStore::FakeTransaction::Begin() {}
CommitPhaseOne(scoped_refptr<BlobWriteCallback> callback)208 leveldb::Status IndexedDBFakeBackingStore::FakeTransaction::CommitPhaseOne(
209     scoped_refptr<BlobWriteCallback> callback) {
210   callback->Run(true);
211   return leveldb::Status::OK();
212 }
CommitPhaseTwo()213 leveldb::Status IndexedDBFakeBackingStore::FakeTransaction::CommitPhaseTwo() {
214   return result_;
215 }
Rollback()216 void IndexedDBFakeBackingStore::FakeTransaction::Rollback() {}
217 
218 }  // namespace content
219