Title: [137831] trunk/Source/WebKit2
Revision
137831
Author
[email protected]
Date
2012-12-15 18:54:54 -0800 (Sat, 15 Dec 2012)

Log Message

[WebKit2] Have CustomProtocolManager and CustomProtocolManagerProxy store Connections for messaging
https://bugs.webkit.org/show_bug.cgi?id=105124

Reviewed by Anders Carlsson.

Remove CustomProtocolManagerProxy's assumption that all messages go to
a web process. Have it take a ChildProcessProxy instead and extract its
connection.

Similarly, remove CustomProtocolManager's assumption that all messages
go through a shared WebProcess. Initialize the shared CustomProtocolManager
with a Connection object instead.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::initializeNetworkProcess): Initialize the
shared CustomProtocolManager with the NetworkProcess's connection to
the UI process.
* Shared/Network/CustomProtocols/CustomProtocolManager.h:
(WebKit::CustomProtocolManager::connection): Assert m_connection is
non-0 and return it.
* Shared/Network/CustomProtocols/mac/CustomProtocolManagerMac.mm:
(+[WKCustomProtocol canInitWithRequest:]): Remove an unnecessary
namespace.
(-[WKCustomProtocol initWithRequest:cachedResponse:client:]): Ditto.
(-[WKCustomProtocol startLoading]): Send a message on the
CustomProtocolManager's connection rather than assuming there is a
shared WebProcess in our address space.
(-[WKCustomProtocol stopLoading]): Ditto.
(WebKit::CustomProtocolManager::initialize): Initialize the shared
CustomProtocolManager with a Connection and register our custom
protocol handler with NSURLProtocol.
* UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.h:
(WebKit):
(CustomProtocolManagerProxy): Take a ChildProcessProxy* rather than a
WebProcessProxy*.
* UIProcess/Network/CustomProtocols/mac/CustomProtocolManagerProxyMac.mm:
(WebKit::CustomProtocolManagerProxy::CustomProtocolManagerProxy): Ditto.
(WebKit::CustomProtocolManagerProxy::startLoading): Ditto.
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::NetworkProcessProxy): Instantiate a
CustomProtocolManagerProxy for the network process.
(WebKit::NetworkProcessProxy::didReceiveMessage): Route messages of
class MessageClassCustomProtocolManagerProxy to the
CustomProtocolManagerProxy.
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::didReceiveMessage): Assert that we aren't
using the network process since we've received a message from a
web process's CustomProtocolManager.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess): Break CustomProtocolManager
initialization out into a helper function.
(WebKit::WebProcess::initializeCustomProtocolManager): Initialize our
CustomProtocolManager.
* WebProcess/WebProcess.h:

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (137830 => 137831)


--- trunk/Source/WebKit2/ChangeLog	2012-12-16 02:47:55 UTC (rev 137830)
+++ trunk/Source/WebKit2/ChangeLog	2012-12-16 02:54:54 UTC (rev 137831)
@@ -1,3 +1,61 @@
+2012-12-15  Andy Estes  <[email protected]>
+
+        [WebKit2] Have CustomProtocolManager and CustomProtocolManagerProxy store Connections for messaging
+        https://bugs.webkit.org/show_bug.cgi?id=105124
+
+        Reviewed by Anders Carlsson.
+
+        Remove CustomProtocolManagerProxy's assumption that all messages go to
+        a web process. Have it take a ChildProcessProxy instead and extract its
+        connection.
+
+        Similarly, remove CustomProtocolManager's assumption that all messages
+        go through a shared WebProcess. Initialize the shared CustomProtocolManager
+        with a Connection object instead.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::initializeNetworkProcess): Initialize the
+        shared CustomProtocolManager with the NetworkProcess's connection to
+        the UI process.
+        * Shared/Network/CustomProtocols/CustomProtocolManager.h:
+        (WebKit::CustomProtocolManager::connection): Assert m_connection is
+        non-0 and return it.
+        * Shared/Network/CustomProtocols/mac/CustomProtocolManagerMac.mm:
+        (+[WKCustomProtocol canInitWithRequest:]): Remove an unnecessary
+        namespace.
+        (-[WKCustomProtocol initWithRequest:cachedResponse:client:]): Ditto.
+        (-[WKCustomProtocol startLoading]): Send a message on the
+        CustomProtocolManager's connection rather than assuming there is a
+        shared WebProcess in our address space.
+        (-[WKCustomProtocol stopLoading]): Ditto.
+        (WebKit::CustomProtocolManager::initialize): Initialize the shared
+        CustomProtocolManager with a Connection and register our custom
+        protocol handler with NSURLProtocol.
+        * UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.h:
+        (WebKit):
+        (CustomProtocolManagerProxy): Take a ChildProcessProxy* rather than a
+        WebProcessProxy*.
+        * UIProcess/Network/CustomProtocols/mac/CustomProtocolManagerProxyMac.mm:
+        (WebKit::CustomProtocolManagerProxy::CustomProtocolManagerProxy): Ditto.
+        (WebKit::CustomProtocolManagerProxy::startLoading): Ditto.
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::NetworkProcessProxy): Instantiate a
+        CustomProtocolManagerProxy for the network process.
+        (WebKit::NetworkProcessProxy::didReceiveMessage): Route messages of
+        class MessageClassCustomProtocolManagerProxy to the
+        CustomProtocolManagerProxy.
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::didReceiveMessage): Assert that we aren't
+        using the network process since we've received a message from a
+        web process's CustomProtocolManager.
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess): Break CustomProtocolManager
+        initialization out into a helper function.
+        (WebKit::WebProcess::initializeCustomProtocolManager): Initialize our
+        CustomProtocolManager.
+        * WebProcess/WebProcess.h:
+
 2012-12-15  Anders Carlsson  <[email protected]>
 
         Happy little Qt build fix.

Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (137830 => 137831)


--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2012-12-16 02:47:55 UTC (rev 137830)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp	2012-12-16 02:54:54 UTC (rev 137831)
@@ -139,10 +139,9 @@
         RemoteNetworkingContext::ensurePrivateBrowsingSession();
 
 #if ENABLE(CUSTOM_PROTOCOLS)
+    CustomProtocolManager::shared().initialize(m_uiConnection);
     for (size_t i = 0; i < parameters.urlSchemesRegisteredForCustomProtocols.size(); ++i)
         CustomProtocolManager::shared().registerScheme(parameters.urlSchemesRegisteredForCustomProtocols[i]);
-
-    CustomProtocolManager::registerCustomProtocolClass();
 #endif
 }
 

Modified: trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h (137830 => 137831)


--- trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h	2012-12-16 02:47:55 UTC (rev 137830)
+++ trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h	2012-12-16 02:54:54 UTC (rev 137831)
@@ -28,6 +28,7 @@
 
 #if ENABLE(CUSTOM_PROTOCOLS)
 
+#include "Connection.h"
 #include "MessageID.h"
 #include <wtf/HashSet.h>
 #include <wtf/text/WTFString.h>
@@ -40,7 +41,6 @@
 
 
 namespace CoreIPC {
-class Connection;
 class DataReference;
 class MessageDecoder;
 } // namespace CoreIPC
@@ -58,6 +58,14 @@
 public:
     static CustomProtocolManager& shared();
     
+    void initialize(PassRefPtr<CoreIPC::Connection>);
+
+    CoreIPC::Connection* connection() const
+    {
+        ASSERT(m_connection);
+        return m_connection.get();
+    }
+
     void registerScheme(const String&);
     void unregisterScheme(const String&);
     bool supportsScheme(const String&);
@@ -69,7 +77,6 @@
     void didFinishLoading(uint64_t customProtocolID);
     
 #if PLATFORM(MAC)
-    static void registerCustomProtocolClass();
     void addCustomProtocol(WKCustomProtocol *);
     void removeCustomProtocol(WKCustomProtocol *);
 #endif
@@ -79,6 +86,7 @@
     void didReceiveCustomProtocolManagerMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
     
     HashSet<String> m_registeredSchemes;
+    RefPtr<CoreIPC::Connection> m_connection;
 
 #if PLATFORM(MAC)
     typedef HashMap<uint64_t, RetainPtr<WKCustomProtocol> > CustomProtocolMap;

Modified: trunk/Source/WebKit2/Shared/Network/CustomProtocols/mac/CustomProtocolManagerMac.mm (137830 => 137831)


--- trunk/Source/WebKit2/Shared/Network/CustomProtocols/mac/CustomProtocolManagerMac.mm	2012-12-16 02:47:55 UTC (rev 137830)
+++ trunk/Source/WebKit2/Shared/Network/CustomProtocols/mac/CustomProtocolManagerMac.mm	2012-12-16 02:54:54 UTC (rev 137831)
@@ -55,7 +55,7 @@
 
 + (BOOL)canInitWithRequest:(NSURLRequest *)request
 {
-    return WebKit::CustomProtocolManager::shared().supportsScheme([[[request URL] scheme] lowercaseString]);
+    return CustomProtocolManager::shared().supportsScheme([[[request URL] scheme] lowercaseString]);
 }
 
 + (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request
@@ -75,19 +75,19 @@
         return nil;
     
     _customProtocolID = generateCustomProtocolID();
-    WebKit::CustomProtocolManager::shared().addCustomProtocol(self);
+    CustomProtocolManager::shared().addCustomProtocol(self);
     return self;
 }
 
 - (void)startLoading
 {
-    WebProcess::shared().connection()->send(Messages::CustomProtocolManagerProxy::StartLoading(self.customProtocolID, [self request]), 0);
+    CustomProtocolManager::shared().connection()->send(Messages::CustomProtocolManagerProxy::StartLoading(self.customProtocolID, [self request]), 0);
 }
 
 - (void)stopLoading
 {
-    WebProcess::shared().connection()->send(Messages::CustomProtocolManagerProxy::StopLoading(self.customProtocolID), 0);
-    WebKit::CustomProtocolManager::shared().removeCustomProtocol(self);
+    CustomProtocolManager::shared().connection()->send(Messages::CustomProtocolManagerProxy::StopLoading(self.customProtocolID), 0);
+    CustomProtocolManager::shared().removeCustomProtocol(self);
 }
 
 @end
@@ -100,11 +100,14 @@
     return customProtocolManager;
 }
 
-void CustomProtocolManager::registerCustomProtocolClass()
+void CustomProtocolManager::initialize(PassRefPtr<CoreIPC::Connection> connection)
 {
+    ASSERT(connection);
+    ASSERT(!CustomProtocolManager::shared().m_connection);
+    CustomProtocolManager::shared().m_connection = connection;
     [NSURLProtocol registerClass:[WKCustomProtocol class]];
 }
-    
+
 void CustomProtocolManager::addCustomProtocol(WKCustomProtocol *customProtocol)
 {
     ASSERT(customProtocol);

Modified: trunk/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.h (137830 => 137831)


--- trunk/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.h	2012-12-16 02:47:55 UTC (rev 137830)
+++ trunk/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.h	2012-12-16 02:54:54 UTC (rev 137831)
@@ -47,11 +47,11 @@
 
 namespace WebKit {
 
-class WebProcessProxy;
+class ChildProcessProxy;
 
 class CustomProtocolManagerProxy {
 public:
-    explicit CustomProtocolManagerProxy(WebProcessProxy*);
+    explicit CustomProtocolManagerProxy(ChildProcessProxy*);
 
     void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
     void startLoading(uint64_t customProtocolID, const WebCore::ResourceRequest&);
@@ -60,7 +60,7 @@
 private:
     void didReceiveCustomProtocolManagerProxyMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&);
 
-    WebProcessProxy* m_webProcessProxy;
+    ChildProcessProxy* m_childProcessProxy;
 
 #if PLATFORM(MAC)
     typedef HashMap<uint64_t, RetainPtr<WKCustomProtocolLoader> > LoaderMap;

Modified: trunk/Source/WebKit2/UIProcess/Network/CustomProtocols/mac/CustomProtocolManagerProxyMac.mm (137830 => 137831)


--- trunk/Source/WebKit2/UIProcess/Network/CustomProtocols/mac/CustomProtocolManagerProxyMac.mm	2012-12-16 02:47:55 UTC (rev 137830)
+++ trunk/Source/WebKit2/UIProcess/Network/CustomProtocols/mac/CustomProtocolManagerProxyMac.mm	2012-12-16 02:54:54 UTC (rev 137831)
@@ -28,11 +28,13 @@
 
 #if ENABLE(CUSTOM_PROTOCOLS)
 
+#import "ChildProcessProxy.h"
 #import "Connection.h"
 #import "CustomProtocolManagerMessages.h"
 #import "DataReference.h"
-#import "WebProcessProxy.h"
+#import "WebCoreArgumentCoders.h"
 #import <WebCore/ResourceError.h>
+#import <WebCore/ResourceRequest.h>
 #import <WebCore/ResourceResponse.h>
 
 using namespace CoreIPC;
@@ -119,10 +121,10 @@
 
 namespace WebKit {
 
-CustomProtocolManagerProxy::CustomProtocolManagerProxy(WebProcessProxy* webProcessProxy)
-    : m_webProcessProxy(webProcessProxy)
+CustomProtocolManagerProxy::CustomProtocolManagerProxy(ChildProcessProxy* childProcessProxy)
+    : m_childProcessProxy(childProcessProxy)
 {
-    ASSERT(m_webProcessProxy);
+    ASSERT(m_childProcessProxy);
 }
 
 void CustomProtocolManagerProxy::didReceiveMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::MessageDecoder& decoder)
@@ -136,7 +138,7 @@
     if (!request)
         return;
 
-    WKCustomProtocolLoader *loader = [[WKCustomProtocolLoader alloc] initWithCustomProtocolManagerProxy:this customProtocolID:customProtocolID request:request connection:m_webProcessProxy->connection()];
+    WKCustomProtocolLoader *loader = [[WKCustomProtocolLoader alloc] initWithCustomProtocolManagerProxy:this customProtocolID:customProtocolID request:request connection:m_childProcessProxy->connection()];
     ASSERT(loader);
     ASSERT(!m_loaderMap.contains(customProtocolID));
     m_loaderMap.add(customProtocolID, loader);

Modified: trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp (137830 => 137831)


--- trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp	2012-12-16 02:47:55 UTC (rev 137830)
+++ trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp	2012-12-16 02:54:54 UTC (rev 137831)
@@ -47,6 +47,9 @@
 NetworkProcessProxy::NetworkProcessProxy(WebContext* webContext)
     : m_webContext(webContext)
     , m_numPendingConnectionRequests(0)
+#if ENABLE(CUSTOM_PROTOCOLS)
+    , m_customProtocolManagerProxy(this)
+#endif
 {
     connect();
 }
@@ -110,6 +113,13 @@
     if (m_messageReceiverMap.dispatchMessage(connection, messageID, decoder))
         return;
 
+#if ENABLE(CUSTOM_PROTOCOLS)
+    if (messageID.is<CoreIPC::MessageClassCustomProtocolManagerProxy>()) {
+        m_customProtocolManagerProxy.didReceiveMessage(connection, messageID, decoder);
+        return;
+    }
+#endif
+
     didReceiveNetworkProcessProxyMessage(connection, messageID, decoder);
 }
 

Modified: trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h (137830 => 137831)


--- trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h	2012-12-16 02:47:55 UTC (rev 137830)
+++ trunk/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h	2012-12-16 02:54:54 UTC (rev 137831)
@@ -35,6 +35,10 @@
 #include "WebProcessProxyMessages.h"
 #include <wtf/Deque.h>
 
+#if ENABLE(CUSTOM_PROTOCOLS)
+#include "CustomProtocolManagerProxy.h"
+#endif
+
 namespace WebKit {
 
 class DownloadProxy;
@@ -82,6 +86,10 @@
 
     CoreIPC::MessageReceiverMap m_messageReceiverMap;
     OwnPtr<DownloadProxyMap> m_downloadProxyMap;
+
+#if ENABLE(CUSTOM_PROTOCOLS)
+    CustomProtocolManagerProxy m_customProtocolManagerProxy;
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (137830 => 137831)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2012-12-16 02:47:55 UTC (rev 137830)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2012-12-16 02:54:54 UTC (rev 137831)
@@ -395,6 +395,9 @@
 
 #if ENABLE(CUSTOM_PROTOCOLS)
     if (messageID.is<CoreIPC::MessageClassCustomProtocolManagerProxy>()) {
+#if ENABLE(NETWORK_PROCESS)
+        ASSERT(!context()->usesNetworkProcess());
+#endif
         m_customProtocolManagerProxy.didReceiveMessage(connection, messageID, decoder);
         return;
     }

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (137830 => 137831)


--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2012-12-16 02:47:55 UTC (rev 137830)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp	2012-12-16 02:54:54 UTC (rev 137831)
@@ -325,17 +325,8 @@
         didAddPlugInAutoStartOrigin(parameters.plugInAutoStartOrigins[i]);
 
 #if ENABLE(CUSTOM_PROTOCOLS)
-#if ENABLE(NETWORK_PROCESS)
-    ASSERT(parameters.urlSchemesRegisteredForCustomProtocols.isEmpty() || !m_usesNetworkProcess);
+    initializeCustomProtocolManager(parameters);
 #endif
-    for (size_t i = 0; i < parameters.urlSchemesRegisteredForCustomProtocols.size(); ++i)
-        CustomProtocolManager::shared().registerScheme(parameters.urlSchemesRegisteredForCustomProtocols[i]);
-
-#if ENABLE(NETWORK_PROCESS)
-    if (!m_usesNetworkProcess)
-#endif
-        CustomProtocolManager::registerCustomProtocolClass();
-#endif
 }
 
 #if ENABLE(NETWORK_PROCESS)
@@ -1098,6 +1089,19 @@
 #endif // ENABLE(PLUGIN_PROCESS)
 
 #if ENABLE(CUSTOM_PROTOCOLS)
+void WebProcess::initializeCustomProtocolManager(const WebProcessCreationParameters& parameters)
+{
+#if ENABLE(NETWORK_PROCESS)
+    ASSERT(parameters.urlSchemesRegisteredForCustomProtocols.isEmpty() || !m_usesNetworkProcess);
+    if (m_usesNetworkProcess)
+        return;
+#endif
+
+    CustomProtocolManager::shared().initialize(m_connection);
+    for (size_t i = 0; i < parameters.urlSchemesRegisteredForCustomProtocols.size(); ++i)
+        CustomProtocolManager::shared().registerScheme(parameters.urlSchemesRegisteredForCustomProtocols[i]);
+}
+
 void WebProcess::registerSchemeForCustomProtocol(const WTF::String& scheme)
 {
     CustomProtocolManager::shared().registerScheme(scheme);
@@ -1107,6 +1111,6 @@
 {
     CustomProtocolManager::shared().unregisterScheme(scheme);
 }
-#endif
+#endif // ENABLE(CUSTOM_PROTOCOLS)
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (137830 => 137831)


--- trunk/Source/WebKit2/WebProcess/WebProcess.h	2012-12-16 02:47:55 UTC (rev 137830)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h	2012-12-16 02:54:54 UTC (rev 137831)
@@ -313,6 +313,7 @@
 #endif
 
 #if ENABLE(CUSTOM_PROTOCOLS)
+    void initializeCustomProtocolManager(const WebProcessCreationParameters&);
     void registerSchemeForCustomProtocol(const WTF::String&);
     void unregisterSchemeForCustomProtocol(const WTF::String&);
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to