summaryrefslogtreecommitdiff
path: root/Source/WebKit2/UIProcess/Network
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit2/UIProcess/Network')
-rw-r--r--Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.cpp86
-rw-r--r--Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.h31
-rw-r--r--Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.messages.in4
-rw-r--r--Source/WebKit2/UIProcess/Network/CustomProtocols/soup/CustomProtocolManagerProxySoup.cpp54
-rw-r--r--Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.cpp148
-rw-r--r--Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.h88
-rw-r--r--Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.cpp45
-rw-r--r--Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.h54
-rw-r--r--Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp297
-rw-r--r--Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h94
-rw-r--r--Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in22
-rw-r--r--Source/WebKit2/UIProcess/Network/soup/NetworkProcessProxySoup.cpp47
12 files changed, 442 insertions, 528 deletions
diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.cpp b/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.cpp
new file mode 100644
index 000000000..452f3a858
--- /dev/null
+++ b/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.cpp
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2013 Igalia S.L.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB. If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+#include "CustomProtocolManagerProxy.h"
+
+#include "APICustomProtocolManagerClient.h"
+#include "ChildProcessProxy.h"
+#include "CustomProtocolManagerMessages.h"
+#include "CustomProtocolManagerProxyMessages.h"
+#include "WebProcessPool.h"
+#include <WebCore/ResourceRequest.h>
+
+namespace WebKit {
+
+CustomProtocolManagerProxy::CustomProtocolManagerProxy(ChildProcessProxy* childProcessProxy, WebProcessPool& processPool)
+ : m_childProcessProxy(childProcessProxy)
+ , m_processPool(processPool)
+{
+ ASSERT(m_childProcessProxy);
+ m_childProcessProxy->addMessageReceiver(Messages::CustomProtocolManagerProxy::messageReceiverName(), *this);
+}
+
+CustomProtocolManagerProxy::~CustomProtocolManagerProxy()
+{
+ m_childProcessProxy->removeMessageReceiver(Messages::CustomProtocolManagerProxy::messageReceiverName());
+}
+
+void CustomProtocolManagerProxy::startLoading(uint64_t customProtocolID, const WebCore::ResourceRequest& request)
+{
+ m_processPool.customProtocolManagerClient().startLoading(*this, customProtocolID, request);
+}
+
+void CustomProtocolManagerProxy::stopLoading(uint64_t customProtocolID)
+{
+ m_processPool.customProtocolManagerClient().stopLoading(*this, customProtocolID);
+}
+
+void CustomProtocolManagerProxy::processDidClose()
+{
+ m_processPool.customProtocolManagerClient().invalidate(*this);
+}
+
+void CustomProtocolManagerProxy::wasRedirectedToRequest(uint64_t customProtocolID, const WebCore::ResourceRequest& request, const WebCore::ResourceResponse& redirectResponse)
+{
+ m_childProcessProxy->send(Messages::CustomProtocolManager::WasRedirectedToRequest(customProtocolID, request, redirectResponse), 0);
+}
+
+void CustomProtocolManagerProxy::didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse& response, uint32_t cacheStoragePolicy)
+{
+ m_childProcessProxy->send(Messages::CustomProtocolManager::DidReceiveResponse(customProtocolID, response, cacheStoragePolicy), 0);
+}
+
+void CustomProtocolManagerProxy::didLoadData(uint64_t customProtocolID, const IPC::DataReference& data)
+{
+ m_childProcessProxy->send(Messages::CustomProtocolManager::DidLoadData(customProtocolID, data), 0);
+}
+
+void CustomProtocolManagerProxy::didFailWithError(uint64_t customProtocolID, const WebCore::ResourceError& error)
+{
+ m_childProcessProxy->send(Messages::CustomProtocolManager::DidFailWithError(customProtocolID, error), 0);
+}
+
+void CustomProtocolManagerProxy::didFinishLoading(uint64_t customProtocolID)
+{
+ m_childProcessProxy->send(Messages::CustomProtocolManager::DidFinishLoading(customProtocolID), 0);
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.h b/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.h
index 9615a510b..ffe99cbe1 100644
--- a/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.h
+++ b/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.h
@@ -26,40 +26,53 @@
#ifndef CustomProtocolManagerProxy_h
#define CustomProtocolManagerProxy_h
-#if ENABLE(CUSTOM_PROTOCOLS)
-
#include "MessageReceiver.h"
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
#include <wtf/HashMap.h>
#include <wtf/RetainPtr.h>
OBJC_CLASS WKCustomProtocolLoader;
#endif
+namespace IPC {
+class DataReference;
+}
+
namespace WebCore {
+class ResourceError;
class ResourceRequest;
+class ResourceResponse;
} // namespace WebCore
namespace WebKit {
class ChildProcessProxy;
-class WebContext;
+class WebProcessPool;
class CustomProtocolManagerProxy : public IPC::MessageReceiver {
public:
- explicit CustomProtocolManagerProxy(ChildProcessProxy*, WebContext&);
+ CustomProtocolManagerProxy(ChildProcessProxy*, WebProcessPool&);
+ ~CustomProtocolManagerProxy();
void startLoading(uint64_t customProtocolID, const WebCore::ResourceRequest&);
void stopLoading(uint64_t customProtocolID);
+ void processDidClose();
+
+ void wasRedirectedToRequest(uint64_t customProtocolID, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&);
+ void didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse&, uint32_t cacheStoragePolicy);
+ void didLoadData(uint64_t customProtocolID, const IPC::DataReference&);
+ void didFailWithError(uint64_t customProtocolID, const WebCore::ResourceError&);
+ void didFinishLoading(uint64_t customProtocolID);
+
private:
// IPC::MessageReceiver
- virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
ChildProcessProxy* m_childProcessProxy;
- WebContext& m_webContext;
+ WebProcessPool& m_processPool;
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
typedef HashMap<uint64_t, RetainPtr<WKCustomProtocolLoader>> LoaderMap;
LoaderMap m_loaderMap;
#endif
@@ -67,6 +80,4 @@ private:
} // namespace WebKit
-#endif // ENABLE(CUSTOM_PROTOCOLS)
-
#endif // CustomProtocolManagerProxy_h
diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.messages.in b/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.messages.in
index 7aef0e0e7..93c0ad435 100644
--- a/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.messages.in
+++ b/Source/WebKit2/UIProcess/Network/CustomProtocols/CustomProtocolManagerProxy.messages.in
@@ -20,11 +20,7 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#if ENABLE(CUSTOM_PROTOCOLS)
-
messages -> CustomProtocolManagerProxy {
StartLoading(uint64_t customProtocolID, WebCore::ResourceRequest request)
StopLoading(uint64_t customProtocolID)
}
-
-#endif // ENABLE(CUSTOM_PROTOCOLS)
diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/CustomProtocolManagerProxySoup.cpp b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/CustomProtocolManagerProxySoup.cpp
deleted file mode 100644
index a6b437d04..000000000
--- a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/CustomProtocolManagerProxySoup.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2013 Igalia S.L.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "CustomProtocolManagerProxy.h"
-
-#if ENABLE(CUSTOM_PROTOCOLS)
-
-#include "ChildProcessProxy.h"
-#include "CustomProtocolManagerMessages.h"
-#include "CustomProtocolManagerProxyMessages.h"
-#include "WebContext.h"
-#include "WebSoupCustomProtocolRequestManager.h"
-#include <WebCore/ResourceRequest.h>
-
-namespace WebKit {
-
-CustomProtocolManagerProxy::CustomProtocolManagerProxy(ChildProcessProxy* childProcessProxy, WebContext& webContext)
- : m_childProcessProxy(childProcessProxy)
- , m_webContext(webContext)
-{
- ASSERT(m_childProcessProxy);
- m_childProcessProxy->addMessageReceiver(Messages::CustomProtocolManagerProxy::messageReceiverName(), *this);
-}
-
-void CustomProtocolManagerProxy::startLoading(uint64_t customProtocolID, const WebCore::ResourceRequest& request)
-{
- m_webContext.supplement<WebSoupCustomProtocolRequestManager>()->startLoading(customProtocolID, request);
-}
-
-void CustomProtocolManagerProxy::stopLoading(uint64_t customProtocolID)
-{
- m_webContext.supplement<WebSoupCustomProtocolRequestManager>()->stopLoading(customProtocolID);
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(CUSTOM_PROTOCOLS)
diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.cpp b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.cpp
deleted file mode 100644
index ad73ad494..000000000
--- a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.cpp
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2013 Igalia S.L.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "WebSoupCustomProtocolRequestManager.h"
-
-#if ENABLE(CUSTOM_PROTOCOLS)
-
-#include "APIData.h"
-#include "CustomProtocolManagerMessages.h"
-#include "WebContext.h"
-#include <WebCore/ResourceError.h>
-#include <WebCore/ResourceRequest.h>
-#include <WebCore/ResourceResponse.h>
-
-#if PLATFORM(GTK)
-#include <WebCore/ErrorsGtk.h>
-#endif
-
-namespace WebKit {
-
-const char* WebSoupCustomProtocolRequestManager::supplementName()
-{
- return "WebSoupCustomProtocolRequestManager";
-}
-
-PassRefPtr<WebSoupCustomProtocolRequestManager> WebSoupCustomProtocolRequestManager::create(WebContext* context)
-{
- return adoptRef(new WebSoupCustomProtocolRequestManager(context));
-}
-
-WebSoupCustomProtocolRequestManager::WebSoupCustomProtocolRequestManager(WebContext* context)
- : WebContextSupplement(context)
-{
-}
-
-WebSoupCustomProtocolRequestManager::~WebSoupCustomProtocolRequestManager()
-{
-}
-
-void WebSoupCustomProtocolRequestManager::initializeClient(const WKSoupCustomProtocolRequestManagerClientBase* client)
-{
- m_client.initialize(client);
-}
-
-// WebContextSupplement
-void WebSoupCustomProtocolRequestManager::contextDestroyed()
-{
-}
-
-void WebSoupCustomProtocolRequestManager::processDidClose(WebProcessProxy*)
-{
-}
-
-void WebSoupCustomProtocolRequestManager::refWebContextSupplement()
-{
- API::Object::ref();
-}
-
-void WebSoupCustomProtocolRequestManager::derefWebContextSupplement()
-{
- API::Object::deref();
-}
-
-void WebSoupCustomProtocolRequestManager::registerSchemeForCustomProtocol(const String& scheme)
-{
- if (!context())
- return;
-
- context()->registerSchemeForCustomProtocol(scheme);
-
- ASSERT(!m_registeredSchemes.contains(scheme));
- m_registeredSchemes.append(scheme);
-}
-
-void WebSoupCustomProtocolRequestManager::unregisterSchemeForCustomProtocol(const String& scheme)
-{
- if (!context())
- return;
-
- context()->unregisterSchemeForCustomProtocol(scheme);
-
- ASSERT(m_registeredSchemes.contains(scheme));
- m_registeredSchemes.remove(m_registeredSchemes.find(scheme));
-}
-
-void WebSoupCustomProtocolRequestManager::startLoading(uint64_t customProtocolID, const WebCore::ResourceRequest& request)
-{
- if (!m_client.startLoading(this, customProtocolID, request))
- didFailWithError(customProtocolID, WebCore::cannotShowURLError(request));
-}
-
-void WebSoupCustomProtocolRequestManager::stopLoading(uint64_t customProtocolID)
-{
- m_client.stopLoading(this, customProtocolID);
-}
-
-void WebSoupCustomProtocolRequestManager::didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse& response)
-{
- if (!context())
- return;
-
- context()->networkingProcessConnection()->send(Messages::CustomProtocolManager::DidReceiveResponse(customProtocolID, response, 0), 0);
-}
-
-void WebSoupCustomProtocolRequestManager::didLoadData(uint64_t customProtocolID, const API::Data* data)
-{
- if (!context())
- return;
-
- context()->networkingProcessConnection()->send(Messages::CustomProtocolManager::DidLoadData(customProtocolID, data->dataReference()), 0);
-}
-
-void WebSoupCustomProtocolRequestManager::didFailWithError(uint64_t customProtocolID, const WebCore::ResourceError& error)
-{
- if (!context())
- return;
-
- context()->networkingProcessConnection()->send(Messages::CustomProtocolManager::DidFailWithError(customProtocolID, error), 0);
-}
-
-void WebSoupCustomProtocolRequestManager::didFinishLoading(uint64_t customProtocolID)
-{
- if (!context())
- return;
-
- context()->networkingProcessConnection()->send(Messages::CustomProtocolManager::DidFinishLoading(customProtocolID), 0);
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(CUSTOM_PROTOCOLS)
diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.h b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.h
deleted file mode 100644
index a140925d1..000000000
--- a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManager.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2013 Igalia S.L.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef WebSoupCustomProtocolRequestManager_h
-#define WebSoupCustomProtocolRequestManager_h
-
-#if ENABLE(CUSTOM_PROTOCOLS)
-
-#include "APIObject.h"
-#include "WebContextSupplement.h"
-#include "WebSoupCustomProtocolRequestManagerClient.h"
-#include <wtf/PassRefPtr.h>
-#include <wtf/RefPtr.h>
-#include <wtf/text/WTFString.h>
-
-namespace API {
-class Data;
-}
-
-namespace WebCore {
-class ResourceError;
-class ResourceRequest;
-class ResourceResponse;
-}
-
-namespace WebKit {
-
-class WebContext;
-
-class WebSoupCustomProtocolRequestManager : public API::ObjectImpl<API::Object::Type::SoupCustomProtocolRequestManager>, public WebContextSupplement {
-public:
- static const char* supplementName();
-
- static PassRefPtr<WebSoupCustomProtocolRequestManager> create(WebContext*);
- virtual ~WebSoupCustomProtocolRequestManager();
-
- void initializeClient(const WKSoupCustomProtocolRequestManagerClientBase*);
-
- void registerSchemeForCustomProtocol(const String& scheme);
- void unregisterSchemeForCustomProtocol(const String& scheme);
-
- void startLoading(uint64_t customProtocolID, const WebCore::ResourceRequest&);
- void stopLoading(uint64_t customProtocolID);
-
- void didReceiveResponse(uint64_t customProtocolID, const WebCore::ResourceResponse&);
- void didLoadData(uint64_t customProtocolID, const API::Data*);
- void didFailWithError(uint64_t customProtocolID, const WebCore::ResourceError&);
- void didFinishLoading(uint64_t customProtocolID);
-
- const Vector<String>& registeredSchemesForCustomProtocols() const { return m_registeredSchemes; }
-
- using API::Object::ref;
- using API::Object::deref;
-
-private:
- WebSoupCustomProtocolRequestManager(WebContext*);
-
- // WebContextSupplement
- virtual void contextDestroyed() override;
- virtual void processDidClose(WebProcessProxy*) override;
- virtual void refWebContextSupplement() override;
- virtual void derefWebContextSupplement() override;
-
- WebSoupCustomProtocolRequestManagerClient m_client;
- Vector<String> m_registeredSchemes;
-};
-
-} // namespace WebKit
-
-#endif // ENABLE(CUSTOM_PROTOCOLS)
-
-#endif // WebSoupCustomProtocolRequestManager_h
diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.cpp b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.cpp
deleted file mode 100644
index 80d43c5a3..000000000
--- a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2013 Igalia S.L.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#include "config.h"
-#include "WebSoupCustomProtocolRequestManagerClient.h"
-
-#if ENABLE(CUSTOM_PROTOCOLS)
-
-namespace WebKit {
-
-bool WebSoupCustomProtocolRequestManagerClient::startLoading(WebSoupCustomProtocolRequestManager* soupRequestManager, uint64_t customProtocolID, const WebCore::ResourceRequest& request)
-{
- if (!m_client.startLoading)
- return false;
-
- RefPtr<API::URLRequest> urlRequest = API::URLRequest::create(request);
- m_client.startLoading(toAPI(soupRequestManager), customProtocolID, toAPI(urlRequest.get()), m_client.base.clientInfo);
- return true;
-}
-
-void WebSoupCustomProtocolRequestManagerClient::stopLoading(WebSoupCustomProtocolRequestManager* soupRequestManager, uint64_t customProtocolID)
-{
- if (m_client.stopLoading)
- m_client.stopLoading(toAPI(soupRequestManager), customProtocolID, m_client.base.clientInfo);
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(CUSTOM_PROTOCOLS)
diff --git a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.h b/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.h
deleted file mode 100644
index e14332141..000000000
--- a/Source/WebKit2/UIProcess/Network/CustomProtocols/soup/WebSoupCustomProtocolRequestManagerClient.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2013 Igalia S.L.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * You should have received a copy of the GNU Library General Public License
- * along with this library; see the file COPYING.LIB. If not, write to
- * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-#ifndef WebSoupCustomProtocolRequestManagerClient_h
-#define WebSoupCustomProtocolRequestManagerClient_h
-
-#if ENABLE(CUSTOM_PROTOCOLS)
-
-#include "APIClient.h"
-#include "WKAPICast.h"
-#include "WKSoupCustomProtocolRequestManager.h"
-
-namespace API {
-
-template<> struct ClientTraits<WKSoupCustomProtocolRequestManagerClientBase> {
- typedef std::tuple<WKSoupCustomProtocolRequestManagerClientV0> Versions;
-};
-}
-
-namespace WebCore {
-class ResourceRequest;
-}
-
-namespace WebKit {
-
-class WebSoupCustomProtocolRequestManager;
-
-class WebSoupCustomProtocolRequestManagerClient : public API::Client<WKSoupCustomProtocolRequestManagerClientBase> {
-public:
- bool startLoading(WebSoupCustomProtocolRequestManager*, uint64_t customProtocolID, const WebCore::ResourceRequest&);
- void stopLoading(WebSoupCustomProtocolRequestManager*, uint64_t customProtocolID);
-};
-
-} // namespace WebKit
-
-#endif // ENABLE(CUSTOM_PROTOCOLS)
-
-#endif // WebSoupCustomProtocolRequestManagerClient_h
diff --git a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp
index e9b4e7964..8c0e96689 100644
--- a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp
+++ b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -26,114 +26,189 @@
#include "config.h"
#include "NetworkProcessProxy.h"
-#if ENABLE(NETWORK_PROCESS)
-
#include "AuthenticationChallengeProxy.h"
#include "CustomProtocolManagerProxyMessages.h"
+#include "DatabaseProcessMessages.h"
#include "DownloadProxyMessages.h"
+#include "Logging.h"
#include "NetworkProcessCreationParameters.h"
#include "NetworkProcessMessages.h"
-#include "WebContext.h"
+#include "SandboxExtension.h"
#include "WebProcessMessages.h"
-#include <wtf/RunLoop.h>
+#include "WebProcessPool.h"
+#include "WebsiteData.h"
#if ENABLE(SEC_ITEM_SHIM)
#include "SecItemShimProxy.h"
#endif
+#if PLATFORM(IOS)
+#include <wtf/spi/darwin/XPCSPI.h>
+#endif
+
#define MESSAGE_CHECK(assertion) MESSAGE_CHECK_BASE(assertion, connection())
using namespace WebCore;
namespace WebKit {
-PassRefPtr<NetworkProcessProxy> NetworkProcessProxy::create(WebContext& webContext)
+static uint64_t generateCallbackID()
+{
+ static uint64_t callbackID;
+
+ return ++callbackID;
+}
+
+Ref<NetworkProcessProxy> NetworkProcessProxy::create(WebProcessPool& processPool)
{
- return adoptRef(new NetworkProcessProxy(webContext));
+ return adoptRef(*new NetworkProcessProxy(processPool));
}
-NetworkProcessProxy::NetworkProcessProxy(WebContext& webContext)
- : m_webContext(webContext)
+NetworkProcessProxy::NetworkProcessProxy(WebProcessPool& processPool)
+ : ChildProcessProxy(processPool.alwaysRunsAtBackgroundPriority())
+ , m_processPool(processPool)
, m_numPendingConnectionRequests(0)
-#if ENABLE(CUSTOM_PROTOCOLS)
- , m_customProtocolManagerProxy(this, webContext)
-#endif
+ , m_customProtocolManagerProxy(this, processPool)
+ , m_throttler(*this)
{
connect();
}
NetworkProcessProxy::~NetworkProcessProxy()
{
+ ASSERT(m_pendingFetchWebsiteDataCallbacks.isEmpty());
+ ASSERT(m_pendingDeleteWebsiteDataCallbacks.isEmpty());
+ ASSERT(m_pendingDeleteWebsiteDataForOriginsCallbacks.isEmpty());
}
void NetworkProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions)
{
- launchOptions.processType = ProcessLauncher::NetworkProcess;
- platformGetLaunchOptions(launchOptions);
+ launchOptions.processType = ProcessLauncher::ProcessType::Network;
+ ChildProcessProxy::getLaunchOptions(launchOptions);
}
-void NetworkProcessProxy::connectionWillOpen(IPC::Connection* connection)
+void NetworkProcessProxy::connectionWillOpen(IPC::Connection& connection)
{
#if ENABLE(SEC_ITEM_SHIM)
- SecItemShimProxy::shared().initializeConnection(connection);
+ SecItemShimProxy::singleton().initializeConnection(connection);
+#else
+ UNUSED_PARAM(connection);
#endif
}
-void NetworkProcessProxy::connectionWillClose(IPC::Connection*)
+void NetworkProcessProxy::processWillShutDown(IPC::Connection& connection)
{
+ ASSERT_UNUSED(connection, this->connection() == &connection);
}
-void NetworkProcessProxy::getNetworkProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> reply)
+void NetworkProcessProxy::getNetworkProcessConnection(Ref<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply>&& reply)
{
- m_pendingConnectionReplies.append(reply);
+ m_pendingConnectionReplies.append(WTFMove(reply));
- if (isLaunching()) {
+ if (state() == State::Launching) {
m_numPendingConnectionRequests++;
return;
}
- connection()->send(Messages::NetworkProcess::CreateNetworkConnectionToWebProcess(), 0, IPC::DispatchMessageEvenWhenWaitingForSyncReply);
+ connection()->send(Messages::NetworkProcess::CreateNetworkConnectionToWebProcess(), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
}
-DownloadProxy* NetworkProcessProxy::createDownloadProxy()
+DownloadProxy* NetworkProcessProxy::createDownloadProxy(const ResourceRequest& resourceRequest)
{
if (!m_downloadProxyMap)
- m_downloadProxyMap = adoptPtr(new DownloadProxyMap(this));
+ m_downloadProxyMap = std::make_unique<DownloadProxyMap>(this);
+
+ return m_downloadProxyMap->createDownloadProxy(m_processPool, resourceRequest);
+}
+
+void NetworkProcessProxy::fetchWebsiteData(SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, OptionSet<WebsiteDataFetchOption> fetchOptions, std::function<void (WebsiteData)> completionHandler)
+{
+ ASSERT(canSendMessage());
- return m_downloadProxyMap->createDownloadProxy(m_webContext);
+ uint64_t callbackID = generateCallbackID();
+ auto token = throttler().backgroundActivityToken();
+ RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - NetworkProcessProxy is taking a background assertion because the Network process is fetching Website data", this);
+
+ m_pendingFetchWebsiteDataCallbacks.add(callbackID, [this, token, completionHandler, sessionID](WebsiteData websiteData) {
+ completionHandler(WTFMove(websiteData));
+ RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - NetworkProcessProxy is releasing a background assertion because the Network process is done fetching Website data", this);
+ });
+
+ send(Messages::NetworkProcess::FetchWebsiteData(sessionID, dataTypes, fetchOptions, callbackID), 0);
+}
+
+void NetworkProcessProxy::deleteWebsiteData(WebCore::SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, std::chrono::system_clock::time_point modifiedSince, std::function<void ()> completionHandler)
+{
+ auto callbackID = generateCallbackID();
+ auto token = throttler().backgroundActivityToken();
+ RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - NetworkProcessProxy is taking a background assertion because the Network process is deleting Website data", this);
+
+ m_pendingDeleteWebsiteDataCallbacks.add(callbackID, [this, token, completionHandler, sessionID] {
+ completionHandler();
+ RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - NetworkProcessProxy is releasing a background assertion because the Network process is done deleting Website data", this);
+ });
+ send(Messages::NetworkProcess::DeleteWebsiteData(sessionID, dataTypes, modifiedSince, callbackID), 0);
+}
+
+void NetworkProcessProxy::deleteWebsiteDataForOrigins(SessionID sessionID, OptionSet<WebsiteDataType> dataTypes, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, std::function<void()> completionHandler)
+{
+ ASSERT(canSendMessage());
+
+ uint64_t callbackID = generateCallbackID();
+ auto token = throttler().backgroundActivityToken();
+ RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - NetworkProcessProxy is taking a background assertion because the Network process is deleting Website data for several origins", this);
+
+ m_pendingDeleteWebsiteDataForOriginsCallbacks.add(callbackID, [this, token, completionHandler, sessionID] {
+ completionHandler();
+ RELEASE_LOG_IF(sessionID.isAlwaysOnLoggingAllowed(), ProcessSuspension, "%p - NetworkProcessProxy is releasing a background assertion because the Network process is done deleting Website data for several origins", this);
+ });
+
+ send(Messages::NetworkProcess::DeleteWebsiteDataForOrigins(sessionID, dataTypes, origins, cookieHostNames, callbackID), 0);
}
void NetworkProcessProxy::networkProcessCrashedOrFailedToLaunch()
{
// The network process must have crashed or exited, send any pending sync replies we might have.
while (!m_pendingConnectionReplies.isEmpty()) {
- RefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst();
+ Ref<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst();
-#if PLATFORM(MAC)
- reply->send(IPC::Attachment(0, MACH_MSG_TYPE_MOVE_SEND));
-#elif USE(UNIX_DOMAIN_SOCKETS)
+#if USE(UNIX_DOMAIN_SOCKETS)
reply->send(IPC::Attachment());
+#elif OS(DARWIN)
+ reply->send(IPC::Attachment(0, MACH_MSG_TYPE_MOVE_SEND));
#else
notImplemented();
#endif
}
+ for (const auto& callback : m_pendingFetchWebsiteDataCallbacks.values())
+ callback(WebsiteData());
+ m_pendingFetchWebsiteDataCallbacks.clear();
+
+ for (const auto& callback : m_pendingDeleteWebsiteDataCallbacks.values())
+ callback();
+ m_pendingDeleteWebsiteDataCallbacks.clear();
+
+ for (const auto& callback : m_pendingDeleteWebsiteDataForOriginsCallbacks.values())
+ callback();
+ m_pendingDeleteWebsiteDataForOriginsCallbacks.clear();
+
// Tell the network process manager to forget about this network process proxy. This may cause us to be deleted.
- m_webContext.networkProcessCrashed(this);
+ m_processPool.networkProcessCrashed(this);
}
-void NetworkProcessProxy::didReceiveMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder)
+void NetworkProcessProxy::didReceiveMessage(IPC::Connection& connection, IPC::Decoder& decoder)
{
if (dispatchMessage(connection, decoder))
return;
- if (m_webContext.dispatchMessage(connection, decoder))
+ if (m_processPool.dispatchMessage(connection, decoder))
return;
didReceiveNetworkProcessProxyMessage(connection, decoder);
}
-void NetworkProcessProxy::didReceiveSyncMessage(IPC::Connection* connection, IPC::MessageDecoder& decoder, std::unique_ptr<IPC::MessageEncoder>& replyEncoder)
+void NetworkProcessProxy::didReceiveSyncMessage(IPC::Connection& connection, IPC::Decoder& decoder, std::unique_ptr<IPC::Encoder>& replyEncoder)
{
if (dispatchSyncMessage(connection, decoder, replyEncoder))
return;
@@ -141,16 +216,19 @@ void NetworkProcessProxy::didReceiveSyncMessage(IPC::Connection* connection, IPC
ASSERT_NOT_REACHED();
}
-void NetworkProcessProxy::didClose(IPC::Connection*)
+void NetworkProcessProxy::didClose(IPC::Connection&)
{
if (m_downloadProxyMap)
m_downloadProxyMap->processDidClose();
+ m_customProtocolManagerProxy.processDidClose();
+
+ m_tokenForHoldingLockedFiles = nullptr;
// This may cause us to be deleted.
networkProcessCrashedOrFailedToLaunch();
}
-void NetworkProcessProxy::didReceiveInvalidMessage(IPC::Connection*, IPC::StringReference, IPC::StringReference)
+void NetworkProcessProxy::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference, IPC::StringReference)
{
}
@@ -161,10 +239,10 @@ void NetworkProcessProxy::didCreateNetworkConnectionToWebProcess(const IPC::Atta
// Grab the first pending connection reply.
RefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply> reply = m_pendingConnectionReplies.takeFirst();
-#if PLATFORM(MAC)
- reply->send(IPC::Attachment(connectionIdentifier.port(), MACH_MSG_TYPE_MOVE_SEND));
-#elif USE(UNIX_DOMAIN_SOCKETS)
+#if USE(UNIX_DOMAIN_SOCKETS)
reply->send(connectionIdentifier);
+#elif OS(DARWIN)
+ reply->send(IPC::Attachment(connectionIdentifier.port(), MACH_MSG_TYPE_MOVE_SEND));
#else
notImplemented();
#endif
@@ -175,8 +253,43 @@ void NetworkProcessProxy::didReceiveAuthenticationChallenge(uint64_t pageID, uin
WebPageProxy* page = WebProcessProxy::webPage(pageID);
MESSAGE_CHECK(page);
- RefPtr<AuthenticationChallengeProxy> authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, connection());
- page->didReceiveAuthenticationChallengeProxy(frameID, authenticationChallenge.release());
+ auto authenticationChallenge = AuthenticationChallengeProxy::create(coreChallenge, challengeID, connection());
+ page->didReceiveAuthenticationChallengeProxy(frameID, WTFMove(authenticationChallenge));
+}
+
+void NetworkProcessProxy::didFetchWebsiteData(uint64_t callbackID, const WebsiteData& websiteData)
+{
+ auto callback = m_pendingFetchWebsiteDataCallbacks.take(callbackID);
+ callback(websiteData);
+}
+
+void NetworkProcessProxy::didDeleteWebsiteData(uint64_t callbackID)
+{
+ auto callback = m_pendingDeleteWebsiteDataCallbacks.take(callbackID);
+ callback();
+}
+
+void NetworkProcessProxy::didDeleteWebsiteDataForOrigins(uint64_t callbackID)
+{
+ auto callback = m_pendingDeleteWebsiteDataForOriginsCallbacks.take(callbackID);
+ callback();
+}
+
+void NetworkProcessProxy::grantSandboxExtensionsToDatabaseProcessForBlobs(uint64_t requestID, const Vector<String>& paths)
+{
+#if ENABLE(DATABASE_PROCESS)
+#if ENABLE(SANDBOX_EXTENSIONS)
+ SandboxExtension::HandleArray extensions;
+ extensions.allocate(paths.size());
+ for (size_t i = 0; i < paths.size(); ++i) {
+ // ReadWrite is required for creating hard links as well as deleting the temporary file, which the DatabaseProcess will do.
+ SandboxExtension::createHandle(paths[i], SandboxExtension::ReadWrite, extensions[i]);
+ }
+
+ m_processPool.sendToDatabaseProcessRelaunchingIfNecessary(Messages::DatabaseProcess::GrantSandboxExtensionsForBlobs(paths, extensions));
+#endif
+ connection()->send(Messages::NetworkProcess::DidGrantSandboxExtensionsToDatabaseProcessForBlobs(requestID), 0);
+#endif
}
void NetworkProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Connection::Identifier connectionIdentifier)
@@ -184,7 +297,7 @@ void NetworkProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Con
ChildProcessProxy::didFinishLaunching(launcher, connectionIdentifier);
if (IPC::Connection::identifierIsNull(connectionIdentifier)) {
- // FIXME: Do better cleanup here.
+ networkProcessCrashedOrFailedToLaunch();
return;
}
@@ -193,12 +306,108 @@ void NetworkProcessProxy::didFinishLaunching(ProcessLauncher* launcher, IPC::Con
m_numPendingConnectionRequests = 0;
-#if PLATFORM(MAC)
- if (m_webContext.processSuppressionEnabled())
+#if PLATFORM(COCOA)
+ if (m_processPool.processSuppressionEnabled())
setProcessSuppressionEnabled(true);
#endif
+
+#if PLATFORM(IOS)
+ if (xpc_connection_t connection = this->connection()->xpcConnection())
+ m_throttler.didConnectToProcess(xpc_connection_get_pid(connection));
+#endif
}
-} // namespace WebKit
+void NetworkProcessProxy::logDiagnosticMessage(uint64_t pageID, const String& message, const String& description, WebCore::ShouldSample shouldSample)
+{
+ WebPageProxy* page = WebProcessProxy::webPage(pageID);
+ // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this,
+ // but for now we simply drop the message in the rare case this happens.
+ if (!page)
+ return;
+
+ page->logDiagnosticMessage(message, description, shouldSample);
+}
+
+void NetworkProcessProxy::logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result, WebCore::ShouldSample shouldSample)
+{
+ WebPageProxy* page = WebProcessProxy::webPage(pageID);
+ // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this,
+ // but for now we simply drop the message in the rare case this happens.
+ if (!page)
+ return;
+
+ page->logDiagnosticMessageWithResult(message, description, result, shouldSample);
+}
+
+void NetworkProcessProxy::logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample shouldSample)
+{
+ WebPageProxy* page = WebProcessProxy::webPage(pageID);
+ // FIXME: We do this null-check because by the time the decision to log is made, the page may be gone. We should refactor to avoid this,
+ // but for now we simply drop the message in the rare case this happens.
+ if (!page)
+ return;
+
+ page->logDiagnosticMessageWithValue(message, description, value, significantFigures, shouldSample);
+}
-#endif // ENABLE(NETWORK_PROCESS)
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+void NetworkProcessProxy::canAuthenticateAgainstProtectionSpace(uint64_t loaderID, uint64_t pageID, uint64_t frameID, const WebCore::ProtectionSpace& protectionSpace)
+{
+ WebPageProxy* page = WebProcessProxy::webPage(pageID);
+ if (!page)
+ return;
+
+ page->canAuthenticateAgainstProtectionSpace(loaderID, frameID, protectionSpace);
+}
+#endif
+
+void NetworkProcessProxy::sendProcessWillSuspendImminently()
+{
+ if (!canSendMessage())
+ return;
+
+ bool handled = false;
+ sendSync(Messages::NetworkProcess::ProcessWillSuspendImminently(), Messages::NetworkProcess::ProcessWillSuspendImminently::Reply(handled), 0, 1_s);
+}
+
+void NetworkProcessProxy::sendPrepareToSuspend()
+{
+ if (canSendMessage())
+ send(Messages::NetworkProcess::PrepareToSuspend(), 0);
+}
+
+void NetworkProcessProxy::sendCancelPrepareToSuspend()
+{
+ if (canSendMessage())
+ send(Messages::NetworkProcess::CancelPrepareToSuspend(), 0);
+}
+
+void NetworkProcessProxy::sendProcessDidResume()
+{
+ if (canSendMessage())
+ send(Messages::NetworkProcess::ProcessDidResume(), 0);
+}
+
+void NetworkProcessProxy::processReadyToSuspend()
+{
+ m_throttler.processReadyToSuspend();
+}
+
+void NetworkProcessProxy::didSetAssertionState(AssertionState)
+{
+}
+
+void NetworkProcessProxy::setIsHoldingLockedFiles(bool isHoldingLockedFiles)
+{
+ if (!isHoldingLockedFiles) {
+ RELEASE_LOG(ProcessSuspension, "UIProcess is releasing a background assertion because the Network process is no longer holding locked files");
+ m_tokenForHoldingLockedFiles = nullptr;
+ return;
+ }
+ if (!m_tokenForHoldingLockedFiles) {
+ RELEASE_LOG(ProcessSuspension, "UIProcess is taking a background assertion because the Network process is holding locked files");
+ m_tokenForHoldingLockedFiles = m_throttler.backgroundActivityToken();
+ }
+}
+
+} // namespace WebKit
diff --git a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h
index ad13c702c..772840825 100644
--- a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h
+++ b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.h
@@ -26,80 +26,114 @@
#ifndef NetworkProcessProxy_h
#define NetworkProcessProxy_h
-#if ENABLE(NETWORK_PROCESS)
-
#include "ChildProcessProxy.h"
+#include "CustomProtocolManagerProxy.h"
#include "ProcessLauncher.h"
+#include "ProcessThrottler.h"
+#include "ProcessThrottlerClient.h"
#include "WebProcessProxyMessages.h"
+#include <memory>
#include <wtf/Deque.h>
-#if ENABLE(CUSTOM_PROTOCOLS)
-#include "CustomProtocolManagerProxy.h"
-#endif
-
namespace WebCore {
class AuthenticationChallenge;
+class ProtectionSpace;
+class ResourceRequest;
+enum class ShouldSample;
+class SecurityOrigin;
+struct SecurityOriginData;
+class SessionID;
}
namespace WebKit {
class DownloadProxy;
class DownloadProxyMap;
-class WebContext;
+class WebProcessPool;
+enum class WebsiteDataFetchOption;
+enum class WebsiteDataType;
struct NetworkProcessCreationParameters;
+struct WebsiteData;
-class NetworkProcessProxy : public ChildProcessProxy {
+class NetworkProcessProxy : public ChildProcessProxy, private ProcessThrottlerClient {
public:
- static PassRefPtr<NetworkProcessProxy> create(WebContext&);
+ static Ref<NetworkProcessProxy> create(WebProcessPool&);
~NetworkProcessProxy();
- void getNetworkProcessConnection(PassRefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply>);
+ void getNetworkProcessConnection(Ref<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply>&&);
+
+ DownloadProxy* createDownloadProxy(const WebCore::ResourceRequest&);
- DownloadProxy* createDownloadProxy();
+ void fetchWebsiteData(WebCore::SessionID, OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, std::function<void(WebsiteData)> completionHandler);
+ void deleteWebsiteData(WebCore::SessionID, OptionSet<WebsiteDataType>, std::chrono::system_clock::time_point modifiedSince, std::function<void()> completionHandler);
+ void deleteWebsiteDataForOrigins(WebCore::SessionID, OptionSet<WebKit::WebsiteDataType>, const Vector<WebCore::SecurityOriginData>& origins, const Vector<String>& cookieHostNames, std::function<void()> completionHandler);
-#if PLATFORM(MAC)
+#if PLATFORM(COCOA)
void setProcessSuppressionEnabled(bool);
#endif
+ void processReadyToSuspend();
+
+ void setIsHoldingLockedFiles(bool);
+
+ ProcessThrottler& throttler() { return m_throttler; }
+
private:
- NetworkProcessProxy(WebContext&);
+ NetworkProcessProxy(WebProcessPool&);
// ChildProcessProxy
- virtual void getLaunchOptions(ProcessLauncher::LaunchOptions&) override;
- virtual void connectionWillOpen(IPC::Connection*) override;
- virtual void connectionWillClose(IPC::Connection*) override;
+ void getLaunchOptions(ProcessLauncher::LaunchOptions&) override;
+ void connectionWillOpen(IPC::Connection&) override;
+ void processWillShutDown(IPC::Connection&) override;
- void platformGetLaunchOptions(ProcessLauncher::LaunchOptions&);
void networkProcessCrashedOrFailedToLaunch();
+ // ProcessThrottlerClient
+ void sendProcessWillSuspendImminently() override;
+ void sendPrepareToSuspend() override;
+ void sendCancelPrepareToSuspend() override;
+ void sendProcessDidResume() override;
+ void didSetAssertionState(AssertionState) override;
+
// IPC::Connection::Client
- virtual void didReceiveMessage(IPC::Connection*, IPC::MessageDecoder&) override;
- virtual void didReceiveSyncMessage(IPC::Connection*, IPC::MessageDecoder&, std::unique_ptr<IPC::MessageEncoder>&) override;
- virtual void didClose(IPC::Connection*) override;
- virtual void didReceiveInvalidMessage(IPC::Connection*, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
+ void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
+ void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) override;
+ void didClose(IPC::Connection&) override;
+ void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) override;
// Message handlers
- void didReceiveNetworkProcessProxyMessage(IPC::Connection*, IPC::MessageDecoder&);
+ void didReceiveNetworkProcessProxyMessage(IPC::Connection&, IPC::Decoder&);
void didCreateNetworkConnectionToWebProcess(const IPC::Attachment&);
void didReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, const WebCore::AuthenticationChallenge&, uint64_t challengeID);
+ void didFetchWebsiteData(uint64_t callbackID, const WebsiteData&);
+ void didDeleteWebsiteData(uint64_t callbackID);
+ void didDeleteWebsiteDataForOrigins(uint64_t callbackID);
+ void grantSandboxExtensionsToDatabaseProcessForBlobs(uint64_t requestID, const Vector<String>& paths);
+ void logDiagnosticMessage(uint64_t pageID, const String& message, const String& description, WebCore::ShouldSample);
+ void logDiagnosticMessageWithResult(uint64_t pageID, const String& message, const String& description, uint32_t result, WebCore::ShouldSample);
+ void logDiagnosticMessageWithValue(uint64_t pageID, const String& message, const String& description, double value, unsigned significantFigures, WebCore::ShouldSample);
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+ void canAuthenticateAgainstProtectionSpace(uint64_t loaderID, uint64_t pageID, uint64_t frameID, const WebCore::ProtectionSpace&);
+#endif
// ProcessLauncher::Client
- virtual void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier);
+ void didFinishLaunching(ProcessLauncher*, IPC::Connection::Identifier) override;
- WebContext& m_webContext;
+ WebProcessPool& m_processPool;
unsigned m_numPendingConnectionRequests;
- Deque<RefPtr<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply>> m_pendingConnectionReplies;
+ Deque<Ref<Messages::WebProcessProxy::GetNetworkProcessConnection::DelayedReply>> m_pendingConnectionReplies;
- OwnPtr<DownloadProxyMap> m_downloadProxyMap;
+ HashMap<uint64_t, std::function<void (WebsiteData)>> m_pendingFetchWebsiteDataCallbacks;
+ HashMap<uint64_t, std::function<void ()>> m_pendingDeleteWebsiteDataCallbacks;
+ HashMap<uint64_t, std::function<void ()>> m_pendingDeleteWebsiteDataForOriginsCallbacks;
-#if ENABLE(CUSTOM_PROTOCOLS)
+ std::unique_ptr<DownloadProxyMap> m_downloadProxyMap;
CustomProtocolManagerProxy m_customProtocolManagerProxy;
-#endif
+ ProcessThrottler m_throttler;
+ ProcessThrottler::BackgroundActivityToken m_tokenForHoldingLockedFiles;
};
} // namespace WebKit
-#endif // ENABLE(NETWORK_PROCESS)
-
#endif // NetworkProcessProxy_h
diff --git a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in
index 3b41a540a..0c902ed7a 100644
--- a/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in
+++ b/Source/WebKit2/UIProcess/Network/NetworkProcessProxy.messages.in
@@ -20,12 +20,26 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-#if ENABLE(NETWORK_PROCESS)
-
messages -> NetworkProcessProxy LegacyReceiver {
DidCreateNetworkConnectionToWebProcess(IPC::Attachment connectionIdentifier)
DidReceiveAuthenticationChallenge(uint64_t pageID, uint64_t frameID, WebCore::AuthenticationChallenge challenge, uint64_t challengeID)
-}
-#endif // ENABLE(NETWORK_PROCESS)
+ DidFetchWebsiteData(uint64_t callbackID, struct WebKit::WebsiteData websiteData)
+ DidDeleteWebsiteData(uint64_t callbackID)
+ DidDeleteWebsiteDataForOrigins(uint64_t callbackID)
+
+ GrantSandboxExtensionsToDatabaseProcessForBlobs(uint64_t requestID, Vector<String> paths)
+
+ ProcessReadyToSuspend()
+ SetIsHoldingLockedFiles(bool isHoldingLockedFiles)
+
+ # Diagnostic messages logging
+ LogDiagnosticMessage(uint64_t pageID, String message, String description, enum WebCore::ShouldSample shouldSample)
+ LogDiagnosticMessageWithResult(uint64_t pageID, String message, String description, uint32_t result, enum WebCore::ShouldSample shouldSample)
+ LogDiagnosticMessageWithValue(uint64_t pageID, String message, String description, double value, unsigned significantFigures, enum WebCore::ShouldSample shouldSample)
+
+#if USE(PROTECTION_SPACE_AUTH_CALLBACK)
+ CanAuthenticateAgainstProtectionSpace(uint64_t loaderID, uint64_t pageID, uint64_t frameID, WebCore::ProtectionSpace protectionSpace)
+#endif
+}
diff --git a/Source/WebKit2/UIProcess/Network/soup/NetworkProcessProxySoup.cpp b/Source/WebKit2/UIProcess/Network/soup/NetworkProcessProxySoup.cpp
deleted file mode 100644
index 1bdf0ed7c..000000000
--- a/Source/WebKit2/UIProcess/Network/soup/NetworkProcessProxySoup.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2012 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#if ENABLE(NETWORK_PROCESS)
-
-#include "NetworkProcessProxy.h"
-#include <glib.h>
-
-namespace WebKit {
-
-void NetworkProcessProxy::platformGetLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions)
-{
-#ifndef NDEBUG
- const char* networkProcessCmdPrefix = g_getenv("NETWORK_PROCESS_CMD_PREFIX");
- if (networkProcessCmdPrefix && *networkProcessCmdPrefix)
- launchOptions.processCmdPrefix = String::fromUTF8(networkProcessCmdPrefix);
-#else
- UNUSED_PARAM(launchOptions);
-#endif
-}
-
-}
-
-#endif // ENABLE(NETWORK_PROCESS)