Skip to content
Permalink
Browse files
Drop some unnecessary code in SQLiteIDBBackingStore and IDBServer
https://bugs.webkit.org/show_bug.cgi?id=214992
<rdar://problem/66648514>

Reviewed by Brady Eidson.

No behavior change. Paths of SQLiteIDBBackingStore and IDBServer are only accessed from one thread now, so we
don't need to make isolated copy.

* Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::IDBServer::createBackingStore):
(WebCore::IDBServer::IDBServer::getAllDatabaseNamesAndVersions):
(WebCore::IDBServer::IDBServer::removeDatabasesModifiedSinceForVersion):
(WebCore::IDBServer::IDBServer::removeDatabasesWithOriginsForVersion):
(WebCore::IDBServer::IDBServer::renameOrigin):
(WebCore::IDBServer::IDBServer::upgradeFilesIfNecessary):
* Modules/indexeddb/server/IDBServer.h:
(WebCore::IDBServer::IDBServer::databaseDirectoryPathIsolatedCopy const): Deleted.
* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::fullDatabaseDirectoryWithUpgrade):
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteBackingStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::databaseNameFromEncodedFilename): Deleted.
* Modules/indexeddb/server/SQLiteIDBBackingStore.h:


Canonical link: https://commits.webkit.org/229942@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267823 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
szewai committed Oct 1, 2020
1 parent 8df57f1 commit 146b38644b677565770701244a117b1df5eab937
Showing 5 changed files with 38 additions and 33 deletions.
@@ -1,3 +1,29 @@
2020-10-01 Sihui Liu <sihui_liu@apple.com>

Drop some unnecessary code in SQLiteIDBBackingStore and IDBServer
https://bugs.webkit.org/show_bug.cgi?id=214992
<rdar://problem/66648514>

Reviewed by Brady Eidson.

No behavior change. Paths of SQLiteIDBBackingStore and IDBServer are only accessed from one thread now, so we
don't need to make isolated copy.

* Modules/indexeddb/server/IDBServer.cpp:
(WebCore::IDBServer::IDBServer::createBackingStore):
(WebCore::IDBServer::IDBServer::getAllDatabaseNamesAndVersions):
(WebCore::IDBServer::IDBServer::removeDatabasesModifiedSinceForVersion):
(WebCore::IDBServer::IDBServer::removeDatabasesWithOriginsForVersion):
(WebCore::IDBServer::IDBServer::renameOrigin):
(WebCore::IDBServer::IDBServer::upgradeFilesIfNecessary):
* Modules/indexeddb/server/IDBServer.h:
(WebCore::IDBServer::IDBServer::databaseDirectoryPathIsolatedCopy const): Deleted.
* Modules/indexeddb/server/SQLiteIDBBackingStore.cpp:
(WebCore::IDBServer::SQLiteIDBBackingStore::fullDatabaseDirectoryWithUpgrade):
(WebCore::IDBServer::SQLiteIDBBackingStore::deleteBackingStore):
(WebCore::IDBServer::SQLiteIDBBackingStore::databaseNameFromEncodedFilename): Deleted.
* Modules/indexeddb/server/SQLiteIDBBackingStore.h:

2020-10-01 Youenn Fablet <youenn@apple.com>

MediaRecorder should allow setting low bit rates for audio
@@ -128,16 +128,14 @@ UniqueIDBDatabase& IDBServer::getOrCreateUniqueIDBDatabase(const IDBDatabaseIden
std::unique_ptr<IDBBackingStore> IDBServer::createBackingStore(const IDBDatabaseIdentifier& identifier)
{
ASSERT(!isMainThread());

auto databaseDirectoryPath = this->databaseDirectoryPathIsolatedCopy();
if (databaseDirectoryPath.isEmpty())
if (m_databaseDirectoryPath.isEmpty())
return makeUnique<MemoryIDBBackingStore>(m_sessionID, identifier);

ASSERT(!m_sessionID.isEphemeral());
if (identifier.isTransient())
return makeUnique<MemoryIDBBackingStore>(m_sessionID, identifier);

return makeUnique<SQLiteIDBBackingStore>(m_sessionID, identifier, databaseDirectoryPath);
return makeUnique<SQLiteIDBBackingStore>(m_sessionID, identifier, m_databaseDirectoryPath);
}

void IDBServer::openDatabase(const IDBRequestData& requestData)
@@ -516,8 +514,7 @@ void IDBServer::getAllDatabaseNamesAndVersions(IDBConnectionIdentifier serverCon
ASSERT(!isMainThread());
ASSERT(m_lock.isHeld());

auto databaseDirectoryPath = this->databaseDirectoryPathIsolatedCopy();
String oldDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin.topOrigin, origin.clientOrigin, databaseDirectoryPath, "v0");
String oldDirectory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin.topOrigin, origin.clientOrigin, m_databaseDirectoryPath, "v0");
Vector<String> files = FileSystem::listDirectory(oldDirectory, "*"_s);
Vector<IDBDatabaseNameAndVersion> databases;
for (auto& file : files) {
@@ -526,7 +523,7 @@ void IDBServer::getAllDatabaseNamesAndVersions(IDBConnectionIdentifier serverCon
databases.append(WTFMove(*databaseTuple));
}

String directory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin.topOrigin, origin.clientOrigin, databaseDirectoryPath, "v1");
String directory = IDBDatabaseIdentifier::databaseDirectoryRelativeToRoot(origin.topOrigin, origin.clientOrigin, m_databaseDirectoryPath, "v1");
files = FileSystem::listDirectory(directory, "*"_s);
for (auto& file : files) {
auto databaseTuple = SQLiteIDBBackingStore::databaseNameAndVersionFromFile(SQLiteIDBBackingStore::fullDatabasePathForDirectory(file));
@@ -712,7 +709,7 @@ static void removeAllDatabasesForOriginPath(const String& originPath, WallTime m

void IDBServer::removeDatabasesModifiedSinceForVersion(WallTime modifiedSince, const String& version)
{
String versionPath = FileSystem::pathByAppendingComponent(databaseDirectoryPathIsolatedCopy(), version);
String versionPath = FileSystem::pathByAppendingComponent(m_databaseDirectoryPath, version);
for (auto& originPath : FileSystem::listDirectory(versionPath, "*")) {
String databaseIdentifier = FileSystem::lastComponentOfPathIgnoringTrailingSlash(originPath);
if (auto securityOrigin = SecurityOriginData::fromDatabaseIdentifier(databaseIdentifier))
@@ -722,7 +719,7 @@ void IDBServer::removeDatabasesModifiedSinceForVersion(WallTime modifiedSince, c

void IDBServer::removeDatabasesWithOriginsForVersion(const Vector<SecurityOriginData> &origins, const String& version)
{
String versionPath = FileSystem::pathByAppendingComponent(databaseDirectoryPathIsolatedCopy(), version);
String versionPath = FileSystem::pathByAppendingComponent(m_databaseDirectoryPath, version);
for (const auto& origin : origins) {
String originPath = FileSystem::pathByAppendingComponent(versionPath, origin.databaseIdentifier());
removeAllDatabasesForOriginPath(originPath, -WallTime::infinity());
@@ -741,7 +738,7 @@ void IDBServer::renameOrigin(const WebCore::SecurityOriginData& oldOrigin, const
return databaseOrigin.topOrigin == targetOrigin;
});

auto versionPath = FileSystem::pathByAppendingComponent(databaseDirectoryPathIsolatedCopy(), "v1");
auto versionPath = FileSystem::pathByAppendingComponent(m_databaseDirectoryPath, "v1");
auto oldOriginPath = FileSystem::pathByAppendingComponent(versionPath, oldOrigin.databaseIdentifier());
auto newOriginPath = FileSystem::pathByAppendingComponent(versionPath, newOrigin.databaseIdentifier());
if (FileSystem::fileExists(oldOriginPath))
@@ -774,11 +771,10 @@ uint64_t IDBServer::diskUsage(const String& rootDirectory, const ClientOrigin& o

void IDBServer::upgradeFilesIfNecessary()
{
auto databaseDirectoryPath = this->databaseDirectoryPathIsolatedCopy();
if (databaseDirectoryPath.isEmpty() || !FileSystem::fileExists(databaseDirectoryPath))
if (m_databaseDirectoryPath.isEmpty() || !FileSystem::fileExists(m_databaseDirectoryPath))
return;

String newVersionDirectory = FileSystem::pathByAppendingComponent(databaseDirectoryPath, "v1");
String newVersionDirectory = FileSystem::pathByAppendingComponent(m_databaseDirectoryPath, "v1");
if (!FileSystem::fileExists(newVersionDirectory))
FileSystem::makeAllDirectories(newVersionDirectory);
}
@@ -116,8 +116,6 @@ class IDBServer {

private:
UniqueIDBDatabase& getOrCreateUniqueIDBDatabase(const IDBDatabaseIdentifier&);

String databaseDirectoryPathIsolatedCopy() const { return m_databaseDirectoryPath.isolatedCopy(); }

void upgradeFilesIfNecessary();
void removeDatabasesModifiedSinceForVersion(WallTime, const String&);
@@ -1128,17 +1128,6 @@ std::unique_ptr<IDBDatabaseInfo> SQLiteIDBBackingStore::extractExistingDatabaseI
return databaseInfo;
}

String SQLiteIDBBackingStore::databaseNameFromEncodedFilename(const String& encodedName)
{
if (encodedName == "%00"_s)
return { };

String partiallyDecoded = encodedName;
partiallyDecoded.replace("%2E"_s, "."_s);

return FileSystem::decodeFromFilename(partiallyDecoded);
}

String SQLiteIDBBackingStore::filenameForDatabaseName() const
{
ASSERT(!m_identifier.databaseName().isNull());
@@ -1191,10 +1180,9 @@ Optional<IDBDatabaseNameAndVersion> SQLiteIDBBackingStore::databaseNameAndVersio

String SQLiteIDBBackingStore::fullDatabaseDirectoryWithUpgrade()
{
auto databaseRootDirectory = this->databaseRootDirectoryIsolatedCopy();
String oldOriginDirectory = m_identifier.databaseDirectoryRelativeToRoot(databaseRootDirectory, "v0");
String oldOriginDirectory = m_identifier.databaseDirectoryRelativeToRoot(m_databaseRootDirectory, "v0");
String oldDatabaseDirectory = FileSystem::pathByAppendingComponent(oldOriginDirectory, filenameForDatabaseName());
String newOriginDirectory = m_identifier.databaseDirectoryRelativeToRoot(databaseRootDirectory, "v1");
String newOriginDirectory = m_identifier.databaseDirectoryRelativeToRoot(m_databaseRootDirectory, "v1");
String fileNameHash = SQLiteFileSystem::computeHashForFileName(m_identifier.databaseName());
Vector<String> directoriesWithSameHash = FileSystem::listDirectory(newOriginDirectory, fileNameHash + "*");
String newDatabaseDirectory = FileSystem::pathByAppendingComponent(newOriginDirectory, fileNameHash);
@@ -3044,7 +3032,7 @@ void SQLiteIDBBackingStore::deleteBackingStore()

SQLiteFileSystem::deleteDatabaseFile(dbFilename);
SQLiteFileSystem::deleteEmptyDatabaseDirectory(m_databaseDirectory);
SQLiteFileSystem::deleteEmptyDatabaseDirectory(m_identifier.databaseDirectoryRelativeToRoot(databaseRootDirectoryIsolatedCopy()));
SQLiteFileSystem::deleteEmptyDatabaseDirectory(m_identifier.databaseDirectoryRelativeToRoot(m_databaseRootDirectory));
}

void SQLiteIDBBackingStore::unregisterCursor(SQLiteIDBCursor& cursor)
@@ -97,7 +97,6 @@ class SQLiteIDBBackingStore final : public IDBBackingStore {

IDBError getBlobRecordsForObjectStoreRecord(int64_t objectStoreRecord, Vector<String>& blobURLs, Vector<String>& blobFilePaths);

static String databaseNameFromEncodedFilename(const String&);
static uint64_t databasesSizeForDirectory(const String& directory);

String databaseDirectory() const { return m_databaseDirectory; };
@@ -110,8 +109,6 @@ class SQLiteIDBBackingStore final : public IDBBackingStore {
String filenameForDatabaseName() const;
String fullDatabasePath() const;
String fullDatabaseDirectoryWithUpgrade();

String databaseRootDirectoryIsolatedCopy() const { return m_databaseRootDirectory.isolatedCopy(); }

bool ensureValidRecordsTable();
bool ensureValidIndexRecordsTable();

0 comments on commit 146b386

Please sign in to comment.