Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: content/browser/indexed_db/indexed_db_database.h

Issue 2506773002: [IndexedDB] Integrating failures and corruption with transaction (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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_DATABASE_H_ 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 class IndexedDBKeyRange; 42 class IndexedDBKeyRange;
43 class IndexedDBObserverChanges; 43 class IndexedDBObserverChanges;
44 class IndexedDBTransaction; 44 class IndexedDBTransaction;
45 struct IndexedDBValue; 45 struct IndexedDBValue;
46 46
47 class CONTENT_EXPORT IndexedDBDatabase 47 class CONTENT_EXPORT IndexedDBDatabase
48 : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBDatabase>) { 48 : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBDatabase>) {
49 public: 49 public:
50 // Identifier is pair of (origin, database name). 50 // Identifier is pair of (origin, database name).
51 using Identifier = std::pair<url::Origin, base::string16>; 51 using Identifier = std::pair<url::Origin, base::string16>;
52 using OperationResult = leveldb::Status;
52 53
53 static const int64_t kInvalidId = 0; 54 static const int64_t kInvalidId = 0;
54 static const int64_t kMinimumIndexId = 30; 55 static const int64_t kMinimumIndexId = 30;
55 56
56 static scoped_refptr<IndexedDBDatabase> Create( 57 static scoped_refptr<IndexedDBDatabase> Create(
57 const base::string16& name, 58 const base::string16& name,
58 IndexedDBBackingStore* backing_store, 59 IndexedDBBackingStore* backing_store,
59 IndexedDBFactory* factory, 60 IndexedDBFactory* factory,
60 const Identifier& unique_identifier, 61 const Identifier& unique_identifier,
61 leveldb::Status* s); 62 leveldb::Status* s);
62 63
63 const Identifier& identifier() const { return identifier_; } 64 const Identifier& identifier() const { return identifier_; }
64 IndexedDBBackingStore* backing_store() { return backing_store_.get(); } 65 IndexedDBBackingStore* backing_store() { return backing_store_.get(); }
65 66
66 int64_t id() const { return metadata_.id; } 67 int64_t id() const { return metadata_.id; }
67 const base::string16& name() const { return metadata_.name; } 68 const base::string16& name() const { return metadata_.name; }
69 const url::Origin& origin() const { return identifier_.first; }
68 70
69 void AddObjectStore(const IndexedDBObjectStoreMetadata& metadata, 71 void AddObjectStore(const IndexedDBObjectStoreMetadata& metadata,
70 int64_t new_max_object_store_id); 72 int64_t new_max_object_store_id);
71 void RemoveObjectStore(int64_t object_store_id); 73 void RemoveObjectStore(int64_t object_store_id);
72 void SetObjectStoreName(int64_t object_store_id, const base::string16& name); 74 void SetObjectStoreName(int64_t object_store_id, const base::string16& name);
73 void AddIndex(int64_t object_store_id, 75 void AddIndex(int64_t object_store_id,
74 const IndexedDBIndexMetadata& metadata, 76 const IndexedDBIndexMetadata& metadata,
75 int64_t new_max_index_id); 77 int64_t new_max_index_id);
76 void RemoveIndex(int64_t object_store_id, int64_t index_id); 78 void RemoveIndex(int64_t object_store_id, int64_t index_id);
77 void SetIndexName(int64_t object_store_id, 79 void SetIndexName(int64_t object_store_id,
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 IndexedDBTransactionCoordinator& transaction_coordinator() { 131 IndexedDBTransactionCoordinator& transaction_coordinator() {
130 return transaction_coordinator_; 132 return transaction_coordinator_;
131 } 133 }
132 const IndexedDBTransactionCoordinator& transaction_coordinator() const { 134 const IndexedDBTransactionCoordinator& transaction_coordinator() const {
133 return transaction_coordinator_; 135 return transaction_coordinator_;
134 } 136 }
135 137
136 void TransactionCreated(IndexedDBTransaction* transaction); 138 void TransactionCreated(IndexedDBTransaction* transaction);
137 void TransactionFinished(IndexedDBTransaction* transaction, bool committed); 139 void TransactionFinished(IndexedDBTransaction* transaction, bool committed);
138 140
139 // Called by transactions to report failure committing to the backing store.
140 void TransactionCommitFailed(const leveldb::Status& status);
141
142 void AddPendingObserver(int64_t transaction_id, 141 void AddPendingObserver(int64_t transaction_id,
143 int32_t observer_id, 142 int32_t observer_id,
144 const IndexedDBObserver::Options& options); 143 const IndexedDBObserver::Options& options);
145 void RemovePendingObservers(IndexedDBConnection* connection, 144 void RemovePendingObservers(IndexedDBConnection* connection,
146 const std::vector<int32_t>& pending_observer_ids); 145 const std::vector<int32_t>& pending_observer_ids);
147 146
148 void FilterObservation(IndexedDBTransaction*, 147 void FilterObservation(IndexedDBTransaction*,
149 int64_t object_store_id, 148 int64_t object_store_id,
150 blink::WebIDBOperationType type, 149 blink::WebIDBOperationType type,
151 const IndexedDBKeyRange& key_range); 150 const IndexedDBKeyRange& key_range);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 size_t ConnectionCount() const { return connections_.size(); } 204 size_t ConnectionCount() const { return connections_.size(); }
206 205
207 // Number of active open/delete calls (running or blocked on other 206 // Number of active open/delete calls (running or blocked on other
208 // connections). 207 // connections).
209 size_t ActiveOpenDeleteCount() const { return active_request_ ? 1 : 0; } 208 size_t ActiveOpenDeleteCount() const { return active_request_ ? 1 : 0; }
210 209
211 // Number of open/delete calls that are waiting their turn. 210 // Number of open/delete calls that are waiting their turn.
212 size_t PendingOpenDeleteCount() const { return pending_requests_.size(); } 211 size_t PendingOpenDeleteCount() const { return pending_requests_.size(); }
213 212
214 // Asynchronous tasks scheduled within transactions: 213 // Asynchronous tasks scheduled within transactions:
215 void CreateObjectStoreAbortOperation(int64_t object_store_id, 214 void CreateObjectStoreAbortOperation(int64_t object_store_id);
215 OperationResult DeleteObjectStoreOperation(int64_t object_store_id,
216 IndexedDBTransaction* transaction);
217 void DeleteObjectStoreAbortOperation(
218 const IndexedDBObjectStoreMetadata& object_store_metadata);
219 void RenameObjectStoreAbortOperation(int64_t object_store_id,
220 const base::string16& old_name);
221 OperationResult VersionChangeOperation(
222 int64_t version,
223 scoped_refptr<IndexedDBCallbacks> callbacks,
224 IndexedDBTransaction* transaction);
225 void VersionChangeAbortOperation(int64_t previous_version);
226 OperationResult DeleteIndexOperation(int64_t object_store_id,
227 int64_t index_id,
216 IndexedDBTransaction* transaction); 228 IndexedDBTransaction* transaction);
217 void DeleteObjectStoreOperation(int64_t object_store_id, 229 void CreateIndexAbortOperation(int64_t object_store_id, int64_t index_id);
218 IndexedDBTransaction* transaction);
219 void DeleteObjectStoreAbortOperation(
220 const IndexedDBObjectStoreMetadata& object_store_metadata,
221 IndexedDBTransaction* transaction);
222 void RenameObjectStoreAbortOperation(int64_t object_store_id,
223 const base::string16& old_name,
224 IndexedDBTransaction* transaction);
225 void VersionChangeOperation(int64_t version,
226 scoped_refptr<IndexedDBCallbacks> callbacks,
227 IndexedDBTransaction* transaction);
228 void VersionChangeAbortOperation(int64_t previous_version,
229 IndexedDBTransaction* transaction);
230 void DeleteIndexOperation(int64_t object_store_id,
231 int64_t index_id,
232 IndexedDBTransaction* transaction);
233 void CreateIndexAbortOperation(int64_t object_store_id,
234 int64_t index_id,
235 IndexedDBTransaction* transaction);
236 void DeleteIndexAbortOperation(int64_t object_store_id, 230 void DeleteIndexAbortOperation(int64_t object_store_id,
237 const IndexedDBIndexMetadata& index_metadata, 231 const IndexedDBIndexMetadata& index_metadata);
238 IndexedDBTransaction* transaction);
239 void RenameIndexAbortOperation(int64_t object_store_id, 232 void RenameIndexAbortOperation(int64_t object_store_id,
240 int64_t index_id, 233 int64_t index_id,
241 const base::string16& old_name, 234 const base::string16& old_name);
235 OperationResult GetOperation(int64_t object_store_id,
236 int64_t index_id,
237 std::unique_ptr<IndexedDBKeyRange> key_range,
238 indexed_db::CursorType cursor_type,
239 scoped_refptr<IndexedDBCallbacks> callbacks,
240 IndexedDBTransaction* transaction);
241 OperationResult GetAllOperation(int64_t object_store_id,
242 int64_t index_id,
243 std::unique_ptr<IndexedDBKeyRange> key_range,
244 indexed_db::CursorType cursor_type,
245 int64_t max_count,
246 scoped_refptr<IndexedDBCallbacks> callbacks,
247 IndexedDBTransaction* transaction);
248 struct PutOperationParams;
249 OperationResult PutOperation(std::unique_ptr<PutOperationParams> params,
250 IndexedDBTransaction* transaction);
251 OperationResult SetIndexesReadyOperation(size_t index_count,
252 IndexedDBTransaction* transaction);
253 struct OpenCursorOperationParams;
254 OperationResult OpenCursorOperation(
255 std::unique_ptr<OpenCursorOperationParams> params,
256 IndexedDBTransaction* transaction);
257 OperationResult CountOperation(int64_t object_store_id,
258 int64_t index_id,
259 std::unique_ptr<IndexedDBKeyRange> key_range,
260 scoped_refptr<IndexedDBCallbacks> callbacks,
242 IndexedDBTransaction* transaction); 261 IndexedDBTransaction* transaction);
243 void GetOperation(int64_t object_store_id, 262 OperationResult DeleteRangeOperation(
244 int64_t index_id, 263 int64_t object_store_id,
245 std::unique_ptr<IndexedDBKeyRange> key_range, 264 std::unique_ptr<IndexedDBKeyRange> key_range,
246 indexed_db::CursorType cursor_type, 265 scoped_refptr<IndexedDBCallbacks> callbacks,
247 scoped_refptr<IndexedDBCallbacks> callbacks, 266 IndexedDBTransaction* transaction);
248 IndexedDBTransaction* transaction); 267 OperationResult ClearOperation(int64_t object_store_id,
249 void GetAllOperation(int64_t object_store_id, 268 scoped_refptr<IndexedDBCallbacks> callbacks,
250 int64_t index_id, 269 IndexedDBTransaction* transaction);
251 std::unique_ptr<IndexedDBKeyRange> key_range,
252 indexed_db::CursorType cursor_type,
253 int64_t max_count,
254 scoped_refptr<IndexedDBCallbacks> callbacks,
255 IndexedDBTransaction* transaction);
256 struct PutOperationParams;
257 void PutOperation(std::unique_ptr<PutOperationParams> params,
258 IndexedDBTransaction* transaction);
259 void SetIndexesReadyOperation(size_t index_count,
260 IndexedDBTransaction* transaction);
261 struct OpenCursorOperationParams;
262 void OpenCursorOperation(std::unique_ptr<OpenCursorOperationParams> params,
263 IndexedDBTransaction* transaction);
264 void CountOperation(int64_t object_store_id,
265 int64_t index_id,
266 std::unique_ptr<IndexedDBKeyRange> key_range,
267 scoped_refptr<IndexedDBCallbacks> callbacks,
268 IndexedDBTransaction* transaction);
269 void DeleteRangeOperation(int64_t object_store_id,
270 std::unique_ptr<IndexedDBKeyRange> key_range,
271 scoped_refptr<IndexedDBCallbacks> callbacks,
272 IndexedDBTransaction* transaction);
273 void ClearOperation(int64_t object_store_id,
274 scoped_refptr<IndexedDBCallbacks> callbacks,
275 IndexedDBTransaction* transaction);
276 270
277 protected: 271 protected:
272 friend class IndexedDBTransaction;
273
278 IndexedDBDatabase(const base::string16& name, 274 IndexedDBDatabase(const base::string16& name,
279 IndexedDBBackingStore* backing_store, 275 IndexedDBBackingStore* backing_store,
280 IndexedDBFactory* factory, 276 IndexedDBFactory* factory,
281 const Identifier& unique_identifier); 277 const Identifier& unique_identifier);
282 virtual ~IndexedDBDatabase(); 278 virtual ~IndexedDBDatabase();
283 279
284 // May be overridden in tests. 280 // May be overridden in tests.
285 virtual size_t GetMaxMessageSizeInBytes() const; 281 virtual size_t GetMaxMessageSizeInBytes() const;
286 282
283 IndexedDBFactory* factory() const { return factory_.get(); }
284
287 private: 285 private:
288 friend class base::RefCounted<IndexedDBDatabase>; 286 friend class base::RefCounted<IndexedDBDatabase>;
289 friend class IndexedDBClassFactory; 287 friend class IndexedDBClassFactory;
290 288
291 class ConnectionRequest; 289 class ConnectionRequest;
292 class OpenRequest; 290 class OpenRequest;
293 class DeleteRequest; 291 class DeleteRequest;
294 292
295 leveldb::Status OpenInternal(); 293 leveldb::Status OpenInternal();
296 294
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 // is executing. It prevents rentrant calls if the active request completes 344 // is executing. It prevents rentrant calls if the active request completes
347 // synchronously. 345 // synchronously.
348 bool processing_pending_requests_ = false; 346 bool processing_pending_requests_ = false;
349 347
350 DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabase); 348 DISALLOW_COPY_AND_ASSIGN(IndexedDBDatabase);
351 }; 349 };
352 350
353 } // namespace content 351 } // namespace content
354 352
355 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_ 353 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698