Diff
Modified: trunk/Source/WebKit2/ChangeLog (138532 => 138533)
--- trunk/Source/WebKit2/ChangeLog 2012-12-28 12:51:41 UTC (rev 138532)
+++ trunk/Source/WebKit2/ChangeLog 2012-12-28 14:26:00 UTC (rev 138533)
@@ -1,5 +1,46 @@
2012-12-27 Sam Weinig <[email protected]>
+ Make CustomProtocolManager a WebProcessSupplement
+ https://bugs.webkit.org/show_bug.cgi?id=105814
+
+ Reviewed by Dan Bernstein.
+
+ This converts CustomProtocolManager from a global singleton, to be a
+ supplement of the WebProcess. Since it also needs to act as a supplement
+ of the NetworkProcess, it adds an initialization function for the NetworkProcess
+ as well, while we await the arrival of the forthcoming NetworkProcessSupplement.
+
+ In addition, this moves the handling of registering and unregistering schemes
+ directly to the CustomProtocolManager, instead of requiring an unnecessary trip
+ in the ChildProcess.
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::NetworkProcess):
+ (WebKit::NetworkProcess::initializeNetworkProcess):
+ * NetworkProcess/NetworkProcess.h:
+ * NetworkProcess/NetworkProcess.messages.in:
+ * Shared/Network/CustomProtocols/CustomProtocolManager.h:
+ (CustomProtocolManager):
+ * Shared/Network/CustomProtocols/CustomProtocolManager.messages.in:
+ * Shared/Network/CustomProtocols/mac/CustomProtocolManagerMac.mm:
+ (+[WKCustomProtocol canInitWithRequest:]):
+ (-[WKCustomProtocol initWithRequest:cachedResponse:client:]):
+ (-[WKCustomProtocol startLoading]):
+ (-[WKCustomProtocol stopLoading]):
+ (WebKit::CustomProtocolManager::supplementName):
+ (WebKit::CustomProtocolManager::CustomProtocolManager):
+ (WebKit::CustomProtocolManager::initialize):
+ * UIProcess/WebContext.cpp:
+ (WebKit::WebContext::registerSchemeForCustomProtocol):
+ (WebKit::WebContext::unregisterSchemeForCustomProtocol):
+ * WebProcess/WebProcess.cpp:
+ (WebKit::WebProcess::WebProcess):
+ (WebKit::WebProcess::initializeWebProcess):
+ * WebProcess/WebProcess.h:
+ * WebProcess/WebProcess.messages.in:
+
+2012-12-27 Sam Weinig <[email protected]>
+
Convert a few other WebProcess managers to be WebProcessSupplements
https://bugs.webkit.org/show_bug.cgi?id=105812
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (138532 => 138533)
--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2012-12-28 12:51:41 UTC (rev 138532)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2012-12-28 14:26:00 UTC (rev 138533)
@@ -58,10 +58,8 @@
, m_cacheModel(CacheModelDocumentViewer)
, m_downloadsAuthenticationManager(new AuthenticationManager(this))
, m_cookieManager(new WebCookieManager(this))
+ , m_customProtocolManager(new CustomProtocolManager(this))
{
-#if ENABLE(CUSTOM_PROTOCOLS)
- CustomProtocolManager::shared().initialize(this);
-#endif
}
NetworkProcess::~NetworkProcess()
@@ -159,11 +157,7 @@
if (parameters.privateBrowsingEnabled)
RemoteNetworkingContext::ensurePrivateBrowsingSession();
-#if ENABLE(CUSTOM_PROTOCOLS)
- CustomProtocolManager::shared().connectionEstablished();
- for (size_t i = 0; i < parameters.urlSchemesRegisteredForCustomProtocols.size(); ++i)
- CustomProtocolManager::shared().registerScheme(parameters.urlSchemesRegisteredForCustomProtocols[i]);
-#endif
+ m_customProtocolManager->initialize(parameters);
}
void NetworkProcess::createNetworkConnectionToWebProcess()
@@ -204,18 +198,6 @@
downloadManager().cancelDownload(downloadID);
}
-#if ENABLE(CUSTOM_PROTOCOLS)
-void NetworkProcess::registerSchemeForCustomProtocol(const String& scheme)
-{
- CustomProtocolManager::shared().registerScheme(scheme);
-}
-
-void NetworkProcess::unregisterSchemeForCustomProtocol(const String& scheme)
-{
- CustomProtocolManager::shared().unregisterScheme(scheme);
-}
-#endif
-
void NetworkProcess::setCacheModel(uint32_t cm)
{
CacheModel cacheModel = static_cast<CacheModel>(cm);
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h (138532 => 138533)
--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h 2012-12-28 12:51:41 UTC (rev 138532)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.h 2012-12-28 14:26:00 UTC (rev 138533)
@@ -42,6 +42,7 @@
namespace WebKit {
class AuthenticationManager;
+class CustomProtocolManager;
class NetworkConnectionToWebProcess;
class PlatformCertificateInfo;
class WebCookieManager;
@@ -92,10 +93,6 @@
void downloadRequest(uint64_t downloadID, const WebCore::ResourceRequest&);
void cancelDownload(uint64_t downloadID);
void setCacheModel(uint32_t);
-#if ENABLE(CUSTOM_PROTOCOLS)
- void registerSchemeForCustomProtocol(const String&);
- void unregisterSchemeForCustomProtocol(const String&);
-#endif
void allowSpecificHTTPSCertificateForHost(const PlatformCertificateInfo&, const String& host);
@@ -116,6 +113,7 @@
AuthenticationManager* m_downloadsAuthenticationManager;
WebCookieManager* m_cookieManager;
+ CustomProtocolManager* m_customProtocolManager;
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in (138532 => 138533)
--- trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in 2012-12-28 12:51:41 UTC (rev 138532)
+++ trunk/Source/WebKit2/NetworkProcess/NetworkProcess.messages.in 2012-12-28 14:26:00 UTC (rev 138533)
@@ -39,11 +39,6 @@
SetApplicationIsOccluded(bool flag)
#endif
-#if ENABLE(CUSTOM_PROTOCOLS)
- RegisterSchemeForCustomProtocol(WTF::String name)
- UnregisterSchemeForCustomProtocol(WTF::String name)
-#endif
-
AllowSpecificHTTPSCertificateForHost(WebKit::PlatformCertificateInfo certificate, WTF::String host)
}
Modified: trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h (138532 => 138533)
--- trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h 2012-12-28 12:51:41 UTC (rev 138532)
+++ trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.h 2012-12-28 14:26:00 UTC (rev 138533)
@@ -28,8 +28,7 @@
#if ENABLE(CUSTOM_PROTOCOLS)
-#include "Connection.h"
-#include "MessageReceiver.h"
+#include "WebProcessSupplement.h"
#include <wtf/HashSet.h>
#include <wtf/text/WTFString.h>
@@ -52,16 +51,21 @@
namespace WebKit {
class ChildProcess;
+struct NetworkProcessCreationParameters;
-class CustomProtocolManager : private CoreIPC::MessageReceiver {
+class CustomProtocolManager : public WebProcessSupplement {
WTF_MAKE_NONCOPYABLE(CustomProtocolManager);
-
public:
- static CustomProtocolManager& shared();
-
- void initialize(ChildProcess*);
- void connectionEstablished();
+ explicit CustomProtocolManager(ChildProcess*);
+ static const AtomicString& supplementName();
+
+#if ENABLE(NETWORK_PROCESS)
+ // FIXME: Once NetworkProcessSupplement exists, this should
+ // move to the private section.
+ void initialize(const NetworkProcessCreationParameters&);
+#endif
+
ChildProcess* childProcess() const { return m_childProcess; }
void registerScheme(const String&);
@@ -74,7 +78,8 @@
#endif
private:
- CustomProtocolManager();
+ // WebProcessSupplement
+ void initialize(const WebProcessCreationParameters&) OVERRIDE;
// CoreIPC::MessageReceiver
virtual void didReceiveMessage(CoreIPC::Connection*, CoreIPC::MessageID, CoreIPC::MessageDecoder&) OVERRIDE;
Modified: trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in (138532 => 138533)
--- trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in 2012-12-28 12:51:41 UTC (rev 138532)
+++ trunk/Source/WebKit2/Shared/Network/CustomProtocols/CustomProtocolManager.messages.in 2012-12-28 14:26:00 UTC (rev 138533)
@@ -27,6 +27,9 @@
DidLoadData(uint64_t customProtocolID, CoreIPC::DataReference data)
DidReceiveResponse(uint64_t customProtocolID, WebCore::ResourceResponse response, uint32_t cacheStoragePolicy)
DidFinishLoading(uint64_t customProtocolID)
+
+ RegisterScheme(WTF::String name)
+ UnregisterScheme(WTF::String name)
}
#endif // ENABLE(CUSTOM_PROTOCOLS)
Modified: trunk/Source/WebKit2/Shared/Network/CustomProtocols/mac/CustomProtocolManagerMac.mm (138532 => 138533)
--- trunk/Source/WebKit2/Shared/Network/CustomProtocols/mac/CustomProtocolManagerMac.mm 2012-12-28 12:51:41 UTC (rev 138532)
+++ trunk/Source/WebKit2/Shared/Network/CustomProtocols/mac/CustomProtocolManagerMac.mm 2012-12-28 14:26:00 UTC (rev 138533)
@@ -33,19 +33,30 @@
#import "CustomProtocolManagerProxyMessages.h"
#import "DataReference.h"
#import "WebCoreArgumentCoders.h"
+#import "WebProcessCreationParameters.h"
#import <WebCore/KURL.h>
#import <WebCore/ResourceError.h>
#import <WebCore/ResourceRequest.h>
#import <WebCore/ResourceResponse.h>
+#if ENABLE(NETWORK_PROCESS)
+#import "NetworkProcessCreationParameters.h"
+#endif
+
using namespace WebKit;
+namespace WebKit {
+
+static CustomProtocolManager* sharedCustomProtocolManager;
+
static uint64_t generateCustomProtocolID()
{
static uint64_t uniqueCustomProtocolID = 0;
return ++uniqueCustomProtocolID;
}
+} // namespace WebKit
+
@interface WKCustomProtocol : NSURLProtocol {
@private
uint64_t _customProtocolID;
@@ -59,7 +70,7 @@
+ (BOOL)canInitWithRequest:(NSURLRequest *)request
{
- return CustomProtocolManager::shared().supportsScheme([[[request URL] scheme] lowercaseString]);
+ return sharedCustomProtocolManager->supportsScheme([[[request URL] scheme] lowercaseString]);
}
+ (NSURLRequest *)canonicalRequestForRequest:(NSURLRequest *)request
@@ -79,49 +90,63 @@
return nil;
_customProtocolID = generateCustomProtocolID();
- CustomProtocolManager::shared().addCustomProtocol(self);
+ sharedCustomProtocolManager->addCustomProtocol(self);
return self;
}
- (void)startLoading
{
- CustomProtocolManager::shared().childProcess()->send(Messages::CustomProtocolManagerProxy::StartLoading(self.customProtocolID, [self request]), 0);
+ sharedCustomProtocolManager->childProcess()->send(Messages::CustomProtocolManagerProxy::StartLoading(self.customProtocolID, [self request]), 0);
}
- (void)stopLoading
{
- CustomProtocolManager::shared().childProcess()->send(Messages::CustomProtocolManagerProxy::StopLoading(self.customProtocolID), 0);
- CustomProtocolManager::shared().removeCustomProtocol(self);
+ sharedCustomProtocolManager->childProcess()->send(Messages::CustomProtocolManagerProxy::StopLoading(self.customProtocolID), 0);
+ sharedCustomProtocolManager->removeCustomProtocol(self);
}
@end
namespace WebKit {
-CustomProtocolManager& CustomProtocolManager::shared()
+const AtomicString& CustomProtocolManager::supplementName()
{
- DEFINE_STATIC_LOCAL(CustomProtocolManager, customProtocolManager, ());
- return customProtocolManager;
+ DEFINE_STATIC_LOCAL(AtomicString, name, ("CustomProtocolManager", AtomicString::ConstructFromLiteral));
+ return name;
}
-CustomProtocolManager::CustomProtocolManager()
- : m_childProcess(0)
+CustomProtocolManager::CustomProtocolManager(ChildProcess* childProcess)
+ : m_childProcess(childProcess)
{
+ m_childProcess->addMessageReceiver(Messages::CustomProtocolManager::messageReceiverName(), this);
+
+ ASSERT(!sharedCustomProtocolManager);
+ sharedCustomProtocolManager = this;
}
-void CustomProtocolManager::initialize(ChildProcess* childProcess)
+void CustomProtocolManager::initialize(const WebProcessCreationParameters& parameters)
{
- ASSERT(!m_childProcess);
- ASSERT(childProcess);
+#if ENABLE(NETWORK_PROCESS)
+ ASSERT(parameters.urlSchemesRegisteredForCustomProtocols.isEmpty() || !parameters.usesNetworkProcess);
+ if (parameters.usesNetworkProcess)
+ return;
+#endif
- m_childProcess = childProcess;
- m_childProcess->addMessageReceiver(Messages::CustomProtocolManager::messageReceiverName(), this);
+ [NSURLProtocol registerClass:[WKCustomProtocol class]];
+
+ for (size_t i = 0; i < parameters.urlSchemesRegisteredForCustomProtocols.size(); ++i)
+ registerScheme(parameters.urlSchemesRegisteredForCustomProtocols[i]);
}
-void CustomProtocolManager::connectionEstablished()
+#if ENABLE(NETWORK_PROCESS)
+void CustomProtocolManager::initialize(const NetworkProcessCreationParameters& parameters)
{
[NSURLProtocol registerClass:[WKCustomProtocol class]];
+
+ for (size_t i = 0; i < parameters.urlSchemesRegisteredForCustomProtocols.size(); ++i)
+ registerScheme(parameters.urlSchemesRegisteredForCustomProtocols[i]);
}
+#endif
void CustomProtocolManager::addCustomProtocol(WKCustomProtocol *customProtocol)
{
Modified: trunk/Source/WebKit2/UIProcess/WebContext.cpp (138532 => 138533)
--- trunk/Source/WebKit2/UIProcess/WebContext.cpp 2012-12-28 12:51:41 UTC (rev 138532)
+++ trunk/Source/WebKit2/UIProcess/WebContext.cpp 2012-12-28 14:26:00 UTC (rev 138533)
@@ -77,6 +77,10 @@
#include "NetworkProcessProxy.h"
#endif
+#if ENABLE(CUSTOM_PROTOCOLS)
+#include "CustomProtocolManagerMessages.h"
+#endif
+
#if USE(SOUP)
#include "WebSoupRequestManagerProxy.h"
#endif
@@ -1175,26 +1179,14 @@
}
#if ENABLE(CUSTOM_PROTOCOLS)
-void WebContext::registerSchemeForCustomProtocol(const WTF::String& scheme)
+void WebContext::registerSchemeForCustomProtocol(const String& scheme)
{
-#if ENABLE(NETWORK_PROCESS)
- if (m_usesNetworkProcess && m_networkProcess) {
- m_networkProcess->send(Messages::NetworkProcess::RegisterSchemeForCustomProtocol(scheme), 0);
- return;
- }
-#endif
- sendToAllProcesses(Messages::WebProcess::RegisterSchemeForCustomProtocol(scheme));
+ sendToNetworkingProcess(Messages::CustomProtocolManager::RegisterScheme(scheme));
}
-void WebContext::unregisterSchemeForCustomProtocol(const WTF::String& scheme)
+void WebContext::unregisterSchemeForCustomProtocol(const String& scheme)
{
-#if ENABLE(NETWORK_PROCESS)
- if (m_usesNetworkProcess && m_networkProcess) {
- m_networkProcess->send(Messages::NetworkProcess::UnregisterSchemeForCustomProtocol(scheme), 0);
- return;
- }
-#endif
- sendToAllProcesses(Messages::WebProcess::UnregisterSchemeForCustomProtocol(scheme));
+ sendToNetworkingProcess(Messages::CustomProtocolManager::UnregisterScheme(scheme));
}
#endif
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.cpp (138532 => 138533)
--- trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2012-12-28 12:51:41 UTC (rev 138532)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.cpp 2012-12-28 14:26:00 UTC (rev 138533)
@@ -176,9 +176,6 @@
#endif // !LOG_DISABLED
-#if ENABLE(CUSTOM_PROTOCOLS)
- CustomProtocolManager::shared().initialize(this);
-#endif
// FIXME: This should moved to where WebProcess::initialize is called,
// so that ports have a chance to customize, and ifdefs in this file are
@@ -198,6 +195,9 @@
#if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
addSupplement<WebNotificationManager>();
#endif
+#if ENABLE(CUSTOM_PROTOCOLS)
+ addSupplement<CustomProtocolManager>();
+#endif
}
void WebProcess::initialize(CoreIPC::Connection::Identifier serverIdentifier, RunLoop* runLoop)
@@ -322,10 +322,6 @@
for (size_t i = 0; i < parameters.plugInAutoStartOrigins.size(); ++i)
didAddPlugInAutoStartOrigin(parameters.plugInAutoStartOrigins[i]);
-
-#if ENABLE(CUSTOM_PROTOCOLS)
- initializeCustomProtocolManager(parameters);
-#endif
}
#if ENABLE(NETWORK_PROCESS)
@@ -1076,29 +1072,4 @@
}
#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().connectionEstablished();
- 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);
-}
-
-void WebProcess::unregisterSchemeForCustomProtocol(const WTF::String& scheme)
-{
- CustomProtocolManager::shared().unregisterScheme(scheme);
-}
-#endif // ENABLE(CUSTOM_PROTOCOLS)
-
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.h (138532 => 138533)
--- trunk/Source/WebKit2/WebProcess/WebProcess.h 2012-12-28 12:51:41 UTC (rev 138532)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.h 2012-12-28 14:26:00 UTC (rev 138533)
@@ -309,12 +309,6 @@
void didGetPlugins(CoreIPC::Connection*, uint64_t requestID, const Vector<WebCore::PluginInfo>&);
#endif
-#if ENABLE(CUSTOM_PROTOCOLS)
- void initializeCustomProtocolManager(const WebProcessCreationParameters&);
- void registerSchemeForCustomProtocol(const WTF::String&);
- void unregisterSchemeForCustomProtocol(const WTF::String&);
-#endif
-
RefPtr<CoreIPC::Connection> m_connection;
RefPtr<WebConnectionToUIProcess> m_webConnection;
Modified: trunk/Source/WebKit2/WebProcess/WebProcess.messages.in (138532 => 138533)
--- trunk/Source/WebKit2/WebProcess/WebProcess.messages.in 2012-12-28 12:51:41 UTC (rev 138532)
+++ trunk/Source/WebKit2/WebProcess/WebProcess.messages.in 2012-12-28 14:26:00 UTC (rev 138533)
@@ -105,9 +105,4 @@
#if PLATFORM(MAC)
SetApplicationIsOccluded(bool flag);
#endif
-
-#if ENABLE(CUSTOM_PROTOCOLS)
- RegisterSchemeForCustomProtocol(WTF::String name)
- UnregisterSchemeForCustomProtocol(WTF::String name)
-#endif
}