Title: [289012] trunk/Source/WebKit
- Revision
- 289012
- Author
- [email protected]
- Date
- 2022-02-02 16:09:20 -0800 (Wed, 02 Feb 2022)
Log Message
Remove OriginStorageManager if it's not in use
https://bugs.webkit.org/show_bug.cgi?id=236029
Reviewed by Darin Adler.
We should remove OriginStorageManager if it does not contains in-memory data and its origin data is not being
used by any web process.
* NetworkProcess/storage/FileSystemStorageManager.cpp:
(WebKit::FileSystemStorageManager::isActive const):
* NetworkProcess/storage/FileSystemStorageManager.h:
* NetworkProcess/storage/NetworkStorageManager.cpp:
(WebKit::NetworkStorageManager::stopReceivingMessageFromConnection):
* NetworkProcess/storage/OriginStorageManager.cpp:
(WebKit::OriginStorageManager::StorageBucket::connectionClosed):
(WebKit::OriginStorageManager::StorageBucket::isActive const):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (289011 => 289012)
--- trunk/Source/WebKit/ChangeLog 2022-02-03 00:07:48 UTC (rev 289011)
+++ trunk/Source/WebKit/ChangeLog 2022-02-03 00:09:20 UTC (rev 289012)
@@ -1,3 +1,22 @@
+2022-02-02 Sihui Liu <[email protected]>
+
+ Remove OriginStorageManager if it's not in use
+ https://bugs.webkit.org/show_bug.cgi?id=236029
+
+ Reviewed by Darin Adler.
+
+ We should remove OriginStorageManager if it does not contains in-memory data and its origin data is not being
+ used by any web process.
+
+ * NetworkProcess/storage/FileSystemStorageManager.cpp:
+ (WebKit::FileSystemStorageManager::isActive const):
+ * NetworkProcess/storage/FileSystemStorageManager.h:
+ * NetworkProcess/storage/NetworkStorageManager.cpp:
+ (WebKit::NetworkStorageManager::stopReceivingMessageFromConnection):
+ * NetworkProcess/storage/OriginStorageManager.cpp:
+ (WebKit::OriginStorageManager::StorageBucket::connectionClosed):
+ (WebKit::OriginStorageManager::StorageBucket::isActive const):
+
2022-02-02 Timothy Hatcher <[email protected]>
Web Inspector: didShowExtensionTab needs to pass the frameID of the tab
Modified: trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageManager.cpp (289011 => 289012)
--- trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageManager.cpp 2022-02-03 00:07:48 UTC (rev 289011)
+++ trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageManager.cpp 2022-02-03 00:09:20 UTC (rev 289012)
@@ -46,6 +46,11 @@
close();
}
+bool FileSystemStorageManager::isActive() const
+{
+ return !m_handles.isEmpty();
+}
+
Expected<WebCore::FileSystemHandleIdentifier, FileSystemStorageError> FileSystemStorageManager::createHandle(IPC::Connection::UniqueID connection, FileSystemStorageHandle::Type type, String&& path, String&& name, bool createIfNecessary)
{
ASSERT(!RunLoop::isMain());
Modified: trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageManager.h (289011 => 289012)
--- trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageManager.h 2022-02-03 00:07:48 UTC (rev 289011)
+++ trunk/Source/WebKit/NetworkProcess/storage/FileSystemStorageManager.h 2022-02-03 00:09:20 UTC (rev 289012)
@@ -39,6 +39,7 @@
FileSystemStorageManager(String&& path, FileSystemStorageHandleRegistry&);
~FileSystemStorageManager();
+ bool isActive() const;
Expected<WebCore::FileSystemHandleIdentifier, FileSystemStorageError> createHandle(IPC::Connection::UniqueID, FileSystemStorageHandle::Type, String&& path, String&& name, bool createIfNecessary);
const String& getPath(WebCore::FileSystemHandleIdentifier);
FileSystemStorageHandle::Type getType(WebCore::FileSystemHandleIdentifier);
Modified: trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp (289011 => 289012)
--- trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp 2022-02-03 00:07:48 UTC (rev 289011)
+++ trunk/Source/WebKit/NetworkProcess/storage/NetworkStorageManager.cpp 2022-02-03 00:09:20 UTC (rev 289012)
@@ -170,8 +170,11 @@
connection.removeWorkQueueMessageReceiver(Messages::NetworkStorageManager::messageReceiverName());
m_queue->dispatch([this, protectedThis = Ref { *this }, connection = connection.uniqueID()]() mutable {
- for (auto& originStorageManager : m_localOriginStorageManagers.values())
- originStorageManager->connectionClosed(connection);
+ m_localOriginStorageManagers.removeIf([&](auto& entry) {
+ auto& manager = entry.value;
+ manager->connectionClosed(connection);
+ return !manager->isActive();
+ });
RunLoop::main().dispatch([protectedThis = WTFMove(protectedThis)] { });
});
Modified: trunk/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp (289011 => 289012)
--- trunk/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp 2022-02-03 00:07:48 UTC (rev 289011)
+++ trunk/Source/WebKit/NetworkProcess/storage/OriginStorageManager.cpp 2022-02-03 00:09:20 UTC (rev 289012)
@@ -58,6 +58,12 @@
{
if (m_fileSystemStorageManager)
m_fileSystemStorageManager->connectionClosed(connection);
+
+ if (m_localStorageManager)
+ m_localStorageManager->connectionClosed(connection);
+
+ if (m_sessionStorageManager)
+ m_sessionStorageManager->connectionClosed(connection);
}
enum class StorageType : uint8_t {
@@ -139,7 +145,11 @@
bool isActive() const
{
- return m_fileSystemStorageManager || m_localStorageManager || m_sessionStorageManager;
+ // We cannot remove the bucket if it has in-memory data, otherwise session
+ // data may be lost.
+ return (m_fileSystemStorageManager && m_fileSystemStorageManager->isActive())
+ || (m_localStorageManager && (m_localStorageManager->hasDataInMemory() || m_localStorageManager->isActive()))
+ || (m_sessionStorageManager && (m_sessionStorageManager->hasDataInMemory() || m_sessionStorageManager->isActive()));
}
bool isEmpty() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes