| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_ |
| 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> |
| 9 |
| 8 #include <vector> | 10 #include <vector> |
| 9 | 11 |
| 12 #include "base/macros.h" |
| 10 #include "content/browser/indexed_db/indexed_db_backing_store.h" | 13 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
| 11 | 14 |
| 12 namespace base { | 15 namespace base { |
| 13 class SequencedTaskRunner; | 16 class SequencedTaskRunner; |
| 14 } | 17 } |
| 15 | 18 |
| 16 namespace content { | 19 namespace content { |
| 17 | 20 |
| 18 class IndexedDBFactory; | 21 class IndexedDBFactory; |
| 19 | 22 |
| 20 class IndexedDBFakeBackingStore : public IndexedDBBackingStore { | 23 class IndexedDBFakeBackingStore : public IndexedDBBackingStore { |
| 21 public: | 24 public: |
| 22 IndexedDBFakeBackingStore(); | 25 IndexedDBFakeBackingStore(); |
| 23 IndexedDBFakeBackingStore(IndexedDBFactory* factory, | 26 IndexedDBFakeBackingStore(IndexedDBFactory* factory, |
| 24 base::SequencedTaskRunner* task_runner); | 27 base::SequencedTaskRunner* task_runner); |
| 25 std::vector<base::string16> GetDatabaseNames(leveldb::Status* s) override; | 28 std::vector<base::string16> GetDatabaseNames(leveldb::Status* s) override; |
| 26 leveldb::Status GetIDBDatabaseMetaData(const base::string16& name, | 29 leveldb::Status GetIDBDatabaseMetaData(const base::string16& name, |
| 27 IndexedDBDatabaseMetadata*, | 30 IndexedDBDatabaseMetadata*, |
| 28 bool* found) override; | 31 bool* found) override; |
| 29 leveldb::Status CreateIDBDatabaseMetaData(const base::string16& name, | 32 leveldb::Status CreateIDBDatabaseMetaData(const base::string16& name, |
| 30 const base::string16& version, | 33 const base::string16& version, |
| 31 int64 int_version, | 34 int64_t int_version, |
| 32 int64* row_id) override; | 35 int64_t* row_id) override; |
| 33 bool UpdateIDBDatabaseIntVersion(Transaction*, | 36 bool UpdateIDBDatabaseIntVersion(Transaction*, |
| 34 int64 row_id, | 37 int64_t row_id, |
| 35 int64 version) override; | 38 int64_t version) override; |
| 36 leveldb::Status DeleteDatabase(const base::string16& name) override; | 39 leveldb::Status DeleteDatabase(const base::string16& name) override; |
| 37 | 40 |
| 38 leveldb::Status CreateObjectStore(Transaction*, | 41 leveldb::Status CreateObjectStore(Transaction*, |
| 39 int64 database_id, | 42 int64_t database_id, |
| 40 int64 object_store_id, | 43 int64_t object_store_id, |
| 41 const base::string16& name, | 44 const base::string16& name, |
| 42 const IndexedDBKeyPath&, | 45 const IndexedDBKeyPath&, |
| 43 bool auto_increment) override; | 46 bool auto_increment) override; |
| 44 | 47 |
| 45 leveldb::Status DeleteObjectStore(Transaction* transaction, | 48 leveldb::Status DeleteObjectStore(Transaction* transaction, |
| 46 int64 database_id, | 49 int64_t database_id, |
| 47 int64 object_store_id) override; | 50 int64_t object_store_id) override; |
| 48 | 51 |
| 49 leveldb::Status PutRecord(IndexedDBBackingStore::Transaction* transaction, | 52 leveldb::Status PutRecord(IndexedDBBackingStore::Transaction* transaction, |
| 50 int64 database_id, | 53 int64_t database_id, |
| 51 int64 object_store_id, | 54 int64_t object_store_id, |
| 52 const IndexedDBKey& key, | 55 const IndexedDBKey& key, |
| 53 IndexedDBValue* value, | 56 IndexedDBValue* value, |
| 54 ScopedVector<storage::BlobDataHandle>* handles, | 57 ScopedVector<storage::BlobDataHandle>* handles, |
| 55 RecordIdentifier* record) override; | 58 RecordIdentifier* record) override; |
| 56 | 59 |
| 57 leveldb::Status ClearObjectStore(Transaction*, | 60 leveldb::Status ClearObjectStore(Transaction*, |
| 58 int64 database_id, | 61 int64_t database_id, |
| 59 int64 object_store_id) override; | 62 int64_t object_store_id) override; |
| 60 leveldb::Status DeleteRecord(Transaction*, | 63 leveldb::Status DeleteRecord(Transaction*, |
| 61 int64 database_id, | 64 int64_t database_id, |
| 62 int64 object_store_id, | 65 int64_t object_store_id, |
| 63 const RecordIdentifier&) override; | 66 const RecordIdentifier&) override; |
| 64 leveldb::Status GetKeyGeneratorCurrentNumber(Transaction*, | 67 leveldb::Status GetKeyGeneratorCurrentNumber( |
| 65 int64 database_id, | 68 Transaction*, |
| 66 int64 object_store_id, | 69 int64_t database_id, |
| 67 int64* current_number) override; | 70 int64_t object_store_id, |
| 71 int64_t* current_number) override; |
| 68 leveldb::Status MaybeUpdateKeyGeneratorCurrentNumber( | 72 leveldb::Status MaybeUpdateKeyGeneratorCurrentNumber( |
| 69 Transaction*, | 73 Transaction*, |
| 70 int64 database_id, | 74 int64_t database_id, |
| 71 int64 object_store_id, | 75 int64_t object_store_id, |
| 72 int64 new_number, | 76 int64_t new_number, |
| 73 bool check_current) override; | 77 bool check_current) override; |
| 74 leveldb::Status KeyExistsInObjectStore( | 78 leveldb::Status KeyExistsInObjectStore( |
| 75 Transaction*, | 79 Transaction*, |
| 76 int64 database_id, | 80 int64_t database_id, |
| 77 int64 object_store_id, | 81 int64_t object_store_id, |
| 78 const IndexedDBKey&, | 82 const IndexedDBKey&, |
| 79 RecordIdentifier* found_record_identifier, | 83 RecordIdentifier* found_record_identifier, |
| 80 bool* found) override; | 84 bool* found) override; |
| 81 | 85 |
| 82 leveldb::Status CreateIndex(Transaction*, | 86 leveldb::Status CreateIndex(Transaction*, |
| 83 int64 database_id, | 87 int64_t database_id, |
| 84 int64 object_store_id, | 88 int64_t object_store_id, |
| 85 int64 index_id, | 89 int64_t index_id, |
| 86 const base::string16& name, | 90 const base::string16& name, |
| 87 const IndexedDBKeyPath&, | 91 const IndexedDBKeyPath&, |
| 88 bool is_unique, | 92 bool is_unique, |
| 89 bool is_multi_entry) override; | 93 bool is_multi_entry) override; |
| 90 leveldb::Status DeleteIndex(Transaction*, | 94 leveldb::Status DeleteIndex(Transaction*, |
| 91 int64 database_id, | 95 int64_t database_id, |
| 92 int64 object_store_id, | 96 int64_t object_store_id, |
| 93 int64 index_id) override; | 97 int64_t index_id) override; |
| 94 leveldb::Status PutIndexDataForRecord(Transaction*, | 98 leveldb::Status PutIndexDataForRecord(Transaction*, |
| 95 int64 database_id, | 99 int64_t database_id, |
| 96 int64 object_store_id, | 100 int64_t object_store_id, |
| 97 int64 index_id, | 101 int64_t index_id, |
| 98 const IndexedDBKey&, | 102 const IndexedDBKey&, |
| 99 const RecordIdentifier&) override; | 103 const RecordIdentifier&) override; |
| 100 void ReportBlobUnused(int64 database_id, int64 blob_key) override; | 104 void ReportBlobUnused(int64_t database_id, int64_t blob_key) override; |
| 101 scoped_ptr<Cursor> OpenObjectStoreKeyCursor( | 105 scoped_ptr<Cursor> OpenObjectStoreKeyCursor( |
| 102 Transaction* transaction, | 106 Transaction* transaction, |
| 103 int64 database_id, | 107 int64_t database_id, |
| 104 int64 object_store_id, | 108 int64_t object_store_id, |
| 105 const IndexedDBKeyRange& key_range, | 109 const IndexedDBKeyRange& key_range, |
| 106 blink::WebIDBCursorDirection, | 110 blink::WebIDBCursorDirection, |
| 107 leveldb::Status*) override; | 111 leveldb::Status*) override; |
| 108 scoped_ptr<Cursor> OpenObjectStoreCursor(Transaction* transaction, | 112 scoped_ptr<Cursor> OpenObjectStoreCursor(Transaction* transaction, |
| 109 int64 database_id, | 113 int64_t database_id, |
| 110 int64 object_store_id, | 114 int64_t object_store_id, |
| 111 const IndexedDBKeyRange& key_range, | 115 const IndexedDBKeyRange& key_range, |
| 112 blink::WebIDBCursorDirection, | 116 blink::WebIDBCursorDirection, |
| 113 leveldb::Status*) override; | 117 leveldb::Status*) override; |
| 114 scoped_ptr<Cursor> OpenIndexKeyCursor(Transaction* transaction, | 118 scoped_ptr<Cursor> OpenIndexKeyCursor(Transaction* transaction, |
| 115 int64 database_id, | 119 int64_t database_id, |
| 116 int64 object_store_id, | 120 int64_t object_store_id, |
| 117 int64 index_id, | 121 int64_t index_id, |
| 118 const IndexedDBKeyRange& key_range, | 122 const IndexedDBKeyRange& key_range, |
| 119 blink::WebIDBCursorDirection, | 123 blink::WebIDBCursorDirection, |
| 120 leveldb::Status*) override; | 124 leveldb::Status*) override; |
| 121 scoped_ptr<Cursor> OpenIndexCursor(Transaction* transaction, | 125 scoped_ptr<Cursor> OpenIndexCursor(Transaction* transaction, |
| 122 int64 database_id, | 126 int64_t database_id, |
| 123 int64 object_store_id, | 127 int64_t object_store_id, |
| 124 int64 index_id, | 128 int64_t index_id, |
| 125 const IndexedDBKeyRange& key_range, | 129 const IndexedDBKeyRange& key_range, |
| 126 blink::WebIDBCursorDirection, | 130 blink::WebIDBCursorDirection, |
| 127 leveldb::Status*) override; | 131 leveldb::Status*) override; |
| 128 | 132 |
| 129 class FakeTransaction : public IndexedDBBackingStore::Transaction { | 133 class FakeTransaction : public IndexedDBBackingStore::Transaction { |
| 130 public: | 134 public: |
| 131 explicit FakeTransaction(leveldb::Status phase_two_result); | 135 explicit FakeTransaction(leveldb::Status phase_two_result); |
| 132 void Begin() override; | 136 void Begin() override; |
| 133 leveldb::Status CommitPhaseOne(scoped_refptr<BlobWriteCallback>) override; | 137 leveldb::Status CommitPhaseOne(scoped_refptr<BlobWriteCallback>) override; |
| 134 leveldb::Status CommitPhaseTwo() override; | 138 leveldb::Status CommitPhaseTwo() override; |
| 135 void Rollback() override; | 139 void Rollback() override; |
| 136 | 140 |
| 137 private: | 141 private: |
| 138 leveldb::Status result_; | 142 leveldb::Status result_; |
| 139 | 143 |
| 140 DISALLOW_COPY_AND_ASSIGN(FakeTransaction); | 144 DISALLOW_COPY_AND_ASSIGN(FakeTransaction); |
| 141 }; | 145 }; |
| 142 | 146 |
| 143 protected: | 147 protected: |
| 144 friend class base::RefCounted<IndexedDBFakeBackingStore>; | 148 friend class base::RefCounted<IndexedDBFakeBackingStore>; |
| 145 ~IndexedDBFakeBackingStore() override; | 149 ~IndexedDBFakeBackingStore() override; |
| 146 | 150 |
| 147 private: | 151 private: |
| 148 DISALLOW_COPY_AND_ASSIGN(IndexedDBFakeBackingStore); | 152 DISALLOW_COPY_AND_ASSIGN(IndexedDBFakeBackingStore); |
| 149 }; | 153 }; |
| 150 | 154 |
| 151 } // namespace content | 155 } // namespace content |
| 152 | 156 |
| 153 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_ | 157 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_FAKE_BACKING_STORE_H_ |
| OLD | NEW |