Diff
Modified: trunk/Source/WebCore/ChangeLog (192162 => 192163)
--- trunk/Source/WebCore/ChangeLog 2015-11-09 18:35:19 UTC (rev 192162)
+++ trunk/Source/WebCore/ChangeLog 2015-11-09 18:36:45 UTC (rev 192163)
@@ -1,3 +1,34 @@
+2015-11-09 Brady Eidson <beid...@apple.com>
+
+ Modern IDB: Refactor memory objectstore/transaction interation.
+ https://bugs.webkit.org/show_bug.cgi?id=151014
+
+ Reviewed by Darin Adler.
+
+ No new tests (Refactor, no change in behavior).
+
+ * Modules/indexeddb/server/IDBBackingStore.h:
+
+ * Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp:
+ (WebCore::IDBServer::MemoryBackingStoreTransaction::recordValueChanged):
+ (WebCore::IDBServer::MemoryBackingStoreTransaction::abort):
+ * Modules/indexeddb/server/MemoryBackingStoreTransaction.h:
+
+ * Modules/indexeddb/server/MemoryIDBBackingStore.cpp:
+ (WebCore::IDBServer::MemoryIDBBackingStore::addRecord):
+ (WebCore::IDBServer::MemoryIDBBackingStore::putRecord): Deleted. Renamed to addRecord.
+ * Modules/indexeddb/server/MemoryIDBBackingStore.h:
+
+ * Modules/indexeddb/server/MemoryObjectStore.cpp:
+ (WebCore::IDBServer::MemoryObjectStore::deleteRecord):
+ (WebCore::IDBServer::MemoryObjectStore::addRecord):
+ (WebCore::IDBServer::MemoryObjectStore::putRecord): Deleted. Renamed to addRecord.
+ (WebCore::IDBServer::MemoryObjectStore::setKeyValue): Deleted. Folded into addRecord.
+ * Modules/indexeddb/server/MemoryObjectStore.h:
+
+ * Modules/indexeddb/server/UniqueIDBDatabase.cpp:
+ (WebCore::IDBServer::UniqueIDBDatabase::performPutOrAdd):
+
2015-11-09 Said Abou-Hallawa <sabouhall...@apple.com>
REGRESSION (r190883): Error calculating the tile size for an SVG with no intrinsic size but with large floating intrinsic ratio
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h (192162 => 192163)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2015-11-09 18:35:19 UTC (rev 192162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBBackingStore.h 2015-11-09 18:36:45 UTC (rev 192163)
@@ -65,7 +65,7 @@
virtual IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) = 0;
virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) = 0;
virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) = 0;
- virtual IDBError putRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& value) = 0;
+ virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& value) = 0;
virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) = 0;
virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) = 0;
virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) = 0;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp (192162 => 192163)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp 2015-11-09 18:35:19 UTC (rev 192162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.cpp 2015-11-09 18:36:45 UTC (rev 192163)
@@ -132,7 +132,7 @@
addResult.iterator->value = WTF::move(keyValueMap);
}
-void MemoryBackingStoreTransaction::recordValueChanged(MemoryObjectStore& objectStore, const IDBKeyData& key)
+void MemoryBackingStoreTransaction::recordValueChanged(MemoryObjectStore& objectStore, const IDBKeyData& key, ThreadSafeDataBuffer* value)
{
ASSERT(m_objectStores.contains(&objectStore));
@@ -154,7 +154,8 @@
if (!addResult.isNewEntry)
return;
- addResult.iterator->value = objectStore.valueForKeyRange(IDBKeyRangeData(key));
+ if (value)
+ addResult.iterator->value = *value;
}
void MemoryBackingStoreTransaction::abort()
@@ -197,7 +198,7 @@
for (auto entry : *keyValueMap) {
objectStore->deleteRecord(entry.key);
- objectStore->setKeyValue(entry.key, entry.value);
+ objectStore->addRecord(*this, entry.key, entry.value);
}
}
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h (192162 => 192163)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h 2015-11-09 18:35:19 UTC (rev 192162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryBackingStoreTransaction.h 2015-11-09 18:36:45 UTC (rev 192163)
@@ -59,7 +59,8 @@
void addNewObjectStore(MemoryObjectStore&);
void addExistingObjectStore(MemoryObjectStore&);
- void recordValueChanged(MemoryObjectStore&, const IDBKeyData&);
+
+ void recordValueChanged(MemoryObjectStore&, const IDBKeyData&, ThreadSafeDataBuffer*);
void objectStoreDeleted(std::unique_ptr<MemoryObjectStore>);
void objectStoreCleared(MemoryObjectStore&, std::unique_ptr<KeyValueMap>&&);
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp (192162 => 192163)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp 2015-11-09 18:35:19 UTC (rev 192162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.cpp 2015-11-09 18:36:45 UTC (rev 192163)
@@ -244,9 +244,9 @@
return IDBError();
}
-IDBError MemoryIDBBackingStore::putRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
+IDBError MemoryIDBBackingStore::addRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
{
- LOG(IndexedDB, "MemoryIDBBackingStore::putRecord");
+ LOG(IndexedDB, "MemoryIDBBackingStore::addRecord");
ASSERT(objectStoreIdentifier);
@@ -258,7 +258,7 @@
if (!objectStore)
return IDBError(IDBExceptionCode::Unknown, WTF::ASCIILiteral("No backing store object store found to put record"));
- objectStore->putRecord(*transaction, keyData, value);
+ objectStore->addRecord(*transaction, keyData, value);
return IDBError();
}
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h (192162 => 192163)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h 2015-11-09 18:35:19 UTC (rev 192162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryIDBBackingStore.h 2015-11-09 18:36:45 UTC (rev 192163)
@@ -58,7 +58,7 @@
virtual IDBError createIndex(const IDBResourceIdentifier& transactionIdentifier, const IDBIndexInfo&) override final;
virtual IDBError keyExistsInObjectStore(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, bool& keyExists) override final;
virtual IDBError deleteRange(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&) override final;
- virtual IDBError putRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& value) override final;
+ virtual IDBError addRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyData&, const ThreadSafeDataBuffer& value) override final;
virtual IDBError getRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, const IDBKeyRangeData&, ThreadSafeDataBuffer& outValue) override final;
virtual IDBError getIndexRecord(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, IndexedDB::IndexRecordType, const IDBKeyRangeData&, IDBGetResult& outValue) override final;
virtual IDBError getCount(const IDBResourceIdentifier& transactionIdentifier, uint64_t objectStoreIdentifier, uint64_t indexIdentifier, const IDBKeyRangeData&, uint64_t& outCount) override final;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp (192162 => 192163)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp 2015-11-09 18:35:19 UTC (rev 192162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.cpp 2015-11-09 18:36:45 UTC (rev 192163)
@@ -115,14 +115,22 @@
LOG(IndexedDB, "MemoryObjectStore::deleteRecord");
ASSERT(m_writeTransaction);
- m_writeTransaction->recordValueChanged(*this, key);
- if (!m_keyValueStore)
+ if (!m_keyValueStore) {
+ m_writeTransaction->recordValueChanged(*this, key, nullptr);
return;
+ }
ASSERT(m_orderedKeys);
- m_keyValueStore->remove(key);
+ auto iterator = m_keyValueStore->find(key);
+ if (iterator == m_keyValueStore->end()) {
+ m_writeTransaction->recordValueChanged(*this, key, nullptr);
+ return;
+ }
+
+ m_writeTransaction->recordValueChanged(*this, key, &iterator->value);
+ m_keyValueStore->remove(iterator);
m_orderedKeys->erase(key);
}
@@ -150,20 +158,15 @@
}
}
-void MemoryObjectStore::putRecord(MemoryBackingStoreTransaction& transaction, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
+void MemoryObjectStore::addRecord(MemoryBackingStoreTransaction& transaction, const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
{
- LOG(IndexedDB, "MemoryObjectStore::putRecord");
+ LOG(IndexedDB, "MemoryObjectStore::addRecord");
ASSERT(m_writeTransaction);
ASSERT_UNUSED(transaction, m_writeTransaction == &transaction);
+ ASSERT(!m_keyValueStore || !m_keyValueStore->contains(keyData));
+ ASSERT(!m_orderedKeys || m_orderedKeys->find(keyData) == m_orderedKeys->end());
- m_writeTransaction->recordValueChanged(*this, keyData);
-
- setKeyValue(keyData, value);
-}
-
-void MemoryObjectStore::setKeyValue(const IDBKeyData& keyData, const ThreadSafeDataBuffer& value)
-{
if (!m_keyValueStore) {
ASSERT(!m_orderedKeys);
m_keyValueStore = std::make_unique<KeyValueMap>();
Modified: trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h (192162 => 192163)
--- trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h 2015-11-09 18:35:19 UTC (rev 192162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/MemoryObjectStore.h 2015-11-09 18:36:45 UTC (rev 192163)
@@ -67,10 +67,8 @@
bool containsRecord(const IDBKeyData&);
void deleteRecord(const IDBKeyData&);
void deleteRange(const IDBKeyRangeData&);
- void putRecord(MemoryBackingStoreTransaction&, const IDBKeyData&, const ThreadSafeDataBuffer& value);
+ void addRecord(MemoryBackingStoreTransaction&, const IDBKeyData&, const ThreadSafeDataBuffer& value);
- void setKeyValue(const IDBKeyData&, const ThreadSafeDataBuffer& value);
-
uint64_t currentKeyGeneratorValue() const { return m_keyGeneratorValue; }
void setKeyGeneratorValue(uint64_t value) { m_keyGeneratorValue = value; }
Modified: trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp (192162 => 192163)
--- trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2015-11-09 18:35:19 UTC (rev 192162)
+++ trunk/Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp 2015-11-09 18:36:45 UTC (rev 192163)
@@ -434,7 +434,7 @@
return;
}
- error = m_backingStore->putRecord(transactionIdentifier, objectStoreIdentifier, usedKey, valueData);
+ error = m_backingStore->addRecord(transactionIdentifier, objectStoreIdentifier, usedKey, valueData);
m_server.postDatabaseTaskReply(createCrossThreadTask(*this, &UniqueIDBDatabase::didPerformPutOrAdd, callbackIdentifier, error, usedKey));
}