Authentication manager cleanup
authorandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Dec 2012 01:51:18 +0000 (01:51 +0000)
committerandersca@apple.com <andersca@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Dec 2012 01:51:18 +0000 (01:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=105144

Reviewed by Sam Weinig.

Some cleanup to make it possible to reuse the authentication manager from the network process.

* UIProcess/Authentication/AuthenticationChallengeProxy.cpp:
(WebKit::AuthenticationChallengeProxy::AuthenticationChallengeProxy):
(WebKit::AuthenticationChallengeProxy::~AuthenticationChallengeProxy):
(WebKit::AuthenticationChallengeProxy::useCredential):
(WebKit::AuthenticationChallengeProxy::cancel):
* UIProcess/Authentication/AuthenticationChallengeProxy.h:
(WebKit::AuthenticationChallengeProxy::create):
(AuthenticationChallengeProxy):
* UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::didReceiveAuthenticationChallenge):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::didReceiveAuthenticationChallenge):
* WebProcess/Authentication/AuthenticationManager.cpp:
(WebKit::AuthenticationManager::AuthenticationManager):
(WebKit::AuthenticationManager::setConnection):
(WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):
(WebKit::AuthenticationManager::useCredentialForChallenge):
* WebProcess/Authentication/AuthenticationManager.h:
* WebProcess/Downloads/Download.cpp:
(WebKit::Download::didReceiveAuthenticationChallenge):
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge):
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::WebProcess):
(WebKit::WebProcess::initialize):
* WebProcess/WebProcess.h:
(WebKit::WebProcess::authenticationManager):
(WebProcess):

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.cpp
Source/WebKit2/UIProcess/Authentication/AuthenticationChallengeProxy.h
Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/WebProcess/Authentication/AuthenticationManager.cpp
Source/WebKit2/WebProcess/Authentication/AuthenticationManager.h
Source/WebKit2/WebProcess/Downloads/Download.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h

index dc7ddf5..cc5f6df 100644 (file)
@@ -1,5 +1,43 @@
 2012-12-16  Anders Carlsson  <andersca@apple.com>
 
+        Authentication manager cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=105144
+
+        Reviewed by Sam Weinig.
+
+        Some cleanup to make it possible to reuse the authentication manager from the network process.
+
+        * UIProcess/Authentication/AuthenticationChallengeProxy.cpp:
+        (WebKit::AuthenticationChallengeProxy::AuthenticationChallengeProxy):
+        (WebKit::AuthenticationChallengeProxy::~AuthenticationChallengeProxy):
+        (WebKit::AuthenticationChallengeProxy::useCredential):
+        (WebKit::AuthenticationChallengeProxy::cancel):
+        * UIProcess/Authentication/AuthenticationChallengeProxy.h:
+        (WebKit::AuthenticationChallengeProxy::create):
+        (AuthenticationChallengeProxy):
+        * UIProcess/Downloads/DownloadProxy.cpp:
+        (WebKit::DownloadProxy::didReceiveAuthenticationChallenge):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::didReceiveAuthenticationChallenge):
+        * WebProcess/Authentication/AuthenticationManager.cpp:
+        (WebKit::AuthenticationManager::AuthenticationManager):
+        (WebKit::AuthenticationManager::setConnection):
+        (WebKit::AuthenticationManager::didReceiveAuthenticationChallenge):
+        (WebKit::AuthenticationManager::useCredentialForChallenge):
+        * WebProcess/Authentication/AuthenticationManager.h:
+        * WebProcess/Downloads/Download.cpp:
+        (WebKit::Download::didReceiveAuthenticationChallenge):
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge):
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::WebProcess):
+        (WebKit::WebProcess::initialize):
+        * WebProcess/WebProcess.h:
+        (WebKit::WebProcess::authenticationManager):
+        (WebProcess):
+
+2012-12-16  Anders Carlsson  <andersca@apple.com>
+
         Rudimentary support for main resource downloads
         https://bugs.webkit.org/show_bug.cgi?id=105141
 
index 7f4e958..9f64885 100644 (file)
 
 #include "AuthenticationDecisionListener.h"
 #include "AuthenticationManagerMessages.h"
+#include "ChildProcessProxy.h"
 #include "WebCertificateInfo.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebCredential.h"
-#include "WebPageProxy.h"
 #include "WebProcessProxy.h"
 #include "WebProtectionSpace.h"
 
 namespace WebKit {
 
-AuthenticationChallengeProxy::AuthenticationChallengeProxy(const WebCore::AuthenticationChallenge& authenticationChallenge, uint64_t challengeID, WebProcessProxy* process)
+AuthenticationChallengeProxy::AuthenticationChallengeProxy(const WebCore::AuthenticationChallenge& authenticationChallenge, uint64_t challengeID, CoreIPC::Connection* connection)
     : m_coreAuthenticationChallenge(authenticationChallenge)
     , m_challengeID(challengeID)
-    , m_process(process)
+    , m_connection(connection)
 {
     ASSERT(m_challengeID);
     m_listener = AuthenticationDecisionListener::create(this);
@@ -49,9 +49,9 @@ AuthenticationChallengeProxy::AuthenticationChallengeProxy(const WebCore::Authen
 AuthenticationChallengeProxy::~AuthenticationChallengeProxy()
 {
     // If an outstanding AuthenticationChallengeProxy is being destroyed even though it hasn't been responded to yet,
-    // we cancel it here so the WebProcess isn't waiting for an answer forever.
+    // we cancel it here so the process isn't waiting for an answer forever.
     if (m_challengeID)
-        m_process->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
+        m_connection->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
 
     if (m_listener)
         m_listener->detachChallenge();
@@ -63,11 +63,11 @@ void AuthenticationChallengeProxy::useCredential(WebCredential* credential)
         return;
 
     if (!credential)
-        m_process->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(m_challengeID), 0);
+        m_connection->send(Messages::AuthenticationManager::ContinueWithoutCredentialForChallenge(m_challengeID), 0);
     else {
         WebCertificateInfo* certificateInfo = credential->certificateInfo();
         PlatformCertificateInfo platformInfo = certificateInfo ? certificateInfo->platformCertificateInfo() : PlatformCertificateInfo();
-        m_process->send(Messages::AuthenticationManager::UseCredentialForChallenge(m_challengeID, credential->core(), platformInfo), 0);
+        m_connection->send(Messages::AuthenticationManager::UseCredentialForChallenge(m_challengeID, credential->core(), platformInfo), 0);
     }
 
     m_challengeID = 0;
@@ -78,7 +78,7 @@ void AuthenticationChallengeProxy::cancel()
     if (!m_challengeID)
         return;
 
-    m_process->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
+    m_connection->send(Messages::AuthenticationManager::CancelChallenge(m_challengeID), 0);
 
     m_challengeID = 0;
 }
index 51379ee..eef8d59 100644 (file)
@@ -39,17 +39,17 @@ namespace CoreIPC {
 namespace WebKit {
 
 class AuthenticationDecisionListener;
+class ChildProcessProxy;
 class WebCredential;
-class WebProcessProxy;
 class WebProtectionSpace;
 
 class AuthenticationChallengeProxy : public APIObject {
 public:
     static const Type APIType = TypeAuthenticationChallenge;
 
-    static PassRefPtr<AuthenticationChallengeProxy> create(const WebCore::AuthenticationChallenge& authenticationChallenge, uint64_t challengeID, WebProcessProxy* process)
+    static PassRefPtr<AuthenticationChallengeProxy> create(const WebCore::AuthenticationChallenge& authenticationChallenge, uint64_t challengeID, CoreIPC::Connection* connection)
     {
-        return adoptRef(new AuthenticationChallengeProxy(authenticationChallenge, challengeID, process));
+        return adoptRef(new AuthenticationChallengeProxy(authenticationChallenge, challengeID, connection));
     }
     
     ~AuthenticationChallengeProxy();
@@ -64,13 +64,13 @@ public:
     const WebCore::AuthenticationChallenge& core() { return m_coreAuthenticationChallenge; }
 
 private:
-    AuthenticationChallengeProxy(const WebCore::AuthenticationChallenge&, uint64_t challengeID, WebProcessProxy*);
+    AuthenticationChallengeProxy(const WebCore::AuthenticationChallenge&, uint64_t challengeID, CoreIPC::Connection*);
 
     virtual Type type() const { return APIType; }
     
     WebCore::AuthenticationChallenge m_coreAuthenticationChallenge;
     uint64_t m_challengeID;
-    RefPtr<WebProcessProxy> m_process;
+    RefPtr<CoreIPC::Connection> m_connection;
     RefPtr<AuthenticationDecisionListener> m_listener;
     mutable RefPtr<WebCredential> m_webCredential;
     mutable RefPtr<WebProtectionSpace> m_webProtectionSpace;
index f9946e7..a2fcbbf 100644 (file)
@@ -124,7 +124,8 @@ void DownloadProxy::didReceiveAuthenticationChallenge(const AuthenticationChalle
 
     // FIXME (Multi-WebProcess): <rdar://problem/12239483> Downloads shouldn't be handled in the web process.
     // Once this is fixed, remove WebContext::deprecatedSharedProcess().
-    RefPtr<AuthenticationChallengeProxy> authenticationChallengeProxy = AuthenticationChallengeProxy::create(authenticationChallenge, challengeID, m_webContext->deprecatedSharedProcess());
+    
+    RefPtr<AuthenticationChallengeProxy> authenticationChallengeProxy = AuthenticationChallengeProxy::create(authenticationChallenge, challengeID, m_webContext->deprecatedSharedProcess()->connection());
     m_webContext->downloadClient().didReceiveAuthenticationChallenge(m_webContext.get(), this, authenticationChallengeProxy.get());
 }
 
index dddb5b8..4be975c 100644 (file)
@@ -3840,7 +3840,7 @@ void WebPageProxy::didReceiveAuthenticationChallenge(uint64_t frameID, const Aut
     WebFrameProxy* frame = m_process->webFrame(frameID);
     MESSAGE_CHECK(frame);
 
-    RefPtr<AuthenticationChallengeProxy> authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, m_process.get());
+    RefPtr<AuthenticationChallengeProxy> authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, m_process->connection());
     
     m_loaderClient.didReceiveAuthenticationChallengeInFrame(this, frame, authenticationChallenge.get());
 }
index 3850e64..0187c69 100644 (file)
 #include "Download.h"
 #include "DownloadProxyMessages.h"
 #include "MessageID.h"
+#include "MessageReceiverMap.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebFrame.h"
 #include "WebPage.h"
 #include "WebPageProxyMessages.h"
-#include "WebProcess.h"
 #include <WebCore/AuthenticationChallenge.h>
 #include <WebCore/AuthenticationClient.h>
 
@@ -48,15 +48,15 @@ static uint64_t generateAuthenticationChallengeID()
     return uniqueAuthenticationChallengeID++;
 }
 
-AuthenticationManager& AuthenticationManager::shared()
+AuthenticationManager::AuthenticationManager(CoreIPC::MessageReceiverMap& messageReceiverMap)
 {
-    static AuthenticationManager& manager = *new AuthenticationManager;
-    return manager;
+    messageReceiverMap.addMessageReceiver(Messages::AuthenticationManager::messageReceiverName(), this);
 }
 
-AuthenticationManager::AuthenticationManager()
+void AuthenticationManager::setConnection(CoreIPC::Connection* connection)
 {
-    WebProcess::shared().addMessageReceiver(Messages::AuthenticationManager::messageReceiverName(), this);
+    ASSERT(!m_connection);
+    m_connection = connection;
 }
 
 void AuthenticationManager::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)
@@ -72,7 +72,7 @@ void AuthenticationManager::didReceiveAuthenticationChallenge(WebFrame* frame, c
     uint64_t challengeID = generateAuthenticationChallengeID();
     m_challenges.set(challengeID, authenticationChallenge);    
     
-    WebProcess::shared().connection()->send(Messages::WebPageProxy::DidReceiveAuthenticationChallenge(frame->frameID(), authenticationChallenge, challengeID), frame->page()->pageID());
+    m_connection->send(Messages::WebPageProxy::DidReceiveAuthenticationChallenge(frame->frameID(), authenticationChallenge, challengeID), frame->page()->pageID());
 }
 
 void AuthenticationManager::didReceiveAuthenticationChallenge(Download* download, const AuthenticationChallenge& authenticationChallenge)
@@ -104,7 +104,6 @@ void AuthenticationManager::useCredentialForChallenge(uint64_t challengeID, cons
         // This authentication challenge comes from a download.
         Download::receivedCredential(challenge, credential);
         return;
-        
     }
 
     coreClient->receivedCredential(challenge, credential);
index 16708ce..d2cb8f8 100644 (file)
 #include <wtf/HashMap.h>
 
 namespace CoreIPC {
-    class ArgumentDecoder;
-    class Connection;
-    class MessageID;
+class ArgumentDecoder;
+class Connection;
+class MessageID;
+class MessageReceiverMap;
 }
 
 namespace WebCore {
@@ -50,7 +51,10 @@ class AuthenticationManager : private CoreIPC::MessageReceiver {
     WTF_MAKE_NONCOPYABLE(AuthenticationManager);
 
 public:
-    static AuthenticationManager& shared();
+    // FIXME: ChildProcess should just have a MessageReceiverMap, and this should take a ChildProcess.
+    explicit AuthenticationManager(CoreIPC::MessageReceiverMap&);
+
+    void setConnection(CoreIPC::Connection*);
 
     void didReceiveAuthenticationChallenge(WebFrame*, const WebCore::AuthenticationChallenge&);
     void didReceiveAuthenticationChallenge(Download*, const WebCore::AuthenticationChallenge&);
@@ -60,14 +64,15 @@ public:
     void cancelChallenge(uint64_t challengeID);
 
 private:
-    AuthenticationManager();
 
     // CoreIPC::MessageReceiver
     virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&) OVERRIDE;
     void didReceiveAuthenticationManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
 
     bool tryUsePlatformCertificateInfoForChallenge(const WebCore::AuthenticationChallenge&, const PlatformCertificateInfo&);
-    
+
+    RefPtr<CoreIPC::Connection> m_connection;
+
     typedef HashMap<uint64_t, WebCore::AuthenticationChallenge> AuthenticationChallengeMap;
     AuthenticationChallengeMap m_challenges;
 };
index b3b6ef2..f289129 100644 (file)
@@ -79,7 +79,7 @@ void Download::didStart()
 
 void Download::didReceiveAuthenticationChallenge(const AuthenticationChallenge& authenticationChallenge)
 {
-    AuthenticationManager::shared().didReceiveAuthenticationChallenge(this, authenticationChallenge);
+//    AuthenticationManager::shared().didReceiveAuthenticationChallenge(this, authenticationChallenge);
 }
 
 void Download::didReceiveResponse(const ResourceResponse& response)
index 9e22a3d..ef35bb6 100644 (file)
@@ -211,7 +211,7 @@ void WebFrameLoaderClient::dispatchDidReceiveAuthenticationChallenge(DocumentLoa
     if (!webPage)
         return;
 
-    AuthenticationManager::shared().didReceiveAuthenticationChallenge(m_frame, challenge);
+    WebProcess::shared().authenticationManager().didReceiveAuthenticationChallenge(m_frame, challenge);
 }
 
 void WebFrameLoaderClient::dispatchDidCancelAuthenticationChallenge(DocumentLoader*, unsigned long /*identifier*/, const AuthenticationChallenge&)    
index e21a002..20f1538 100644 (file)
@@ -174,6 +174,7 @@ WebProcess::WebProcess()
 #if USE(SOUP)
     , m_soupRequestManager(this)
 #endif
+    , m_authenticationManager(m_messageReceiverMap)
 {
 #if USE(PLATFORM_STRATEGIES)
     // Initialize our platform strategies.
@@ -201,6 +202,8 @@ void WebProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier, Ru
 
     m_runLoop = runLoop;
 
+    m_authenticationManager.setConnection(m_connection.get());
+
     startRandomCrashThreadIfRequested();
 }
 
index 6e4622e..c448287 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef WebProcess_h
 #define WebProcess_h
 
+#include "AuthenticationManager.h"
 #include "CacheModel.h"
 #include "ChildProcess.h"
 #include "DownloadManager.h"
@@ -217,6 +218,7 @@ public:
     void destroyPrivateBrowsingSession();
 
     DownloadManager& downloadManager();
+    AuthenticationManager& authenticationManager() { return m_authenticationManager; }
 
 private:
     WebProcess();
@@ -393,6 +395,7 @@ private:
     WebSoupRequestManager m_soupRequestManager;
 #endif
 
+    AuthenticationManager m_authenticationManager;
 };
 
 } // namespace WebKit