Track IconDatabase retain counts for WebContent processes. Balance retain/releases...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Apr 2015 22:37:19 +0000 (22:37 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 9 Apr 2015 22:37:19 +0000 (22:37 +0000)
https://bugs.webkit.org/show_bug.cgi?id=143517.

Patch by Gordon Sheridan <gordon_sheridan@apple.com> on 2015-04-09
Reviewed by Brady Eidson.

* UIProcess/WebIconDatabase.messages.in:
Move RetainIconForPageURL and ReleaseIconForPageURL messages to WebProcessProxy so they can be associated with the appropriate web process.

* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::connectionDidClose):
Call releaseRemainingIconsForPageURLs() to balance retains/releases for this process.

(WebKit::WebProcessProxy::retainIconForPageURL):
Track retain counts for page URLs and call through to WebIconDatabase.

(WebKit::WebProcessProxy::releaseIconForPageURL):
Ditto.

(WebKit::WebProcessProxy::releaseRemainingIconsForPageURLs):
Call releaseIconForPageURL() once for each outstanding retain count, for each page URL.

* UIProcess/WebProcessProxy.h:
Declare methods for retainIconForPageURL(), releaseIconForPageURL(), and releaseRemainingIconsForPageURLs().
Declare hash map to track number of retains per page URL.

* UIProcess/WebProcessProxy.messages.in:
Moved RetainIconForPageURL and ReleaseIconForPageURL messages here from WebIconDatabase.

* WebProcess/IconDatabase/WebIconDatabaseProxy.cpp:
(WebKit::WebIconDatabaseProxy::retainIconForPageURL):
Modify the receiver of the message to be WebProcessProxy.

(WebKit::WebIconDatabaseProxy::releaseIconForPageURL):
Ditto.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebIconDatabase.messages.in
Source/WebKit2/UIProcess/WebProcessProxy.cpp
Source/WebKit2/UIProcess/WebProcessProxy.h
Source/WebKit2/UIProcess/WebProcessProxy.messages.in
Source/WebKit2/WebProcess/IconDatabase/WebIconDatabaseProxy.cpp

index e15023b387a69a115a4750f174775b0111c670e4..503b31cfa110b6ad9cbd8163e307c1de9dfbe4ec 100644 (file)
@@ -1,3 +1,40 @@
+2015-04-09  Gordon Sheridan  <gordon_sheridan@apple.com>
+
+        Track IconDatabase retain counts for WebContent processes. Balance retain/releases for processes that terminate before successfully doing it themselves.
+        https://bugs.webkit.org/show_bug.cgi?id=143517.
+
+        Reviewed by Brady Eidson.
+
+        * UIProcess/WebIconDatabase.messages.in:
+        Move RetainIconForPageURL and ReleaseIconForPageURL messages to WebProcessProxy so they can be associated with the appropriate web process.
+
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::connectionDidClose):
+        Call releaseRemainingIconsForPageURLs() to balance retains/releases for this process.
+
+        (WebKit::WebProcessProxy::retainIconForPageURL):
+        Track retain counts for page URLs and call through to WebIconDatabase.
+
+        (WebKit::WebProcessProxy::releaseIconForPageURL):
+        Ditto.
+
+        (WebKit::WebProcessProxy::releaseRemainingIconsForPageURLs):
+        Call releaseIconForPageURL() once for each outstanding retain count, for each page URL.
+
+        * UIProcess/WebProcessProxy.h:
+        Declare methods for retainIconForPageURL(), releaseIconForPageURL(), and releaseRemainingIconsForPageURLs().
+        Declare hash map to track number of retains per page URL.
+
+        * UIProcess/WebProcessProxy.messages.in:
+        Moved RetainIconForPageURL and ReleaseIconForPageURL messages here from WebIconDatabase.
+
+        * WebProcess/IconDatabase/WebIconDatabaseProxy.cpp:
+        (WebKit::WebIconDatabaseProxy::retainIconForPageURL):
+        Modify the receiver of the message to be WebProcessProxy.
+
+        (WebKit::WebIconDatabaseProxy::releaseIconForPageURL):
+        Ditto.
+
 2015-04-09  Chris Dumez  <cdumez@apple.com>
 
         [WK2] Regression(r182194): The NetworkProcess is calling the wrong memory pressure handler before suspending
 2015-04-09  Chris Dumez  <cdumez@apple.com>
 
         [WK2] Regression(r182194): The NetworkProcess is calling the wrong memory pressure handler before suspending
index 37052b5d829f053bdbfa9e04fb0e3a852a02fcbf..f5b96fd1f66cf24aa82da2c0a9e7264b9bf6050b 100644 (file)
@@ -21,8 +21,6 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 messages -> WebIconDatabase {
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 messages -> WebIconDatabase {
-    RetainIconForPageURL(String pageURL)
-    ReleaseIconForPageURL(String pageURL)
     SetIconURLForPageURL(String iconURL, String pageURL)
     SetIconDataForIconURL(IPC::DataReference iconData, String iconURL)
     
     SetIconURLForPageURL(String iconURL, String pageURL)
     SetIconDataForIconURL(IPC::DataReference iconData, String iconURL)
     
index 4bb55852a3784b38e38e39fd2abc1327349b2b2c..fb0fb48a99fd445ece4a6ad968dcd4c020233025 100644 (file)
@@ -38,6 +38,7 @@
 #include "TextCheckerState.h"
 #include "UserData.h"
 #include "WebBackForwardListItem.h"
 #include "TextCheckerState.h"
 #include "UserData.h"
 #include "WebBackForwardListItem.h"
+#include "WebIconDatabase.h"
 #include "WebInspectorProxy.h"
 #include "WebNavigationDataStore.h"
 #include "WebNotificationManagerProxy.h"
 #include "WebInspectorProxy.h"
 #include "WebNavigationDataStore.h"
 #include "WebNotificationManagerProxy.h"
@@ -117,6 +118,7 @@ WebProcessProxy::~WebProcessProxy()
     ASSERT(m_pendingFetchWebsiteDataCallbacks.isEmpty());
     ASSERT(m_pendingDeleteWebsiteDataCallbacks.isEmpty());
     ASSERT(m_pendingDeleteWebsiteDataForOriginsCallbacks.isEmpty());
     ASSERT(m_pendingFetchWebsiteDataCallbacks.isEmpty());
     ASSERT(m_pendingDeleteWebsiteDataCallbacks.isEmpty());
     ASSERT(m_pendingDeleteWebsiteDataForOriginsCallbacks.isEmpty());
+    ASSERT(m_pageURLRetainCountMap.isEmpty());
 
     if (m_webConnection)
         m_webConnection->invalidate();
 
     if (m_webConnection)
         m_webConnection->invalidate();
@@ -163,6 +165,8 @@ void WebProcessProxy::connectionDidClose(IPC::Connection& connection)
 
     for (auto& page : m_pageMap.values())
         page->connectionDidClose(connection);
 
     for (auto& page : m_pageMap.values())
         page->connectionDidClose(connection);
+
+    releaseRemainingIconsForPageURLs();
 }
 
 void WebProcessProxy::disconnect()
 }
 
 void WebProcessProxy::disconnect()
@@ -433,6 +437,53 @@ void WebProcessProxy::getDatabaseProcessConnection(PassRefPtr<Messages::WebProce
 }
 #endif // ENABLE(DATABASE_PROCESS)
 
 }
 #endif // ENABLE(DATABASE_PROCESS)
 
+void WebProcessProxy::retainIconForPageURL(const String& pageURL)
+{
+    WebIconDatabase* iconDatabase = processPool().iconDatabase();
+    if (!iconDatabase || pageURL.isEmpty())
+        return;
+
+    // Track retain counts so we can release them if the WebProcess terminates early.
+    auto result = m_pageURLRetainCountMap.add(pageURL, 1);
+    if (!result.isNewEntry)
+        ++result.iterator->value;
+
+    iconDatabase->retainIconForPageURL(pageURL);
+}
+
+void WebProcessProxy::releaseIconForPageURL(const String& pageURL)
+{
+    WebIconDatabase* iconDatabase = processPool().iconDatabase();
+    if (!iconDatabase || pageURL.isEmpty())
+        return;
+
+    // Track retain counts so we can release them if the WebProcess terminates early.
+    auto result = m_pageURLRetainCountMap.find(pageURL);
+    if (result == m_pageURLRetainCountMap.end())
+        return;
+
+    --result->value;
+    if (!result->value)
+        m_pageURLRetainCountMap.remove(result);
+
+    iconDatabase->releaseIconForPageURL(pageURL);
+}
+
+void WebProcessProxy::releaseRemainingIconsForPageURLs()
+{
+    WebIconDatabase* iconDatabase = processPool().iconDatabase();
+    if (!iconDatabase)
+        return;
+
+    for (auto iter : m_pageURLRetainCountMap) {
+        uint64_t count = iter.value;
+        for (uint64_t i = 0; i < count; ++i)
+            iconDatabase->releaseIconForPageURL(iter.key);
+    }
+
+    m_pageURLRetainCountMap.clear();
+}
+
 void WebProcessProxy::didReceiveMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder)
 {
     if (dispatchMessage(connection, decoder))
 void WebProcessProxy::didReceiveMessage(IPC::Connection& connection, IPC::MessageDecoder& decoder)
 {
     if (dispatchMessage(connection, decoder))
index b0312b2b26749189388f9885fe25adcac14e1c35..bf5202a06a54a043d69d90dc8a2caa319b0e1a29 100644 (file)
@@ -190,6 +190,10 @@ private:
     void getDatabaseProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetDatabaseProcessConnection::DelayedReply>);
 #endif
 
     void getDatabaseProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetDatabaseProcessConnection::DelayedReply>);
 #endif
 
+    void retainIconForPageURL(const String& pageURL);
+    void releaseIconForPageURL(const String& pageURL);
+    void releaseRemainingIconsForPageURLs();
+
     // IPC::Connection::Client
     friend class WebConnectionToWebProcess;
     virtual void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
     // IPC::Connection::Client
     friend class WebConnectionToWebProcess;
     virtual void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
@@ -243,6 +247,8 @@ private:
 #if PLATFORM(IOS) && ENABLE(NETWORK_PROCESS)
     ProcessThrottler::ForegroundActivityToken m_tokenForNetworkProcess;
 #endif
 #if PLATFORM(IOS) && ENABLE(NETWORK_PROCESS)
     ProcessThrottler::ForegroundActivityToken m_tokenForNetworkProcess;
 #endif
+
+    HashMap<String, uint64_t> m_pageURLRetainCountMap;
 };
 
 } // namespace WebKit
 };
 
 } // namespace WebKit
index 5905497214c97e23f3f1d17defff7b38bbe35fd7..74509e039d46dc7e1a7f85e2204cc061c66daa75 100644 (file)
@@ -48,4 +48,7 @@ messages -> WebProcessProxy LegacyReceiver {
     DidCancelProcessSuspension()
 
     SetIsHoldingLockedFiles(bool isHoldingLockedFiles)
     DidCancelProcessSuspension()
 
     SetIsHoldingLockedFiles(bool isHoldingLockedFiles)
+
+    RetainIconForPageURL(String pageURL)
+    ReleaseIconForPageURL(String pageURL)
 }
 }
index 7b8291df9fc71e84dff92a2ead9ab310e6f4e354..33fe587e4157638400331509d8f7b253c733e89d 100644 (file)
@@ -30,6 +30,7 @@
 #include "WebIconDatabaseMessages.h"
 #include "WebIconDatabaseProxyMessages.h"
 #include "WebProcess.h"
 #include "WebIconDatabaseMessages.h"
 #include "WebIconDatabaseProxyMessages.h"
 #include "WebProcess.h"
+#include "WebProcessProxyMessages.h"
 #include <WebCore/SharedBuffer.h>
 #include <wtf/text/WTFString.h>
 
 #include <WebCore/SharedBuffer.h>
 #include <wtf/text/WTFString.h>
 
@@ -64,12 +65,12 @@ void WebIconDatabaseProxy::setEnabled(bool enabled)
 
 void WebIconDatabaseProxy::retainIconForPageURL(const String& pageURL)
 {
 
 void WebIconDatabaseProxy::retainIconForPageURL(const String& pageURL)
 {
-    m_process->parentProcessConnection()->send(Messages::WebIconDatabase::RetainIconForPageURL(pageURL), 0);
+    m_process->parentProcessConnection()->send(Messages::WebProcessProxy::RetainIconForPageURL(pageURL), 0);
 }
 
 void WebIconDatabaseProxy::releaseIconForPageURL(const String& pageURL)
 {
 }
 
 void WebIconDatabaseProxy::releaseIconForPageURL(const String& pageURL)
 {
-    m_process->parentProcessConnection()->send(Messages::WebIconDatabase::ReleaseIconForPageURL(pageURL), 0);
+    m_process->parentProcessConnection()->send(Messages::WebProcessProxy::ReleaseIconForPageURL(pageURL), 0);
 }
 
 Image* WebIconDatabaseProxy::synchronousIconForPageURL(const String& pageURL, const IntSize& /*size*/)
 }
 
 Image* WebIconDatabaseProxy::synchronousIconForPageURL(const String& pageURL, const IntSize& /*size*/)