Skip to content
Permalink
Browse files

IPC for haiku

- Added a message handler to look out for incoming messages to runloop
- Created new aux support so we can attach all handlers to the main apps looper
- Added a message stashing feature so it stashes the messages and interprets them when the loop is ready to run
- used maps to store loopers and BApplications to forward message to appropriate loopers
- Created a message from ui process to network process that notifies the pid of webprocess
- Added NetworkSession so it doesnt crash
  • Loading branch information...
RAJAGOPALAN-GANGADHARAN authored and pulkomandy committed May 12, 2019
1 parent 4f59c54 commit 641dd71b0f55295d3c8047f22fc8659422a74536
Showing with 961 additions and 102 deletions.
  1. +1 −1 Source/WTF/wtf/Platform.h
  2. +1 −0 Source/WTF/wtf/PlatformHaiku.cmake
  3. +6 −0 Source/WTF/wtf/RunLoop.h
  4. +22 −0 Source/WebCore/platform/network/haiku/ResourceRequest.h
  5. +23 −0 Source/WebCore/platform/network/haiku/ResourceResponse.h
  6. +3 −1 Source/WebKit/NetworkProcess/NetworkProcess.cpp
  7. +3 −0 Source/WebKit/NetworkProcess/NetworkProcess.h
  8. +3 −0 Source/WebKit/NetworkProcess/NetworkProcess.messages.in
  9. +7 −0 Source/WebKit/NetworkProcess/NetworkSession.cpp
  10. +25 −0 Source/WebKit/NetworkProcess/haiku/NetworkProcessHaiku.cpp
  11. +17 −3 Source/WebKit/NetworkProcess/haiku/NetworkProcessMainHaiku.cpp
  12. +50 −0 Source/WebKit/NetworkProcess/haiku/NetworkSessionHaiku.cpp
  13. +47 −0 Source/WebKit/NetworkProcess/haiku/NetworkSessionHaiku.h
  14. +3 −2 Source/WebKit/Platform/IPC/Attachment.cpp
  15. +16 −0 Source/WebKit/Platform/IPC/Attachment.h
  16. +4 −3 Source/WebKit/Platform/IPC/Connection.cpp
  17. +31 −5 Source/WebKit/Platform/IPC/Connection.h
  18. +2 −2 Source/WebKit/Platform/IPC/Decoder.cpp
  19. +1 −1 Source/WebKit/Platform/IPC/Encoder.cpp
  20. +58 −0 Source/WebKit/Platform/IPC/haiku/AttachmentHaiku.cpp
  21. +168 −0 Source/WebKit/Platform/IPC/haiku/ConnectionHaiku.cpp
  22. +11 −0 Source/WebKit/Platform/SharedMemory.h
  23. +116 −0 Source/WebKit/Platform/haiku/SharedMemoryHaiku.cpp
  24. +6 −6 Source/WebKit/PlatformHaiku.cmake
  25. +1 −1 Source/WebKit/Shared/AuxiliaryProcess.cpp
  26. +10 −3 Source/WebKit/Shared/haiku/AuxiliaryProcessMainHaiku.cpp
  27. +159 −0 Source/WebKit/Shared/haiku/AuxiliaryProcessMainHaiku.h
  28. +8 −5 Source/WebKit/Shared/haiku/ProcessExecutablePathHaiku.cpp
  29. +2 −1 Source/WebKit/Shared/haiku/ShareableBitmapHaiku.cpp
  30. +6 −7 Source/WebKit/Shared/haiku/WebCoreArgumentCodersHaiku.cpp
  31. +2 −2 Source/WebKit/Shared/unix/AuxiliaryProcessMain.cpp
  32. +2 −0 Source/WebKit/Shared/unix/AuxiliaryProcessMain.h
  33. +0 −1 Source/WebKit/UIProcess/AuxiliaryProcessProxy.h
  34. +18 −12 Source/WebKit/UIProcess/Launcher/haiku/ProcessLauncherHaiku.cpp
  35. +16 −4 Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
  36. +0 −4 Source/WebKit/UIProcess/WebPageProxy.cpp
  37. +1 −1 Source/WebKit/UIProcess/WebProcessProxy.cpp
  38. +1 −1 Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp
  39. +2 −0 Source/WebKit/WebProcess/WebPage/WebInspector.cpp
  40. +4 −1 Source/WebKit/WebProcess/WebPage/WebInspectorUI.cpp
  41. +2 −2 Source/WebKit/WebProcess/WebPage/WebPage.cpp
  42. +15 −5 Source/WebKit/WebProcess/WebProcess.cpp
  43. +15 −15 Source/WebKit/WebProcess/haiku/WebProcessMainHaiku.cpp
  44. +61 −9 Tools/MiniBrowser/haiku/App.cpp
  45. +12 −4 Tools/MiniBrowser/haiku/App.h
@@ -1189,7 +1189,7 @@
#define USE_EXPORT_MACROS 1
#endif

#if PLATFORM(GTK) || PLATFORM(WPE) || PLATFORM(HAIKU)
#if PLATFORM(GTK) || PLATFORM(WPE)
#define USE_UNIX_DOMAIN_SOCKETS 1
#endif

@@ -1,5 +1,6 @@
LIST(APPEND WTF_SOURCES
generic/WorkQueueGeneric.cpp
#haiku/WorkQueueHaiku.cpp
haiku/RunLoopHaiku.cpp
generic/MainThreadGeneric.cpp
haiku/CurrentProcessMemoryStatus.cpp
@@ -41,8 +41,10 @@
#endif

#if USE(HAIKU_EVENT_LOOP)
#include <Handler.h>
class BHandler;
class BMessageRunner;
class BLooper;
#endif

namespace WTF {
@@ -73,6 +75,10 @@ class RunLoop : public FunctionDispatcher {
WTF_EXPORT_PRIVATE GMainContext* mainContext() const { return m_mainContext.get(); }
#endif

#if USE(HAIKU_EVENT_LOOP)
WTF_EXPORT_PRIVATE BLooper* runLoopLooper() const { return m_handler->Looper(); }
#endif

#if USE(GENERIC_EVENT_LOOP) || USE(HAIKU_EVENT_LOOP) || USE(WINDOWS_EVENT_LOOP)
// Run the single iteration of the RunLoop. It consumes the pending tasks and expired timers, but it won't be blocked.
WTF_EXPORT_PRIVATE static void iterate();
@@ -1,6 +1,7 @@
/*
* Copyright (C) 2003, 2006 Apple Computer, Inc. All rights reserved.
* Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
* Copyright (C) 2019 Haiku, Inc. All rights reserved
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -64,6 +65,9 @@ namespace WebCore {

void setCredentials(const char* username, const char* password);
void updateFromDelegatePreservingOldProperties(const ResourceRequest& delegateProvidedRequest) { *this = delegateProvidedRequest; }

template<class Encoder> void encodePlatformData(Encoder&) const;
template<class Decoder> bool decodePlatformData(Decoder&);

private:
friend class ResourceRequestBase;
@@ -78,6 +82,24 @@ namespace WebCore {
BString fUsername;
BString fPassword;
};

template<class Encoder>
void ResourceRequest::encodePlatformData(Encoder& encoder) const
{
encodeBase(encoder);
}

template<class Decoder>
bool ResourceRequest::decodePlatformData(Decoder& decoder)
{
if(!decodeBase(decoder))
{
return false;
}

return true;
}

} // namespace WebCore

#endif // ResourceRequest_h
@@ -43,6 +43,9 @@ class ResourceResponse : public ResourceResponseBase {
}

void setSuggestedFilename(String name) { m_resourceName = name;}

template<class Encoder> void encodePlatformData(Encoder&) const;
template<class Decoder> bool decodePlatformData(Decoder&);

private:
friend class ResourceResponseBase;
@@ -52,6 +55,26 @@ class ResourceResponse : public ResourceResponseBase {
String m_resourceName;
};

template<class Encoder>
void ResourceResponse::encodePlatformData(Encoder& encoder) const
{
fprintf(stderr,"%s \n",__PRETTY_FUNCTION__);
encodeBase(encoder);
}

template<class Decoder>
bool ResourceResponse::decodePlatformData(Decoder& decoder)
{
fprintf(stderr,"%s \n",__PRETTY_FUNCTION__);
if(!decodeBase(decoder))
{
fprintf(stderr,"%s -- failed\n",__PRETTY_FUNCTION__);
return false;
}

return true;
}

} // namespace WebCore

#endif // ResourceResponse_h
@@ -363,7 +363,7 @@ void NetworkProcess::initializeNetworkProcess(NetworkProcessCreationParameters&&
registerURLSchemeAsCanDisplayOnlyIfCanRequest(scheme);

m_downloadMonitorSpeedMultiplier = parameters.downloadMonitorSpeedMultiplier;

fprintf(stderr,"%p - NetworkProcess::initializeNetworkProcess: Presenting process = %d\n", this, WebCore::presentingApplicationPID());
RELEASE_LOG(Process, "%p - NetworkProcess::initializeNetworkProcess: Presenting process = %d", this, WebCore::presentingApplicationPID());
}

@@ -420,6 +420,8 @@ void NetworkProcess::createNetworkConnectionToWebProcess(bool isServiceWorkerPro

IPC::Attachment clientSocket(clientIdentifier);
parentProcessConnection()->send(Messages::NetworkProcessProxy::DidCreateNetworkConnectionToWebProcess(clientSocket), 0);
#elif PLATFORM(HAIKU)
//do nothing
#else
notImplemented();
#endif
@@ -386,6 +386,9 @@ class NetworkProcess : public AuxiliaryProcess, private DownloadManager::Client,
// Message Handlers
void didReceiveSyncNetworkProcessMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&);
void initializeNetworkProcess(NetworkProcessCreationParameters&&);
#if PLATFORM(HAIKU)
void createNetworkConnectionToWebProcessHaiku(bool isServiceWorkerProcess, WebCore::RegistrableDomain&&,int64_t webPID);
#endif
void createNetworkConnectionToWebProcess(bool isServiceWorkerProcess, WebCore::RegistrableDomain&&);

void fetchWebsiteData(PAL::SessionID, OptionSet<WebsiteDataType>, OptionSet<WebsiteDataFetchOption>, uint64_t callbackID);
@@ -27,6 +27,9 @@ messages -> NetworkProcess LegacyReceiver {
# Creates a connection for communication with a WebProcess
CreateNetworkConnectionToWebProcess(bool isServiceWorkerProcess, WebCore::RegistrableDomain registrableDomain)

#if PLATFORM(HAIKU)
CreateNetworkConnectionToWebProcessHaiku(bool isServiceWorkerProcess, WebCore::RegistrableDomain registrableDomain,int64_t webPID)
#endif
#if USE(SOUP)
SetIgnoreTLSErrors(bool ignoreTLSErrors)
UserPreferredLanguagesChanged(Vector<String> languages)
@@ -50,6 +50,10 @@
#include "NetworkSessionCurl.h"
#endif

#if PLATFORM(HAIKU)
#include "NetworkSessionHaiku.h"
#endif

namespace WebKit {
using namespace WebCore;

@@ -64,6 +68,9 @@ Ref<NetworkSession> NetworkSession::create(NetworkProcess& networkProcess, Netwo
#if USE(CURL)
return NetworkSessionCurl::create(networkProcess, WTFMove(parameters));
#endif
#if PLATFORM(HAIKU)
return NetworkSessionHaiku::create(networkProcess, WTFMove(parameters));
#endif
}

NetworkStorageSession& NetworkSession::networkStorageSession() const
@@ -30,6 +30,11 @@
#include <WebCore/NetworkStorageSession.h>
#include <WebCore/NotImplemented.h>

#include "NetworkConnectionToWebProcess.h"
#include "NetworkProcessProxyMessages.h"
#include <OS.h>
#include <String.h>
#include <wtf/RandomNumber.h>
namespace WebCore
{
class NetworkStorageSession;
@@ -90,4 +95,24 @@ void NetworkProcess::clearDiskCache(WallTime modifiedSince, CompletionHandler<vo
notImplemented();
}

void NetworkProcess::createNetworkConnectionToWebProcessHaiku(bool isServiceWorkerProcess, WebCore::RegistrableDomain&& registrableDomain,int64_t webPID)
{
team_id webID = (team_id)webPID;
fprintf(stderr,"\n %s %ld",__PRETTY_FUNCTION__,webID);
//FIXME:should avoid collision
uint32_t connectionRandkey = WTF::weakRandomUint32();
BString key;
key.SetToFormat("%u",connectionRandkey);

/* Network Process creates random key for workqueue identification and shares its pid and key to webprocess
So a connection can be established*/
auto connection = NetworkConnectionToWebProcess::create(*this,{webID,key});
m_webProcessConnections.append(WTFMove(connection));

IPC::Attachment clientConnector(getpid(),connectionRandkey);
parentProcessConnection()->send(Messages::NetworkProcessProxy::DidCreateNetworkConnectionToWebProcess(clientConnector), 0);
createNetworkConnectionToWebProcess(isServiceWorkerProcess,std::move(registrableDomain));
}


} // namespace WebKit
@@ -26,11 +26,25 @@
#include "config.h"
#include "NetworkProcessMainUnix.h"

#include "AuxiliaryProcessMain.h"
#include "AuxiliaryProcessMainHaiku.h"
#include "NetworkProcess.h"
#include <Application.h>

namespace WebKit {

class NetworkProcessMainBase: public AuxiliaryProcessMainBase
{
public:
ProcessApp* app = nullptr;
bool platformInitialize(char* sign) override
{
app = new ProcessApp(sign);
return true;
}
void runApp()
{
app->Run();
}
};
template<>
void initializeAuxiliaryProcess<NetworkProcess>(AuxiliaryProcessInitializationParameters&& parameters)
{
@@ -39,7 +53,7 @@ void initializeAuxiliaryProcess<NetworkProcess>(AuxiliaryProcessInitializationPa

int NetworkProcessMainUnix(int argc, char** argv)
{
return AuxiliaryProcessMain<NetworkProcess, AuxiliaryProcessMainBase>(argc, argv);
return AuxiliaryProcessMain<NetworkProcess,NetworkProcessMainBase>(argc, argv);
}

} // namespace WebKit
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2018 Sony Interactive Entertainment Inc.
* Copyright (C) 2019 Haiku, Inc.
*
* 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"
#include "NetworkSessionHaiku.h"

#include "NetworkProcess.h"
#include "NetworkSessionCreationParameters.h"
#include "WebCookieManager.h"
#include "NotImplemented.h"

namespace WebKit {

using namespace WebCore;

NetworkSessionHaiku::NetworkSessionHaiku(NetworkProcess& networkProcess, NetworkSessionCreationParameters&& parameters)
: NetworkSession(networkProcess, parameters.sessionID)
{
notImplemented();
}

NetworkSessionHaiku::~NetworkSessionHaiku()
{

}

} // namespace WebKit
@@ -0,0 +1,47 @@
/*
* Copyright (C) 2018 Sony Interactive Entertainment Inc.
* Copyright (C) 2019 Haiku, Inc.
*
* 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.
*/

#pragma once

#include "NetworkSession.h"

namespace WebKit {

struct NetworkSessionCreationParameters;

class NetworkSessionHaiku final : public NetworkSession {
public:
static Ref<NetworkSession> create(NetworkProcess& networkProcess, NetworkSessionCreationParameters&& parameters)
{
return adoptRef(*new NetworkSessionHaiku(networkProcess, WTFMove(parameters)));
}
~NetworkSessionHaiku();

private:
NetworkSessionHaiku(NetworkProcess&, NetworkSessionCreationParameters&&);
};

} // namespace WebKit
@@ -50,16 +50,17 @@ void Attachment::release()
}
#endif

#if !OS(WINDOWS)
#if !OS(WINDOWS) && !PLATFORM(HAIKU)
void Attachment::encode(Encoder& encoder) const
{
{fprintf(stderr,"\n%s-%ld\n",__PRETTY_FUNCTION__,m_connectionID);
encoder.addAttachment(WTFMove(*const_cast<Attachment*>(this)));
}

bool Attachment::decode(Decoder& decoder, Attachment& attachment)
{
if (!decoder.removeAttachment(attachment))
return false;
fprintf(stderr,"\n%s\n",__PRETTY_FUNCTION__);
return true;
}
#endif

0 comments on commit 641dd71

Please sign in to comment.
You can’t perform that action at this time.