Random StorageProcess and SWServer cleanup.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Oct 2017 21:03:04 +0000 (21:03 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 10 Oct 2017 21:03:04 +0000 (21:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=178141

Reviewed by Andy Estes.

-StorageProcess should own the set of SWServers
-Some renaming and cleanup

* StorageProcess/StorageProcess.cpp:
(WebKit::StorageProcess::createStorageToWebProcessConnection):
(WebKit::StorageProcess::swServerForSession):
* StorageProcess/StorageProcess.h:
(WebKit::StorageProcess::queue):

* StorageProcess/StorageToWebProcessConnection.cpp:
(WebKit::StorageToWebProcessConnection::establishSWServerConnection):
* StorageProcess/StorageToWebProcessConnection.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223141 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/ChangeLog
Source/WebKit/StorageProcess/StorageProcess.cpp
Source/WebKit/StorageProcess/StorageProcess.h
Source/WebKit/StorageProcess/StorageToWebProcessConnection.cpp
Source/WebKit/StorageProcess/StorageToWebProcessConnection.h

index b3b09fa..ae3ef35 100644 (file)
@@ -1,3 +1,23 @@
+2017-10-10  Brady Eidson  <beidson@apple.com>
+
+        Random StorageProcess and SWServer cleanup.
+        https://bugs.webkit.org/show_bug.cgi?id=178141
+
+        Reviewed by Andy Estes.
+
+        -StorageProcess should own the set of SWServers
+        -Some renaming and cleanup
+
+        * StorageProcess/StorageProcess.cpp:
+        (WebKit::StorageProcess::createStorageToWebProcessConnection):
+        (WebKit::StorageProcess::swServerForSession):
+        * StorageProcess/StorageProcess.h:
+        (WebKit::StorageProcess::queue):
+
+        * StorageProcess/StorageToWebProcessConnection.cpp:
+        (WebKit::StorageToWebProcessConnection::establishSWServerConnection):
+        * StorageProcess/StorageToWebProcessConnection.h:
+
 2017-10-10  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         Unreviewed, rolling out r223136.
index 5cd93dc..2ef73a8 100644 (file)
@@ -164,7 +164,7 @@ void StorageProcess::createStorageToWebProcessConnection()
 {
 #if USE(UNIX_DOMAIN_SOCKETS)
     IPC::Connection::SocketPair socketPair = IPC::Connection::createPlatformConnection();
-    m_databaseToWebProcessConnections.append(StorageToWebProcessConnection::create(socketPair.server));
+    m_storageToWebProcessConnections.append(StorageToWebProcessConnection::create(socketPair.server));
     parentProcessConnection()->send(Messages::StorageProcessProxy::DidCreateStorageToWebProcessConnection(IPC::Attachment(socketPair.client)), 0);
 #elif OS(DARWIN)
     // Create the listening port.
@@ -172,7 +172,7 @@ void StorageProcess::createStorageToWebProcessConnection()
     mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &listeningPort);
 
     // Create a listening connection.
-    m_databaseToWebProcessConnections.append(StorageToWebProcessConnection::create(IPC::Connection::Identifier(listeningPort)));
+    m_storageToWebProcessConnections.append(StorageToWebProcessConnection::create(IPC::Connection::Identifier(listeningPort)));
 
     IPC::Attachment clientPort(listeningPort, MACH_MSG_TYPE_MAKE_SEND);
     parentProcessConnection()->send(Messages::StorageProcessProxy::DidCreateStorageToWebProcessConnection(clientPort), 0);
@@ -306,6 +306,18 @@ void StorageProcess::didGetSandboxExtensionsForBlobFiles(uint64_t requestID, San
 }
 #endif
 
+#if ENABLE(SERVICE_WORKER)
+SWServer& StorageProcess::swServerForSession(PAL::SessionID sessionID)
+{
+    auto result = m_swServers.add(sessionID, nullptr);
+    if (result.isNewEntry)
+        result.iterator->value = std::make_unique<SWServer>();
+
+    ASSERT(result.iterator->value);
+    return *result.iterator->value;
+}
+#endif
+
 #if !PLATFORM(COCOA)
 void StorageProcess::initializeProcess(const ChildProcessInitializationParameters&)
 {
index c3aef9f..f408334 100644 (file)
@@ -35,6 +35,7 @@
 #include <wtf/Function.h>
 
 namespace WebCore {
+class SWServer;
 struct SecurityOriginData;
 }
 
@@ -55,15 +56,12 @@ public:
     static StorageProcess& singleton();
     ~StorageProcess();
 
-#if ENABLE(INDEXED_DATABASE)
-    WebCore::IDBServer::IDBServer& idbServer(PAL::SessionID);
-#endif
-
     WorkQueue& queue() { return m_queue.get(); }
-
     void postStorageTask(CrossThreadTask&&);
 
 #if ENABLE(INDEXED_DATABASE)
+    WebCore::IDBServer::IDBServer& idbServer(PAL::SessionID);
+
     // WebCore::IDBServer::IDBBackingStoreFileHandler
     void prepareForAccessToTemporaryFile(const String& path) final;
     void accessToTemporaryFileComplete(const String& path) final;
@@ -73,6 +71,10 @@ public:
     void getSandboxExtensionsForBlobFiles(const Vector<String>& filenames, WTF::Function<void (SandboxExtension::HandleArray&&)>&& completionHandler);
 #endif
 
+#if ENABLE(SERVICE_WORKER)
+    WebCore::SWServer& swServerForSession(PAL::SessionID);
+#endif
+
 private:
     StorageProcess();
 
@@ -108,7 +110,7 @@ private:
     void performNextStorageTask();
     void ensurePathExists(const String&);
 
-    Vector<RefPtr<StorageToWebProcessConnection>> m_databaseToWebProcessConnections;
+    Vector<RefPtr<StorageToWebProcessConnection>> m_storageToWebProcessConnections;
 
     Ref<WorkQueue> m_queue;
 
@@ -121,6 +123,10 @@ private:
 
     Deque<CrossThreadTask> m_storageTasks;
     Lock m_storageTaskMutex;
+    
+#if ENABLE(SERVICE_WORKER)
+    HashMap<PAL::SessionID, std::unique_ptr<WebCore::SWServer>> m_swServers;
+#endif
 };
 
 } // namespace WebKit
index 9dde3f6..27bad1c 100644 (file)
@@ -27,6 +27,7 @@
 #include "StorageToWebProcessConnection.h"
 
 #include "Logging.h"
+#include "StorageProcess.h"
 #include "StorageToWebProcessConnectionMessages.h"
 #include "WebIDBConnectionToClient.h"
 #include "WebIDBConnectionToClientMessages.h"
@@ -136,13 +137,8 @@ void StorageToWebProcessConnection::establishSWServerConnection(SessionID sessio
     LOG(ServiceWorker, "StorageToWebProcessConnection::establishSWServerConnection - %" PRIu64, serverConnectionIdentifier);
     ASSERT(!m_swConnections.contains(serverConnectionIdentifier));
 
-    auto result = m_swServers.add(sessionID, nullptr);
-    if (result.isNewEntry)
-        result.iterator->value = std::make_unique<SWServer>();
-
-    ASSERT(result.iterator->value);
-
-    m_swConnections.set(serverConnectionIdentifier, std::make_unique<WebSWServerConnection>(*result.iterator->value, m_connection.get(), serverConnectionIdentifier, sessionID));
+    auto& server = StorageProcess::singleton().swServerForSession(sessionID);
+    m_swConnections.set(serverConnectionIdentifier, std::make_unique<WebSWServerConnection>(server, m_connection.get(), serverConnectionIdentifier, sessionID));
 }
 
 void StorageToWebProcessConnection::removeSWServerConnection(uint64_t serverConnectionIdentifier)
index 8ac2702..ed65802 100644 (file)
@@ -70,7 +70,6 @@ private:
 #if ENABLE(SERVICE_WORKER)
     void establishSWServerConnection(PAL::SessionID, uint64_t& serverConnectionIdentifier);
     void removeSWServerConnection(uint64_t serverConnectionIdentifier);
-    HashMap<PAL::SessionID, std::unique_ptr<WebCore::SWServer>> m_swServers;
     HashMap<uint64_t, std::unique_ptr<WebSWServerConnection>> m_swConnections;
 #endif