Title: [252812] trunk/Source/WebKit
Revision
252812
Author
[email protected]
Date
2019-11-22 15:52:15 -0800 (Fri, 22 Nov 2019)

Log Message

Simplify VisitedLinkStore process registration logic
https://bugs.webkit.org/show_bug.cgi?id=204472

Reviewed by Geoffrey Garen.

Simplify VisitedLinkStore process registration logic:
1. WebProcessProxy objects no longer delay their registration with the VisitedLinkStore until
   after they are done launching. There is no need to do this because AuxiliaxyProcessProxy::send()
   will correctly queue the IPC message if the process is not done launching when the VisitedLinkStore
   tries to send its IPC.
2. Switch VisitedLinkStore to using a WeakHashSet to store the WebProcessProxy object pointers. This
   is safer and this also makes it so that the WebProcessProxy no longer need to unregister themselves
   when shutting down. Note that AuxiliaxyProcessProxy::send() properly discards IPC messages to
   a terminated process anyway.

* UIProcess/VisitedLinkStore.cpp:
(WebKit::VisitedLinkStore::~VisitedLinkStore):
(WebKit::VisitedLinkStore::addProcess):
(WebKit::VisitedLinkStore::removeProcess):
(WebKit::VisitedLinkStore::removeAll):
(WebKit::VisitedLinkStore::didInvalidateSharedMemory):
(WebKit::VisitedLinkStore::didUpdateSharedStringHashes):
* UIProcess/VisitedLinkStore.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::shutDown):
(WebKit::WebProcessProxy::addVisitedLinkStoreUser):
(WebKit::WebProcessProxy::didFinishLaunching):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (252811 => 252812)


--- trunk/Source/WebKit/ChangeLog	2019-11-22 23:50:24 UTC (rev 252811)
+++ trunk/Source/WebKit/ChangeLog	2019-11-22 23:52:15 UTC (rev 252812)
@@ -1,5 +1,35 @@
 2019-11-22  Chris Dumez  <[email protected]>
 
+        Simplify VisitedLinkStore process registration logic
+        https://bugs.webkit.org/show_bug.cgi?id=204472
+
+        Reviewed by Geoffrey Garen.
+
+        Simplify VisitedLinkStore process registration logic:
+        1. WebProcessProxy objects no longer delay their registration with the VisitedLinkStore until
+           after they are done launching. There is no need to do this because AuxiliaxyProcessProxy::send()
+           will correctly queue the IPC message if the process is not done launching when the VisitedLinkStore
+           tries to send its IPC.
+        2. Switch VisitedLinkStore to using a WeakHashSet to store the WebProcessProxy object pointers. This
+           is safer and this also makes it so that the WebProcessProxy no longer need to unregister themselves
+           when shutting down. Note that AuxiliaxyProcessProxy::send() properly discards IPC messages to
+           a terminated process anyway.
+
+        * UIProcess/VisitedLinkStore.cpp:
+        (WebKit::VisitedLinkStore::~VisitedLinkStore):
+        (WebKit::VisitedLinkStore::addProcess):
+        (WebKit::VisitedLinkStore::removeProcess):
+        (WebKit::VisitedLinkStore::removeAll):
+        (WebKit::VisitedLinkStore::didInvalidateSharedMemory):
+        (WebKit::VisitedLinkStore::didUpdateSharedStringHashes):
+        * UIProcess/VisitedLinkStore.h:
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::shutDown):
+        (WebKit::WebProcessProxy::addVisitedLinkStoreUser):
+        (WebKit::WebProcessProxy::didFinishLaunching):
+
+2019-11-22  Chris Dumez  <[email protected]>
+
         [iOS] Copy assertions before iterating over them in _notifyAssertionsOfImminentSuspension
         https://bugs.webkit.org/show_bug.cgi?id=204524
         <rdar://problem/57265830>

Modified: trunk/Source/WebKit/UIProcess/VisitedLinkStore.cpp (252811 => 252812)


--- trunk/Source/WebKit/UIProcess/VisitedLinkStore.cpp	2019-11-22 23:50:24 UTC (rev 252811)
+++ trunk/Source/WebKit/UIProcess/VisitedLinkStore.cpp	2019-11-22 23:52:15 UTC (rev 252812)
@@ -43,7 +43,7 @@
 
 VisitedLinkStore::~VisitedLinkStore()
 {
-    RELEASE_ASSERT(m_processes.isEmpty());
+    RELEASE_ASSERT(m_processes.computesEmpty());
 }
 
 VisitedLinkStore::VisitedLinkStore()
@@ -53,10 +53,9 @@
 
 void VisitedLinkStore::addProcess(WebProcessProxy& process)
 {
-    ASSERT(process.state() == WebProcessProxy::State::Running);
-    ASSERT(!m_processes.contains(&process));
+    ASSERT(!m_processes.contains(process));
 
-    if (!m_processes.add(&process).isNewEntry)
+    if (!m_processes.add(process).isNewEntry)
         return;
 
     process.addMessageReceiver(Messages::VisitedLinkStore::messageReceiverName(), identifier(), *this);
@@ -69,7 +68,8 @@
 
 void VisitedLinkStore::removeProcess(WebProcessProxy& process)
 {
-    if (!m_processes.remove(&process))
+    ASSERT(m_processes.contains(process));
+    if (!m_processes.remove(process))
         return;
 
     process.removeMessageReceiver(Messages::VisitedLinkStore::messageReceiverName(), identifier());
@@ -94,9 +94,9 @@
 {
     m_linkHashStore.clear();
 
-    for (WebProcessProxy* process : m_processes) {
-        ASSERT(process->processPool().processes().contains(process));
-        process->send(Messages::VisitedLinkTableController::RemoveAllVisitedLinks(), identifier());
+    for (auto& process : m_processes) {
+        ASSERT(process.processPool().processes().contains(&process));
+        process.send(Messages::VisitedLinkTableController::RemoveAllVisitedLinks(), identifier());
     }
 }
 
@@ -123,8 +123,8 @@
 
 void VisitedLinkStore::didInvalidateSharedMemory()
 {
-    for (WebProcessProxy* process : m_processes)
-        sendStoreHandleToProcess(*process);
+    for (auto& process : m_processes)
+        sendStoreHandleToProcess(process);
 }
 
 void VisitedLinkStore::didUpdateSharedStringHashes(const Vector<WebCore::SharedStringHash>& addedHashes, const Vector<WebCore::SharedStringHash>& removedHashes)
@@ -131,13 +131,13 @@
 {
     ASSERT(!addedHashes.isEmpty() || !removedHashes.isEmpty());
 
-    for (auto* process : m_processes) {
-        ASSERT(process->processPool().processes().contains(process));
+    for (auto& process : m_processes) {
+        ASSERT(process.processPool().processes().contains(&process));
 
         if (addedHashes.size() > 20 || !removedHashes.isEmpty())
-            process->send(Messages::VisitedLinkTableController::AllVisitedLinkStateChanged(), identifier());
+            process.send(Messages::VisitedLinkTableController::AllVisitedLinkStateChanged(), identifier());
         else
-            process->send(Messages::VisitedLinkTableController::VisitedLinkStateChanged(addedHashes), identifier());
+            process.send(Messages::VisitedLinkTableController::VisitedLinkStateChanged(addedHashes), identifier());
     }
 }
 

Modified: trunk/Source/WebKit/UIProcess/VisitedLinkStore.h (252811 => 252812)


--- trunk/Source/WebKit/UIProcess/VisitedLinkStore.h	2019-11-22 23:50:24 UTC (rev 252811)
+++ trunk/Source/WebKit/UIProcess/VisitedLinkStore.h	2019-11-22 23:52:15 UTC (rev 252812)
@@ -30,9 +30,9 @@
 #include "SharedStringHashStore.h"
 #include "WebPageProxyIdentifier.h"
 #include <wtf/Forward.h>
-#include <wtf/HashSet.h>
 #include <wtf/Identified.h>
 #include <wtf/RefCounted.h>
+#include <wtf/WeakHashSet.h>
 
 namespace WebKit {
 
@@ -65,7 +65,7 @@
 
     void sendStoreHandleToProcess(WebProcessProxy&);
 
-    HashSet<WebProcessProxy*> m_processes;
+    WeakHashSet<WebProcessProxy> m_processes;
     SharedStringHashStore m_linkHashStore;
 };
 

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (252811 => 252812)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2019-11-22 23:50:24 UTC (rev 252811)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2019-11-22 23:52:15 UTC (rev 252812)
@@ -381,10 +381,6 @@
         frame->webProcessWillShutDown();
     m_frameMap.clear();
 
-    for (auto* visitedLinkStore : m_visitedLinkStoresWithUsers.keys())
-        visitedLinkStore->removeProcess(*this);
-    m_visitedLinkStoresWithUsers.clear();
-
     for (auto* webUserContentControllerProxy : m_webUserContentControllerProxies)
         webUserContentControllerProxy->removeProcess(*this);
     m_webUserContentControllerProxies.clear();
@@ -489,7 +485,7 @@
     ASSERT(!users.contains(pageID));
     users.add(pageID);
 
-    if (users.size() == 1 && state() == State::Running)
+    if (users.size() == 1)
         visitedLinkStore.addProcess(*this);
 }
 
@@ -858,9 +854,6 @@
     m_processPool->processDidFinishLaunching(this);
     m_backgroundResponsivenessTimer.updateState();
 
-    for (auto* visitedLinkStore : m_visitedLinkStoresWithUsers.keys())
-        visitedLinkStore->addProcess(*this);
-
 #if PLATFORM(IOS_FAMILY)
     if (connection()) {
         if (xpc_connection_t xpcConnection = connection()->xpcConnection())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to