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