Changeset 196191 in webkit
- Timestamp:
- Feb 5, 2016 2:30:04 PM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r196174 r196191 1 2016-02-05 Brady Eidson <beidson@apple.com> 2 3 Modern IDB: UniqueIDBDatabase's m_databaseInfo is unsafely used from multiple threads. 4 https://bugs.webkit.org/show_bug.cgi?id=153912 5 6 Reviewed by Alex Christensen. 7 8 No new tests (Anything testable about this patch is already covered by existing tests). 9 10 * Modules/indexeddb/server/IDBBackingStore.h: 11 12 * Modules/indexeddb/server/MemoryIDBBackingStore.cpp: 13 (WebCore::IDBServer::MemoryIDBBackingStore::infoForObjectStore): 14 * Modules/indexeddb/server/MemoryIDBBackingStore.h: 15 16 Teach the SQLiteIDBBackingStore to actually keep its m_databaseInfo up to date as it changes, 17 and to revert it when version change transactions abort: 18 * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp: 19 (WebCore::IDBServer::SQLiteIDBBackingStore::beginTransaction): 20 (WebCore::IDBServer::SQLiteIDBBackingStore::abortTransaction): 21 (WebCore::IDBServer::SQLiteIDBBackingStore::commitTransaction): 22 (WebCore::IDBServer::SQLiteIDBBackingStore::createObjectStore): 23 (WebCore::IDBServer::SQLiteIDBBackingStore::deleteObjectStore): 24 (WebCore::IDBServer::SQLiteIDBBackingStore::createIndex): 25 (WebCore::IDBServer::SQLiteIDBBackingStore::deleteIndex): 26 (WebCore::IDBServer::SQLiteIDBBackingStore::infoForObjectStore): 27 * Modules/indexeddb/server/SQLiteIDBBackingStore.h: 28 29 * Modules/indexeddb/server/UniqueIDBDatabase.cpp: 30 (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd): Use the IDBBackingStore's copy of the 31 IDBObjectStoreInfo, meant only for the database thread, instead of the UniqueIDBDatabase's copy, 32 which is meant only for the main thread. 33 1 34 2016-02-05 Alex Christensen <achristensen@webkit.org> 2 35 -
trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h
r195689 r196191 78 78 virtual IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBKeyData&, uint32_t count, IDBGetResult& outResult) = 0; 79 79 80 virtual IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier) = 0; 80 81 virtual void deleteBackingStore() = 0; 81 82 virtual bool supportsSimultaneousTransactions() = 0; -
trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp
r195689 r196191 482 482 } 483 483 484 IDBObjectStoreInfo* MemoryIDBBackingStore::infoForObjectStore(uint64_t objectStoreIdentifier) 485 { 486 ASSERT(m_databaseInfo); 487 return m_databaseInfo->infoForExistingObjectStore(objectStoreIdentifier); 488 } 489 484 490 void MemoryIDBBackingStore::deleteBackingStore() 485 491 { -
trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h
r195689 r196191 70 70 virtual IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBKeyData&, uint32_t count, IDBGetResult& outResult) override final; 71 71 72 virtual IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier) override final; 72 73 virtual void deleteBackingStore() override final; 73 74 virtual bool supportsSimultaneousTransactions() override final { return true; } -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp
r196038 r196191 613 613 ASSERT(m_sqliteDB); 614 614 ASSERT(m_sqliteDB->isOpen()); 615 ASSERT(m_databaseInfo); 615 616 616 617 auto addResult = m_transactions.add(info.identifier(), nullptr); … … 621 622 622 623 addResult.iterator->value = std::make_unique<SQLiteIDBTransaction>(*this, info); 623 return addResult.iterator->value->begin(*m_sqliteDB); 624 625 auto error = addResult.iterator->value->begin(*m_sqliteDB); 626 if (error.isNull() && info.mode() == IndexedDB::TransactionMode::VersionChange) 627 m_originalDatabaseInfoBeforeVersionChange = std::make_unique<IDBDatabaseInfo>(*m_databaseInfo); 628 629 return error; 624 630 } 625 631 … … 637 643 } 638 644 645 646 if (transaction->mode() == IndexedDB::TransactionMode::VersionChange) { 647 ASSERT(m_originalDatabaseInfoBeforeVersionChange); 648 m_databaseInfo = WTFMove(m_originalDatabaseInfoBeforeVersionChange); 649 } 650 639 651 return transaction->abort(); 640 652 } … … 653 665 } 654 666 655 return transaction->commit(); 667 auto error = transaction->commit(); 668 if (!error.isNull()) { 669 if (transaction->mode() == IndexedDB::TransactionMode::VersionChange) { 670 ASSERT(m_originalDatabaseInfoBeforeVersionChange); 671 m_databaseInfo = WTFMove(m_originalDatabaseInfoBeforeVersionChange); 672 } 673 } else 674 m_originalDatabaseInfoBeforeVersionChange = nullptr; 675 676 return error; 656 677 } 657 678 … … 703 724 } 704 725 726 m_databaseInfo->addExistingObjectStore(info); 727 705 728 return { }; 706 729 } … … 777 800 } 778 801 } 802 803 m_databaseInfo->deleteObjectStore(objectStoreIdentifier); 779 804 780 805 return true; … … 891 916 } 892 917 918 auto* objectStore = m_databaseInfo->infoForExistingObjectStore(info.objectStoreIdentifier()); 919 ASSERT(objectStore); 920 objectStore->addExistingIndex(info); 921 893 922 return { }; 894 923 } … … 1032 1061 } 1033 1062 } 1063 1064 auto* objectStore = m_databaseInfo->infoForExistingObjectStore(objectStoreIdentifier); 1065 ASSERT(objectStore); 1066 objectStore->deleteIndex(indexIdentifier); 1034 1067 1035 1068 return { }; … … 1623 1656 } 1624 1657 1658 IDBObjectStoreInfo* SQLiteIDBBackingStore::infoForObjectStore(uint64_t objectStoreIdentifier) 1659 { 1660 ASSERT(m_databaseInfo); 1661 return m_databaseInfo->infoForExistingObjectStore(objectStoreIdentifier); 1662 } 1663 1625 1664 void SQLiteIDBBackingStore::deleteBackingStore() 1626 1665 { -
trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h
r196038 r196191 74 74 virtual IDBError iterateCursor(const IDBResourceIdentifier& transactionIdentifier, const IDBResourceIdentifier& cursorIdentifier, const IDBKeyData&, uint32_t count, IDBGetResult& outResult) override final; 75 75 76 virtual IDBObjectStoreInfo* infoForObjectStore(uint64_t objectStoreIdentifier) override final; 76 77 virtual void deleteBackingStore() override final; 77 78 virtual bool supportsSimultaneousTransactions() override final { return false; } … … 105 106 IDBDatabaseIdentifier m_identifier; 106 107 std::unique_ptr<IDBDatabaseInfo> m_databaseInfo; 108 std::unique_ptr<IDBDatabaseInfo> m_originalDatabaseInfoBeforeVersionChange; 107 109 108 110 std::unique_ptr<SQLiteDatabase> m_sqliteDB; -
trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
r196021 r196191 691 691 IDBError error; 692 692 693 auto objectStoreInfo = m_databaseInfo->infoForExistingObjectStore(objectStoreIdentifier);693 auto* objectStoreInfo = m_backingStore->infoForObjectStore(objectStoreIdentifier); 694 694 if (!objectStoreInfo) { 695 695 error = IDBError(IDBDatabaseException::InvalidStateError, ASCIILiteral("Object store cannot be found in the backing store"));
Note: See TracChangeset
for help on using the changeset viewer.