Switch WebCookieManager and AuthenticationManager to use the ChildProcess rather...
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Dec 2012 05:45:05 +0000 (05:45 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Dec 2012 05:45:05 +0000 (05:45 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105703

Reviewed by Dan Bernstein.

Also switches WebCookieManager over to be a MessageReceiver while we are at it.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::NetworkProcess):
(WebKit::NetworkProcess::initialize):
(WebKit::NetworkProcess::didReceiveMessage):
* NetworkProcess/NetworkProcess.h:
(WebKit):
* WebProcess/Authentication/AuthenticationManager.cpp:
(WebKit::AuthenticationManager::AuthenticationManager):
(WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):
* WebProcess/Authentication/AuthenticationManager.h:
(AuthenticationManager):
* WebProcess/Cookies/WebCookieManager.cpp:
(WebKit):
(WebKit::WebCookieManager::WebCookieManager):
(WebKit::WebCookieManager::didReceiveMessage):
(WebKit::WebCookieManager::getHostnamesWithCookies):
(WebKit::WebCookieManager::cookiesDidChange):
(WebKit::WebCookieManager::dispatchCookiesDidChange):
(WebKit::WebCookieManager::getHTTPCookieAcceptPolicy):
* WebProcess/Cookies/WebCookieManager.h:
(WebKit):
(WebCookieManager):
* WebProcess/Cookies/soup/WebCookieManagerSoup.cpp:
(WebKit::WebCookieManager::setCookiePersistentStorage):
* WebProcess/InjectedBundle/InjectedBundle.cpp:
(WebKit::InjectedBundle::setAlwaysAcceptCookies):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
(WebKit::WebProcess::initialize):
(WebKit::WebProcess::didReceiveMessage):
* WebProcess/WebProcess.h:
(WebProcess):
(WebKit::WebProcess::cookieManager):

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

13 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkProcess.cpp
Source/WebKit2/NetworkProcess/NetworkProcess.h
Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp
Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h
Source/WebKit2/WebProcess/Cookies/WebCookieManager.cpp
Source/WebKit2/WebProcess/Cookies/WebCookieManager.h
Source/WebKit2/WebProcess/Cookies/soup/WebCookieManagerSoup.cpp
Source/WebKit2/WebProcess/InjectedBundle/InjectedBundle.cpp
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h
Source/WebKit2/WebProcess/soup/WebProcessSoup.cpp
Source/WebKit2/WebProcess/win/WebProcessWin.cpp

index f07e692..7b6c293 100644 (file)
@@ -1,5 +1,48 @@
 2012-12-23  Sam Weinig  <sam@webkit.org>
 
+        Switch WebCookieManager and AuthenticationManager to use the ChildProcess rather than holding on to a Connection
+        https://bugs.webkit.org/show_bug.cgi?id=105703
+
+        Reviewed by Dan Bernstein.
+
+        Also switches WebCookieManager over to be a MessageReceiver while we are at it.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::NetworkProcess):
+        (WebKit::NetworkProcess::initialize):
+        (WebKit::NetworkProcess::didReceiveMessage):
+        * NetworkProcess/NetworkProcess.h:
+        (WebKit):
+        * WebProcess/Authentication/AuthenticationManager.cpp:
+        (WebKit::AuthenticationManager::AuthenticationManager):
+        (WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):
+        * WebProcess/Authentication/AuthenticationManager.h:
+        (AuthenticationManager):
+        * WebProcess/Cookies/WebCookieManager.cpp:
+        (WebKit):
+        (WebKit::WebCookieManager::WebCookieManager):
+        (WebKit::WebCookieManager::didReceiveMessage):
+        (WebKit::WebCookieManager::getHostnamesWithCookies):
+        (WebKit::WebCookieManager::cookiesDidChange):
+        (WebKit::WebCookieManager::dispatchCookiesDidChange):
+        (WebKit::WebCookieManager::getHTTPCookieAcceptPolicy):
+        * WebProcess/Cookies/WebCookieManager.h:
+        (WebKit):
+        (WebCookieManager):
+        * WebProcess/Cookies/soup/WebCookieManagerSoup.cpp:
+        (WebKit::WebCookieManager::setCookiePersistentStorage):
+        * WebProcess/InjectedBundle/InjectedBundle.cpp:
+        (WebKit::InjectedBundle::setAlwaysAcceptCookies):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::WebProcess):
+        (WebKit::WebProcess::initialize):
+        (WebKit::WebProcess::didReceiveMessage):
+        * WebProcess/WebProcess.h:
+        (WebProcess):
+        (WebKit::WebProcess::cookieManager):
+
+2012-12-23  Sam Weinig  <sam@webkit.org>
+
         Try to fix the Qt build.
 
         * WebProcess/WebCoreSupport/WebDatabaseManager.h:
index 5b0d42b..4aa6aee 100644 (file)
@@ -56,6 +56,7 @@ NetworkProcess::NetworkProcess()
     : m_hasSetCacheModel(false)
     , m_cacheModel(CacheModelDocumentViewer)
     , m_downloadsAuthenticationManager(this)
+    , m_cookieManager(new WebCookieManager(this))
 {
 #if ENABLE(CUSTOM_PROTOCOLS)
     CustomProtocolManager::shared().initialize(this);
@@ -79,9 +80,6 @@ void NetworkProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier
     m_uiConnection = CoreIPC::Connection::createClientConnection(serverIdentifier, this, runLoop);
     m_uiConnection->setDidCloseOnConnectionWorkQueueCallback(didCloseOnConnectionWorkQueue);
     m_uiConnection->open();
-
-    m_downloadsAuthenticationManager.setConnection(m_uiConnection.get());
-    WebCookieManager::shared().setConnection(m_uiConnection.get());
 }
 
 void NetworkProcess::removeNetworkConnectionToWebProcess(NetworkConnectionToWebProcess* connection)
@@ -103,11 +101,6 @@ void NetworkProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC:
     if (m_messageReceiverMap.dispatchMessage(connection, messageID, decoder))
         return;
 
-    if (messageID.is<CoreIPC::MessageClassWebCookieManager>()) {
-        WebCookieManager::shared().didReceiveMessage(connection, messageID, decoder);
-        return;
-    }
-
     didReceiveNetworkProcessMessage(connection, messageID, decoder);
 }
 
index 7b56f49..3848b13 100644 (file)
@@ -43,6 +43,7 @@ namespace WebCore {
 namespace WebKit {
 
 class NetworkConnectionToWebProcess;
+class WebCookieManager;
 struct NetworkProcessCreationParameters;
 
 class NetworkProcess : public ChildProcess, DownloadManager::Client {
@@ -113,6 +114,8 @@ private:
     CacheModel m_cacheModel;
 
     AuthenticationManager m_downloadsAuthenticationManager;
+
+    WebCookieManager* m_cookieManager;
 };
 
 } // namespace WebKit
index 4ca2b59..177a6f1 100644 (file)
@@ -30,7 +30,6 @@
 #include "ChildProcess.h"
 #include "Download.h"
 #include "DownloadProxyMessages.h"
-#include "MessageID.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebFrame.h"
 #include "WebPage.h"
@@ -48,15 +47,10 @@ static uint64_t generateAuthenticationChallengeID()
     return uniqueAuthenticationChallengeID++;
 }
 
-AuthenticationManager::AuthenticationManager(ChildProcess* childProcess)
+AuthenticationManager::AuthenticationManager(ChildProcess* process)
+    : m_process(process)
 {
-    childProcess->addMessageReceiver(Messages::AuthenticationManager::messageReceiverName(), this);
-}
-
-void AuthenticationManager::setConnection(CoreIPC::Connection* connection)
-{
-    ASSERT(!m_connection);
-    m_connection = connection;
+    m_process->addMessageReceiver(Messages::AuthenticationManager::messageReceiverName(), this);
 }
 
 void AuthenticationManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)
@@ -72,7 +66,7 @@ void AuthenticationManager::didReceiveAuthenticationChallenge(WebFrame* frame, c
     uint64_t challengeID = generateAuthenticationChallengeID();
     m_challenges.set(challengeID, authenticationChallenge);    
     
-    m_connection->send(Messages::WebPageProxy::DidReceiveAuthenticationChallenge(frame->frameID(), authenticationChallenge, challengeID), frame->page()->pageID());
+    m_process->send(Messages::WebPageProxy::DidReceiveAuthenticationChallenge(frame->frameID(), authenticationChallenge, challengeID), frame->page()->pageID());
 }
 
 void AuthenticationManager::didReceiveAuthenticationChallenge(Download* download, const AuthenticationChallenge& authenticationChallenge)
index 5559450..6384ed6 100644 (file)
 #include "MessageReceiver.h"
 #include <wtf/HashMap.h>
 
-namespace CoreIPC {
-class ArgumentDecoder;
-class Connection;
-class MessageID;
-class MessageReceiverMap;
-}
-
 namespace WebCore {
     class AuthenticationChallenge;
     class Credential;
@@ -50,12 +43,9 @@ class WebFrame;
 
 class AuthenticationManager : private CoreIPC::MessageReceiver {
     WTF_MAKE_NONCOPYABLE(AuthenticationManager);
-
 public:
     explicit AuthenticationManager(ChildProcess*);
 
-    void setConnection(CoreIPC::Connection*);
-
     void didReceiveAuthenticationChallenge(WebFrame*, const WebCore::AuthenticationChallenge&);
     void didReceiveAuthenticationChallenge(Download*, const WebCore::AuthenticationChallenge&);
 
@@ -70,7 +60,7 @@ private:
 
     bool tryUsePlatformCertificateInfoForChallenge(const WebCore::AuthenticationChallenge&, const PlatformCertificateInfo&);
 
-    RefPtr<CoreIPC::Connection> m_connection;
+    ChildProcess* m_process;
 
     typedef HashMap<uint64_t, WebCore::AuthenticationChallenge> AuthenticationChallengeMap;
     AuthenticationChallengeMap m_challenges;
index fb59fb7..665e4ba 100644 (file)
 #include "config.h"
 #include "WebCookieManager.h"
 
-#include "MessageID.h"
+#include "ChildProcess.h"
+#include "WebCookieManagerMessages.h"
 #include "WebCookieManagerProxyMessages.h"
-#include "WebProcess.h"
+#include "WebCoreArgumentCoders.h"
 #include <WebCore/CookieStorage.h>
 #include <WebCore/NetworkStorageSession.h>
 #include <WebCore/PlatformCookieJar.h>
 #include <wtf/MainThread.h>
+#include <wtf/text/StringHash.h>
+#include <wtf/text/WTFString.h>
 
 using namespace WebCore;
 
 namespace WebKit {
 
-WebCookieManager& WebCookieManager::shared()
-{
-    DEFINE_STATIC_LOCAL(WebCookieManager, shared, ());
-    return shared;
-}
+static WebCookieManager* sharedCookieManager;
 
-WebCookieManager::WebCookieManager()
+WebCookieManager::WebCookieManager(ChildProcess* process)
+    : m_process(process)
 {
-}
+    m_process->addMessageReceiver(Messages::WebCookieManager::messageReceiverName(), this);
 
-void WebCookieManager::setConnection(CoreIPC::Connection* connection)
-{
-    ASSERT(!m_connection);
-    m_connection = connection;
+    ASSERT(!sharedCookieManager);
+    sharedCookieManager = this;
 }
 
 void WebCookieManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)
 {
-    ASSERT(connection == m_connection.get());
     didReceiveWebCookieManagerMessage(connection, messageID, decoder);
 }
 
 void WebCookieManager::getHostnamesWithCookies(uint64_t callbackID)
 {
     HashSet<String> hostnames;
-
     WebCore::getHostnamesWithCookies(NetworkStorageSession::defaultStorageSession(), hostnames);
 
     Vector<String> hostnameList;
     copyToVector(hostnames, hostnameList);
 
-    m_connection->send(Messages::WebCookieManagerProxy::DidGetHostnamesWithCookies(hostnameList, callbackID), 0);
+    m_process->send(Messages::WebCookieManagerProxy::DidGetHostnamesWithCookies(hostnameList, callbackID), 0);
 }
 
 void WebCookieManager::deleteCookiesForHostname(const String& hostname)
@@ -94,13 +90,13 @@ void WebCookieManager::stopObservingCookieChanges()
 
 void WebCookieManager::cookiesDidChange()
 {
-    WebCookieManager::shared().dispatchCookiesDidChange();
+    sharedCookieManager->dispatchCookiesDidChange();
 }
 
 void WebCookieManager::dispatchCookiesDidChange()
 {
     ASSERT(isMainThread());
-    m_connection->send(Messages::WebCookieManagerProxy::CookiesDidChange(), 0);
+    m_process->send(Messages::WebCookieManagerProxy::CookiesDidChange(), 0);
 }
 
 void WebCookieManager::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
@@ -110,7 +106,7 @@ void WebCookieManager::setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy policy)
 
 void WebCookieManager::getHTTPCookieAcceptPolicy(uint64_t callbackID)
 {
-    m_connection->send(Messages::WebCookieManagerProxy::DidGetHTTPCookieAcceptPolicy(platformGetHTTPCookieAcceptPolicy(), callbackID), 0);
+    m_process->send(Messages::WebCookieManagerProxy::DidGetHTTPCookieAcceptPolicy(platformGetHTTPCookieAcceptPolicy(), callbackID), 0);
 }
 
 } // namespace WebKit
index 7f619d0..e73bbd6 100644 (file)
 #define WebCookieManager_h
 
 #include "HTTPCookieAcceptPolicy.h"
+#include "MessageReceiver.h"
+#include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
-#include <wtf/text/WTFString.h>
 
 #if USE(SOUP)
 #include "SoupCookiePersistentStorageType.h"
 #endif
 
-namespace CoreIPC {
-    class Connection;
-    class MessageDecoder;
-    class MessageID;
-}
-
 namespace WebKit {
 
-class WebCookieManager {
+class ChildProcess;
+
+class WebCookieManager  : private CoreIPC::MessageReceiver {
     WTF_MAKE_NONCOPYABLE(WebCookieManager);
 public:
-    static WebCookieManager& shared();
-    void setConnection(CoreIPC::Connection*);
+    WebCookieManager(ChildProcess*);
 
-    void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
-    
     void setHTTPCookieAcceptPolicy(HTTPCookieAcceptPolicy);
-
 #if USE(SOUP)
     void setCookiePersistentStorage(const String& storagePath, uint32_t storageType);
 #endif
 
-private:
-    WebCookieManager();
-    
+private:    
     void getHostnamesWithCookies(uint64_t callbackID);
     void deleteCookiesForHostname(const String&);
     void deleteAllCookies();
@@ -73,9 +64,10 @@ private:
     static void cookiesDidChange();
     void dispatchCookiesDidChange();
 
+    void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&) OVERRIDE;
     void didReceiveWebCookieManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
 
-    RefPtr<CoreIPC::Connection> m_connection;
+    ChildProcess* m_process;
 };
 
 } // namespace WebKit
index 982c774..958576d 100644 (file)
@@ -26,8 +26,8 @@
 #include "config.h"
 #include "WebCookieManager.h"
 
+#include "ChildProcess.h"
 #include "WebKitSoupCookieJarSqlite.h"
-#include "WebProcess.h"
 #include <WebCore/CookieJarSoup.h>
 #include <WebCore/ResourceHandle.h>
 #include <libsoup/soup.h>
@@ -84,7 +84,7 @@ HTTPCookieAcceptPolicy WebCookieManager::platformGetHTTPCookieAcceptPolicy()
 
 void WebCookieManager::setCookiePersistentStorage(const String& storagePath, uint32_t storageType)
 {
-    WebProcess::LocalTerminationDisabler terminationDisabler(WebProcess::shared());
+    ChildProcess::LocalTerminationDisabler terminationDisabler(*m_process);
 
     GRefPtr<SoupCookieJar> jar;
     switch (storageType) {
index c58b5df..671518c 100644 (file)
@@ -139,7 +139,7 @@ void InjectedBundle::setShouldTrackVisitedLinks(bool shouldTrackVisitedLinks)
 
 void InjectedBundle::setAlwaysAcceptCookies(bool accept)
 {
-    WebCookieManager::shared().setHTTPCookieAcceptPolicy(accept ? HTTPCookieAcceptPolicyAlways : HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain);
+    WebProcess::shared().cookieManager().setHTTPCookieAcceptPolicy(accept ? HTTPCookieAcceptPolicyAlways : HTTPCookieAcceptPolicyOnlyFromMainDocumentDomain);
 }
 
 void InjectedBundle::removeAllVisitedLinks()
index b67eddf..5b3d7b6 100644 (file)
@@ -33,7 +33,6 @@
 #include "SandboxExtension.h"
 #include "StatisticsData.h"
 #include "WebContextMessages.h"
-#include "WebCookieManager.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebFrame.h"
 #include "WebFrameNetworkingContext.h"
@@ -131,6 +130,7 @@ WebProcess::WebProcess()
     , m_geolocationManager(this)
     , m_applicationCacheManager(this)
     , m_resourceCacheManager(this)
+    , m_cookieManager(this)
 #if ENABLE(SQL_DATABASE)
     , m_databaseManager(this)
 #endif
@@ -181,9 +181,6 @@ void WebProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier, Ru
     m_webConnection = WebConnectionToUIProcess::create(this);
 
     m_runLoop = runLoop;
-
-    m_authenticationManager.setConnection(m_connection.get());
-    WebCookieManager::shared().setConnection(m_connection.get());
 }
 
 void WebProcess::didCreateDownload()
@@ -577,11 +574,6 @@ void WebProcess::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::Mes
         return;
     }
 
-    if (messageID.is<CoreIPC::MessageClassWebCookieManager>()) {
-        WebCookieManager::shared().didReceiveMessage(connection, messageID, decoder);
-        return;
-    }
-
     if (messageID.is<CoreIPC::MessageClassWebKeyValueStorageManager>()) {
         WebKeyValueStorageManager::shared().didReceiveMessage(connection, messageID, decoder);
         return;
index fc44b87..bed4e12 100644 (file)
@@ -41,6 +41,7 @@
 #include "VisitedLinkTable.h"
 #include "WebApplicationCacheManager.h"
 #include "WebConnectionToUIProcess.h"
+#include "WebCookieManager.h"
 #include "WebGeolocationManager.h"
 #include "WebIconDatabaseProxy.h"
 #include "WebPageGroupProxy.h"
@@ -188,6 +189,9 @@ public:
     // Resource Cache
     WebResourceCacheManager& resourceCacheManager() { return m_resourceCacheManager; }
 
+    // Cookies
+    WebCookieManager& cookieManager() { return m_cookieManager; }
+
 #if ENABLE(SQL_DATABASE)
     // Database
     WebDatabaseManager& databaseManager() { return m_databaseManager; }
@@ -387,6 +391,7 @@ private:
     WebGeolocationManager m_geolocationManager;
     WebApplicationCacheManager m_applicationCacheManager;
     WebResourceCacheManager m_resourceCacheManager;
+    WebCookieManager m_cookieManager;
 
 #if ENABLE(SQL_DATABASE)
     WebDatabaseManager m_databaseManager;
index f1cc96b..8f16f9f 100644 (file)
@@ -171,10 +171,10 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
         m_soupRequestManager.registerURIScheme(parameters.urlSchemesRegistered[i]);
 
     if (!parameters.cookiePersistentStoragePath.isEmpty()) {
-        WebCookieManager::shared().setCookiePersistentStorage(parameters.cookiePersistentStoragePath,
+        cookieManager().setCookiePersistentStorage(parameters.cookiePersistentStoragePath,
             parameters.cookiePersistentStorageType);
     }
-    WebCookieManager::shared().setHTTPCookieAcceptPolicy(parameters.cookieAcceptPolicy);
+    cookieManager().setHTTPCookieAcceptPolicy(parameters.cookieAcceptPolicy);
 
     setIgnoreTLSErrors(parameters.ignoreTLSErrors);
 
index e731bcd..a09c7b4 100644 (file)
@@ -141,7 +141,7 @@ void WebProcess::platformInitializeWebProcess(const WebProcessCreationParameters
     ResourceHandle::setDefaultStorageSession(defaultStorageSession.get());
 #endif
 
-    WebCookieManager::shared().setHTTPCookieAcceptPolicy(parameters.initialHTTPCookieAcceptPolicy);
+    cookieManager().setHTTPCookieAcceptPolicy(parameters.initialHTTPCookieAcceptPolicy);
 
     // By using the default storage session that came from the ui process, the web process
     // automatically uses the same the URL Cache as ui process.