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 10namespace content { 11 12IndexedDBFakeBackingStore::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} 21IndexedDBFakeBackingStore::IndexedDBFakeBackingStore( 22 IndexedDBFactory* factory, 23 base::SequencedTaskRunner* 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} 32IndexedDBFakeBackingStore::~IndexedDBFakeBackingStore() {} 33 34std::vector<base::string16> IndexedDBFakeBackingStore::GetDatabaseNames( 35 leveldb::Status* s) { 36 *s = leveldb::Status::OK(); 37 return std::vector<base::string16>(); 38} 39leveldb::Status IndexedDBFakeBackingStore::GetIDBDatabaseMetaData( 40 const base::string16& name, 41 IndexedDBDatabaseMetadata*, 42 bool* found) { 43 return leveldb::Status::OK(); 44} 45 46leveldb::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} 53bool IndexedDBFakeBackingStore::UpdateIDBDatabaseIntVersion(Transaction*, 54 int64 row_id, 55 int64 version) { 56 return false; 57} 58leveldb::Status IndexedDBFakeBackingStore::DeleteDatabase( 59 const base::string16& name) { 60 return leveldb::Status::OK(); 61} 62 63leveldb::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 73leveldb::Status IndexedDBFakeBackingStore::DeleteObjectStore( 74 Transaction* transaction, 75 int64 database_id, 76 int64 object_store_id) { 77 return leveldb::Status::OK(); 78} 79 80leveldb::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<storage::BlobDataHandle>* handles, 87 RecordIdentifier* record) { 88 return leveldb::Status::OK(); 89} 90 91leveldb::Status IndexedDBFakeBackingStore::ClearObjectStore( 92 Transaction*, 93 int64 database_id, 94 int64 object_store_id) { 95 return leveldb::Status::OK(); 96} 97leveldb::Status IndexedDBFakeBackingStore::DeleteRecord( 98 Transaction*, 99 int64 database_id, 100 int64 object_store_id, 101 const RecordIdentifier&) { 102 return leveldb::Status::OK(); 103} 104leveldb::Status IndexedDBFakeBackingStore::GetKeyGeneratorCurrentNumber( 105 Transaction*, 106 int64 database_id, 107 int64 object_store_id, 108 int64* current_number) { 109 return leveldb::Status::OK(); 110} 111leveldb::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} 119leveldb::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 129leveldb::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 141leveldb::Status IndexedDBFakeBackingStore::DeleteIndex(Transaction*, 142 int64 database_id, 143 int64 object_store_id, 144 int64 index_id) { 145 return leveldb::Status::OK(); 146} 147leveldb::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 157void IndexedDBFakeBackingStore::ReportBlobUnused(int64 database_id, 158 int64 blob_key) {} 159 160scoped_ptr<IndexedDBBackingStore::Cursor> 161IndexedDBFakeBackingStore::OpenObjectStoreKeyCursor( 162 IndexedDBBackingStore::Transaction* transaction, 163 int64 database_id, 164 int64 object_store_id, 165 const IndexedDBKeyRange& key_range, 166 blink::WebIDBCursorDirection, 167 leveldb::Status* s) { 168 return scoped_ptr<IndexedDBBackingStore::Cursor>(); 169} 170scoped_ptr<IndexedDBBackingStore::Cursor> 171IndexedDBFakeBackingStore::OpenObjectStoreCursor( 172 IndexedDBBackingStore::Transaction* transaction, 173 int64 database_id, 174 int64 object_store_id, 175 const IndexedDBKeyRange& key_range, 176 blink::WebIDBCursorDirection, 177 leveldb::Status* s) { 178 return scoped_ptr<IndexedDBBackingStore::Cursor>(); 179} 180scoped_ptr<IndexedDBBackingStore::Cursor> 181IndexedDBFakeBackingStore::OpenIndexKeyCursor( 182 IndexedDBBackingStore::Transaction* transaction, 183 int64 database_id, 184 int64 object_store_id, 185 int64 index_id, 186 const IndexedDBKeyRange& key_range, 187 blink::WebIDBCursorDirection, 188 leveldb::Status* s) { 189 return scoped_ptr<IndexedDBBackingStore::Cursor>(); 190} 191scoped_ptr<IndexedDBBackingStore::Cursor> 192IndexedDBFakeBackingStore::OpenIndexCursor( 193 IndexedDBBackingStore::Transaction* transaction, 194 int64 database_id, 195 int64 object_store_id, 196 int64 index_id, 197 const IndexedDBKeyRange& key_range, 198 blink::WebIDBCursorDirection, 199 leveldb::Status* s) { 200 return scoped_ptr<IndexedDBBackingStore::Cursor>(); 201} 202 203IndexedDBFakeBackingStore::FakeTransaction::FakeTransaction( 204 leveldb::Status result) 205 : IndexedDBBackingStore::Transaction(NULL), result_(result) { 206} 207void IndexedDBFakeBackingStore::FakeTransaction::Begin() {} 208leveldb::Status IndexedDBFakeBackingStore::FakeTransaction::CommitPhaseOne( 209 scoped_refptr<BlobWriteCallback> callback) { 210 callback->Run(true); 211 return leveldb::Status::OK(); 212} 213leveldb::Status IndexedDBFakeBackingStore::FakeTransaction::CommitPhaseTwo() { 214 return result_; 215} 216void IndexedDBFakeBackingStore::FakeTransaction::Rollback() {} 217 218} // namespace content 219