Diff
Modified: trunk/Source/WebCore/ChangeLog (248376 => 248377)
--- trunk/Source/WebCore/ChangeLog 2019-08-07 17:31:10 UTC (rev 248376)
+++ trunk/Source/WebCore/ChangeLog 2019-08-07 18:05:12 UTC (rev 248377)
@@ -1,3 +1,41 @@
+2019-08-07 Youenn Fablet <[email protected]>
+
+ Remove IDBDatabaseIdentifier::m_sessionID
+ https://bugs.webkit.org/show_bug.cgi?id=200489
+
+ Reviewed by Darin Adler.
+
+ IDBDatabaseIdentifier can be created without a valid session ID.
+ Its session ID is only used in NetworkProcess where it can be retrieved from the IDBServer.
+ In WebProcess, session ID is also known from the IDB connection.
+ Update SQLiteIDBBackingStore to store a session ID which is given from its IDBServer.
+ No observable change of behavior.
+
+ * Modules/indexeddb/IDBDatabaseIdentifier.cpp:
+ (WebCore::IDBDatabaseIdentifier::IDBDatabaseIdentifier):
+ (WebCore::IDBDatabaseIdentifier::isolatedCopy const):
+ * Modules/indexeddb/IDBDatabaseIdentifier.h:
+ (WebCore::IDBDatabaseIdentifier::hash const):
+ (WebCore::IDBDatabaseIdentifier::databaseName const):
+ (WebCore::IDBDatabaseIdentifier::encode const):
+ (WebCore::IDBDatabaseIdentifier::decode):
+ (WebCore::IDBDatabaseIdentifier::sessionID const): Deleted.
+ * Modules/indexeddb/IDBFactory.cpp:
+ (WebCore::IDBFactory::openInternal):
+ (WebCore::IDBFactory::deleteDatabase):
+ * Modules/indexeddb/server/IDBServer.cpp:
+ (WebCore::IDBServer::IDBServer::createBackingStore):
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
+ (WebCore::IDBServer::SQLiteIDBBackingStore::SQLiteIDBBackingStore):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::getBlobRecordsForObjectStoreRecord):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::getRecord):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::getAllObjectStoreRecords):
+ (WebCore::IDBServer::SQLiteIDBBackingStore::uncheckedGetIndexRecordForOneKey):
+ * Modules/indexeddb/server/SQLiteIDBBackingStore.h:
+ (WebCore::IDBServer::SQLiteIDBBackingStore::sessionID const):
+ * Modules/indexeddb/server/SQLiteIDBCursor.cpp:
+ (WebCore::IDBServer::SQLiteIDBCursor::internalFetchNextRecord):
+
2019-08-07 Chris Dumez <[email protected]>
Fix thread safety issue under JSHistory::visitAdditionalChildren()
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp (248376 => 248377)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp 2019-08-07 17:31:10 UTC (rev 248376)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp 2019-08-07 18:05:12 UTC (rev 248377)
@@ -35,9 +35,8 @@
namespace WebCore {
-IDBDatabaseIdentifier::IDBDatabaseIdentifier(const String& databaseName, const PAL::SessionID& sessionID, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin)
+IDBDatabaseIdentifier::IDBDatabaseIdentifier(const String& databaseName, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin)
: m_databaseName(databaseName)
- , m_sessionID(sessionID)
, m_origin { WTFMove(openingOrigin), WTFMove(mainFrameOrigin) }
{
// The empty string is a valid database name, but a null string is not.
@@ -49,7 +48,6 @@
IDBDatabaseIdentifier identifier;
identifier.m_databaseName = m_databaseName.isolatedCopy();
- identifier.m_sessionID = m_sessionID.isolatedCopy();
identifier.m_origin = m_origin.isolatedCopy();
return identifier;
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h (248376 => 248377)
--- trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h 2019-08-07 17:31:10 UTC (rev 248376)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.h 2019-08-07 18:05:12 UTC (rev 248377)
@@ -45,7 +45,7 @@
{
}
- WEBCORE_EXPORT IDBDatabaseIdentifier(const String& databaseName, const PAL::SessionID&, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin);
+ WEBCORE_EXPORT IDBDatabaseIdentifier(const String& databaseName, SecurityOriginData&& openingOrigin, SecurityOriginData&& mainFrameOrigin);
IDBDatabaseIdentifier isolatedCopy() const;
@@ -57,10 +57,9 @@
unsigned hash() const
{
unsigned nameHash = StringHash::hash(m_databaseName);
- unsigned sessionIDHash = WTF::SessionIDHash::hash(m_sessionID);
unsigned originHash = m_origin.hash();
- unsigned hashCodes[3] = { nameHash, sessionIDHash, originHash };
+ unsigned hashCodes[2] = { nameHash, originHash };
return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
}
@@ -81,7 +80,6 @@
}
const String& databaseName() const { return m_databaseName; }
- const PAL::SessionID& sessionID() const { return m_sessionID; }
const ClientOrigin& origin() const { return m_origin; }
String databaseDirectoryRelativeToRoot(const String& rootDirectory, const String& versionString="v1") const;
@@ -98,7 +96,6 @@
private:
String m_databaseName;
- PAL::SessionID m_sessionID;
ClientOrigin m_origin;
SecurityOriginData m_mainFrameOrigin;
};
@@ -118,7 +115,7 @@
template<class Encoder>
void IDBDatabaseIdentifier::encode(Encoder& encoder) const
{
- encoder << m_databaseName << m_sessionID << m_origin;
+ encoder << m_databaseName << m_origin;
}
template<class Decoder>
@@ -129,11 +126,6 @@
if (!databaseName)
return WTF::nullopt;
- Optional<PAL::SessionID> sessionID;
- decoder >> sessionID;
- if (!sessionID)
- return WTF::nullopt;
-
Optional<ClientOrigin> origin;
decoder >> origin;
if (!origin)
@@ -141,7 +133,6 @@
IDBDatabaseIdentifier identifier;
identifier.m_databaseName = WTFMove(*databaseName); // FIXME: When decoding from IPC, databaseName can be null, and the non-empty constructor asserts that this is not the case.
- identifier.m_sessionID = WTFMove(*sessionID);
identifier.m_origin = WTFMove(*origin);
return identifier;
}
Modified: trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp (248376 => 248377)
--- trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2019-08-07 17:31:10 UTC (rev 248376)
+++ trunk/Source/WebCore/Modules/indexeddb/IDBFactory.cpp 2019-08-07 18:05:12 UTC (rev 248377)
@@ -91,7 +91,7 @@
return Exception { SecurityError, "IDBFactory.open() called in an invalid security context"_s };
ASSERT(context.securityOrigin());
- IDBDatabaseIdentifier databaseIdentifier(name, context.sessionID(), SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() });
+ IDBDatabaseIdentifier databaseIdentifier(name, SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() });
if (!databaseIdentifier.isValid())
return Exception { TypeError, "IDBFactory.open() called with an invalid security origin"_s };
@@ -111,7 +111,7 @@
return Exception { SecurityError, "IDBFactory.deleteDatabase() called in an invalid security context"_s };
ASSERT(context.securityOrigin());
- IDBDatabaseIdentifier databaseIdentifier(name, context.sessionID(), SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() });
+ IDBDatabaseIdentifier databaseIdentifier(name, SecurityOriginData { context.securityOrigin()->data() }, SecurityOriginData { context.topOrigin().data() });
if (!databaseIdentifier.isValid())
return Exception { TypeError, "IDBFactory.deleteDatabase() called with an invalid security origin"_s };
Modified: trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp (248376 => 248377)
--- trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2019-08-07 17:31:10 UTC (rev 248376)
+++ trunk/Source/WebCore/Modules/indexeddb/server/IDBServer.cpp 2019-08-07 18:05:12 UTC (rev 248377)
@@ -135,7 +135,7 @@
if (m_databaseDirectoryPath.isEmpty())
return MemoryIDBBackingStore::create(identifier);
- return std::make_unique<SQLiteIDBBackingStore>(identifier, m_databaseDirectoryPath, m_backingStoreTemporaryFileHandler, m_perOriginQuota);
+ return std::make_unique<SQLiteIDBBackingStore>(m_sessionID, identifier, m_databaseDirectoryPath, m_backingStoreTemporaryFileHandler, m_perOriginQuota);
}
void IDBServer::openDatabase(const IDBRequestData& requestData)
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp (248376 => 248377)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2019-08-07 17:31:10 UTC (rev 248376)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.cpp 2019-08-07 18:05:12 UTC (rev 248377)
@@ -228,8 +228,9 @@
return blobFilesTableSchemaString;
}
-SQLiteIDBBackingStore::SQLiteIDBBackingStore(const IDBDatabaseIdentifier& identifier, const String& databaseRootDirectory, IDBBackingStoreTemporaryFileHandler& fileHandler, uint64_t quota)
- : m_identifier(identifier)
+SQLiteIDBBackingStore::SQLiteIDBBackingStore(PAL::SessionID sessionID, const IDBDatabaseIdentifier& identifier, const String& databaseRootDirectory, IDBBackingStoreTemporaryFileHandler& fileHandler, uint64_t quota)
+ : m_sessionID(sessionID)
+ , m_identifier(identifier)
, m_databaseRootDirectory(databaseRootDirectory)
, m_temporaryFileHandler(fileHandler)
, m_quota(quota)
@@ -1905,7 +1906,7 @@
return error;
}
-IDBError SQLiteIDBBackingStore::getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, PAL::SessionID& sessionID, Vector<String>& blobFilePaths)
+IDBError SQLiteIDBBackingStore::getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, Vector<String>& blobFilePaths)
{
ASSERT(objectStoreRecord);
@@ -1954,8 +1955,6 @@
String fileName = sql->getColumnText(0);
blobFilePaths.append(FileSystem::pathByAppendingComponent(m_databaseDirectory, fileName));
}
- sessionID = m_identifier.sessionID();
-
return IDBError { };
}
@@ -2082,8 +2081,7 @@
ASSERT(recordID);
Vector<String> blobURLs, blobFilePaths;
- PAL::SessionID sessionID;
- auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, sessionID, blobFilePaths);
+ auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, blobFilePaths);
ASSERT(blobURLs.size() == blobFilePaths.size());
if (!error.isNull())
@@ -2091,7 +2089,7 @@
auto* objectStoreInfo = infoForObjectStore(objectStoreID);
ASSERT(objectStoreInfo);
- resultValue = { keyData, { valueResultBuffer, WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) }, objectStoreInfo->keyPath()};
+ resultValue = { keyData, { valueResultBuffer, WTFMove(blobURLs), m_sessionID, WTFMove(blobFilePaths) }, objectStoreInfo->keyPath()};
return IDBError { };
}
@@ -2204,14 +2202,13 @@
ASSERT(recordID);
Vector<String> blobURLs, blobFilePaths;
- PAL::SessionID sessionID;
- auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, sessionID, blobFilePaths);
+ auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, blobFilePaths);
ASSERT(blobURLs.size() == blobFilePaths.size());
if (!error.isNull())
return error;
- result.addValue({ valueResultBuffer, WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) });
+ result.addValue({ valueResultBuffer, WTFMove(blobURLs), m_sessionID, WTFMove(blobFilePaths) });
}
++returnedResults;
@@ -2366,8 +2363,7 @@
int64_t recordID = sql->getColumnInt64(2);
Vector<String> blobURLs, blobFilePaths;
- PAL::SessionID sessionID;
- auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, sessionID, blobFilePaths);
+ auto error = getBlobRecordsForObjectStoreRecord(recordID, blobURLs, blobFilePaths);
ASSERT(blobURLs.size() == blobFilePaths.size());
if (!error.isNull())
@@ -2375,7 +2371,7 @@
auto* objectStoreInfo = infoForObjectStore(objectStoreID);
ASSERT(objectStoreInfo);
- getResult = { objectStoreKey, objectStoreKey, { ThreadSafeDataBuffer::create(WTFMove(valueVector)), WTFMove(blobURLs), sessionID, WTFMove(blobFilePaths) }, objectStoreInfo->keyPath() };
+ getResult = { objectStoreKey, objectStoreKey, { ThreadSafeDataBuffer::create(WTFMove(valueVector)), WTFMove(blobURLs), m_sessionID, WTFMove(blobFilePaths) }, objectStoreInfo->keyPath() };
return IDBError { };
}
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h (248376 => 248377)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2019-08-07 17:31:10 UTC (rev 248376)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBBackingStore.h 2019-08-07 18:05:12 UTC (rev 248377)
@@ -48,7 +48,7 @@
class SQLiteIDBBackingStore : public IDBBackingStore {
WTF_MAKE_FAST_ALLOCATED;
public:
- SQLiteIDBBackingStore(const IDBDatabaseIdentifier&, const String& databaseRootDirectory, IDBBackingStoreTemporaryFileHandler&, uint64_t quota);
+ SQLiteIDBBackingStore(PAL::SessionID, const IDBDatabaseIdentifier&, const String& databaseRootDirectory, IDBBackingStoreTemporaryFileHandler&, uint64_t quota);
~SQLiteIDBBackingStore() final;
@@ -91,7 +91,7 @@
IDBBackingStoreTemporaryFileHandler& temporaryFileHandler() const { return m_temporaryFileHandler; }
- IDBError getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, PAL::SessionID&, Vector<String>& blobFilePaths);
+ IDBError getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, Vector<String>& blobFilePaths);
static String databaseNameFromEncodedFilename(const String&);
static uint64_t databasesSizeForFolder(const String& folder);
@@ -101,6 +101,9 @@
static String databaseNameFromFile(const String&);
bool hasTransaction(const IDBResourceIdentifier&) const final;
+
+ PAL::SessionID sessionID() const { return m_sessionID; }
+
private:
String filenameForDatabaseName() const;
String fullDatabasePath() const;
@@ -191,6 +194,7 @@
JSC::JSGlobalObject& globalObject();
void initializeVM();
+ PAL::SessionID m_sessionID;
IDBDatabaseIdentifier m_identifier;
std::unique_ptr<IDBDatabaseInfo> m_databaseInfo;
std::unique_ptr<IDBDatabaseInfo> m_originalDatabaseInfoBeforeVersionChange;
Modified: trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp (248376 => 248377)
--- trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp 2019-08-07 17:31:10 UTC (rev 248376)
+++ trunk/Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp 2019-08-07 18:05:12 UTC (rev 248377)
@@ -456,8 +456,7 @@
record.record.primaryKey = record.record.key;
Vector<String> blobURLs, blobFilePaths;
- PAL::SessionID sessionID;
- auto error = m_transaction->backingStore().getBlobRecordsForObjectStoreRecord(record.rowID, blobURLs, sessionID, blobFilePaths);
+ auto error = m_transaction->backingStore().getBlobRecordsForObjectStoreRecord(record.rowID, blobURLs, blobFilePaths);
if (!error.isNull()) {
LOG_ERROR("Unable to fetch blob records from database while advancing cursor");
markAsErrored(record);
@@ -465,7 +464,7 @@
}
if (m_cursorType == IndexedDB::CursorType::KeyAndValue)
- record.record.value = std::make_unique<IDBValue>(ThreadSafeDataBuffer::create(WTFMove(keyData)), blobURLs, sessionID, blobFilePaths);
+ record.record.value = std::make_unique<IDBValue>(ThreadSafeDataBuffer::create(WTFMove(keyData)), blobURLs, m_transaction->backingStore().sessionID(), blobFilePaths);
} else {
if (!deserializeIDBKeyData(keyData.data(), keyData.size(), record.record.primaryKey)) {
LOG_ERROR("Unable to deserialize value data from database while advancing index cursor");