Chromium Code Reviews| OLD | NEW |
|---|---|
| 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_BACKING_STORE_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
| 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 RecordIdentifier* record) WARN_UNUSED_RESULT; | 196 RecordIdentifier* record) WARN_UNUSED_RESULT; |
| 197 virtual leveldb::Status ClearObjectStore( | 197 virtual leveldb::Status ClearObjectStore( |
| 198 IndexedDBBackingStore::Transaction* transaction, | 198 IndexedDBBackingStore::Transaction* transaction, |
| 199 int64 database_id, | 199 int64 database_id, |
| 200 int64 object_store_id) WARN_UNUSED_RESULT; | 200 int64 object_store_id) WARN_UNUSED_RESULT; |
| 201 virtual leveldb::Status DeleteRecord( | 201 virtual leveldb::Status DeleteRecord( |
| 202 IndexedDBBackingStore::Transaction* transaction, | 202 IndexedDBBackingStore::Transaction* transaction, |
| 203 int64 database_id, | 203 int64 database_id, |
| 204 int64 object_store_id, | 204 int64 object_store_id, |
| 205 const RecordIdentifier& record) WARN_UNUSED_RESULT; | 205 const RecordIdentifier& record) WARN_UNUSED_RESULT; |
| 206 virtual leveldb::Status DeleteRange( | |
| 207 IndexedDBBackingStore::Transaction* transaction, | |
| 208 int64 database_id, | |
| 209 int64 object_store_id, | |
| 210 const IndexedDBKeyRange&) WARN_UNUSED_RESULT; | |
| 206 virtual leveldb::Status GetKeyGeneratorCurrentNumber( | 211 virtual leveldb::Status GetKeyGeneratorCurrentNumber( |
| 207 IndexedDBBackingStore::Transaction* transaction, | 212 IndexedDBBackingStore::Transaction* transaction, |
| 208 int64 database_id, | 213 int64 database_id, |
| 209 int64 object_store_id, | 214 int64 object_store_id, |
| 210 int64* current_number) WARN_UNUSED_RESULT; | 215 int64* current_number) WARN_UNUSED_RESULT; |
| 211 virtual leveldb::Status MaybeUpdateKeyGeneratorCurrentNumber( | 216 virtual leveldb::Status MaybeUpdateKeyGeneratorCurrentNumber( |
| 212 IndexedDBBackingStore::Transaction* transaction, | 217 IndexedDBBackingStore::Transaction* transaction, |
| 213 int64 database_id, | 218 int64 database_id, |
| 214 int64 object_store_id, | 219 int64 object_store_id, |
| 215 int64 new_state, | 220 int64 new_state, |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 382 ScopedVector<webkit_blob::BlobDataHandle> handles_; | 387 ScopedVector<webkit_blob::BlobDataHandle> handles_; |
| 383 DISALLOW_COPY_AND_ASSIGN(BlobChangeRecord); | 388 DISALLOW_COPY_AND_ASSIGN(BlobChangeRecord); |
| 384 }; | 389 }; |
| 385 typedef std::map<std::string, BlobChangeRecord*> BlobChangeMap; | 390 typedef std::map<std::string, BlobChangeRecord*> BlobChangeMap; |
| 386 | 391 |
| 387 class Transaction { | 392 class Transaction { |
| 388 public: | 393 public: |
| 389 explicit Transaction(IndexedDBBackingStore* backing_store); | 394 explicit Transaction(IndexedDBBackingStore* backing_store); |
| 390 virtual ~Transaction(); | 395 virtual ~Transaction(); |
| 391 virtual void Begin(); | 396 virtual void Begin(); |
| 392 virtual leveldb::Status Commit(); | 397 // The callback will be called eventually on success or failure, or |
| 398 // immediately if phase one is complete due to lack of any blobs to write. | |
| 399 virtual leveldb::Status CommitPhaseOne(scoped_refptr<BlobWriteCallback>); | |
| 400 virtual leveldb::Status CommitPhaseTwo(); | |
| 393 virtual void Rollback(); | 401 virtual void Rollback(); |
| 394 void Reset() { | 402 void Reset() { |
| 395 backing_store_ = NULL; | 403 backing_store_ = NULL; |
| 396 transaction_ = NULL; | 404 transaction_ = NULL; |
| 397 } | 405 } |
| 398 void PutBlobInfo(int64 database_id, | 406 void PutBlobInfo(int64 database_id, |
| 399 int64 object_store_id, | 407 int64 object_store_id, |
| 400 const std::string& object_store_data_key, | 408 const std::string& object_store_data_key, |
| 401 std::vector<IndexedDBBlobInfo>*, | 409 std::vector<IndexedDBBlobInfo>*, |
| 402 ScopedVector<webkit_blob::BlobDataHandle>* handles); | 410 ScopedVector<webkit_blob::BlobDataHandle>* handles); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 451 virtual ~ChainedBlobWriter() {} | 459 virtual ~ChainedBlobWriter() {} |
| 452 friend class base::RefCounted<ChainedBlobWriter>; | 460 friend class base::RefCounted<ChainedBlobWriter>; |
| 453 }; | 461 }; |
| 454 class ChainedBlobWriterImpl; | 462 class ChainedBlobWriterImpl; |
| 455 | 463 |
| 456 typedef std::vector<WriteDescriptor> WriteDescriptorVec; | 464 typedef std::vector<WriteDescriptor> WriteDescriptorVec; |
| 457 | 465 |
| 458 private: | 466 private: |
| 459 class BlobWriteCallbackWrapper; | 467 class BlobWriteCallbackWrapper; |
| 460 | 468 |
| 469 // These return true on success, false on failure. | |
|
cmumford
2014/05/28 20:34:54
Nit: You say "these", but the first one (HandleBlo
ericu
2014/05/28 22:50:42
Yup; the first one used to return bool before I ch
| |
| 470 leveldb::Status HandleBlobPreTransaction( | |
| 471 BlobEntryKeyValuePairVec* new_blob_entries, | |
| 472 WriteDescriptorVec* new_files_to_write); | |
| 473 bool CollectBlobFilesToRemove(); | |
| 461 // The callback will be called eventually on success or failure. | 474 // The callback will be called eventually on success or failure. |
| 462 void WriteNewBlobs(BlobEntryKeyValuePairVec& new_blob_entries, | 475 void WriteNewBlobs(BlobEntryKeyValuePairVec& new_blob_entries, |
| 463 WriteDescriptorVec& new_files_to_write, | 476 WriteDescriptorVec& new_files_to_write, |
| 464 scoped_refptr<BlobWriteCallback> callback); | 477 scoped_refptr<BlobWriteCallback> callback); |
| 478 leveldb::Status SortBlobsToRemove(); | |
| 465 | 479 |
| 466 IndexedDBBackingStore* backing_store_; | 480 IndexedDBBackingStore* backing_store_; |
| 467 scoped_refptr<LevelDBTransaction> transaction_; | 481 scoped_refptr<LevelDBTransaction> transaction_; |
| 468 BlobChangeMap blob_change_map_; | 482 BlobChangeMap blob_change_map_; |
| 469 BlobChangeMap incognito_blob_map_; | 483 BlobChangeMap incognito_blob_map_; |
| 470 int64 database_id_; | 484 int64 database_id_; |
| 485 BlobJournalType blobs_to_remove_; | |
| 471 scoped_refptr<ChainedBlobWriter> chained_blob_writer_; | 486 scoped_refptr<ChainedBlobWriter> chained_blob_writer_; |
| 472 }; | 487 }; |
| 473 | 488 |
| 474 protected: | 489 protected: |
| 475 IndexedDBBackingStore(IndexedDBFactory* indexed_db_factory, | 490 IndexedDBBackingStore(IndexedDBFactory* indexed_db_factory, |
| 476 const GURL& origin_url, | 491 const GURL& origin_url, |
| 477 const base::FilePath& blob_path, | 492 const base::FilePath& blob_path, |
| 478 net::URLRequestContext* request_context, | 493 net::URLRequestContext* request_context, |
| 479 scoped_ptr<LevelDBDatabase> db, | 494 scoped_ptr<LevelDBDatabase> db, |
| 480 scoped_ptr<LevelDBComparator> comparator, | 495 scoped_ptr<LevelDBComparator> comparator, |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 545 scoped_ptr<LevelDBComparator> comparator_; | 560 scoped_ptr<LevelDBComparator> comparator_; |
| 546 // Whenever blobs are registered in active_blob_registry_, indexed_db_factory_ | 561 // Whenever blobs are registered in active_blob_registry_, indexed_db_factory_ |
| 547 // will hold a reference to this backing store. | 562 // will hold a reference to this backing store. |
| 548 IndexedDBActiveBlobRegistry active_blob_registry_; | 563 IndexedDBActiveBlobRegistry active_blob_registry_; |
| 549 base::OneShotTimer<IndexedDBBackingStore> close_timer_; | 564 base::OneShotTimer<IndexedDBBackingStore> close_timer_; |
| 550 }; | 565 }; |
| 551 | 566 |
| 552 } // namespace content | 567 } // namespace content |
| 553 | 568 |
| 554 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ | 569 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ |
| OLD | NEW |