@@ -33,12 +33,17 @@ namespace WebKit {

bool AuxiliaryProcessMainBase::parseCommandLine(int argc, char** argv)
{
fprintf(stderr,"\naux:%s\n",argv[1]);
ASSERT(argc >= 3);
if (argc < 3)
return false;
m_parameters.processIdentifier = makeObjectIdentifier<WebCore::ProcessIdentifierType>(atoll(argv[1]));
#if PLATFORM(HAIKU)
m_parameters.processIdentifier = makeObjectIdentifier<WebCore::ProcessIdentifierType>(atoll(argv[2]));
m_parameters.connectionIdentifier = atol(argv[3]);
#else
m_parameters.processIdentifier = makeObjectIdentifier<WebCore::ProcessIdentifierType>(atoll(argv[1]));
m_parameters.connectionIdentifier = atoi(argv[2]);
#endif

return true;
}

@@ -37,6 +37,10 @@ class AuxiliaryProcessMainBase {
virtual bool parseCommandLine(int argc, char** argv);
virtual void platformFinalize() { }

#if PLATFORM(HAIKU)
virtual void runApp() {};
#endif

AuxiliaryProcessInitializationParameters&& takeInitializationParameters() { return WTFMove(m_parameters); }

protected:
@@ -63,7 +67,11 @@ int AuxiliaryProcessMain(int argc, char** argv)
return EXIT_FAILURE;

initializeAuxiliaryProcess<AuxiliaryProcessType>(auxiliaryMain.takeInitializationParameters());
#if PLATFORM(HAIKU)
auxiliaryMain.runApp();
#else
RunLoop::run();
#endif
auxiliaryMain.platformFinalize();

return EXIT_SUCCESS;
@@ -31,11 +31,25 @@
#include <Roster.h>
#include <StackOrHeapArray.h>
#include <String.h>
#include <unistd.h>

using namespace WebCore;

namespace WebKit {

status_t processRef(BString path, entry_ref* pathRef)
{
BEntry pathEntry(path);
if(!pathEntry.Exists())
return B_BAD_VALUE;

status_t result = pathEntry.GetRef(pathRef);
if(result != B_OK)
return result;

return B_OK;
}

void ProcessLauncher::launchProcess()
{
BString executablePath;
@@ -54,7 +68,9 @@ void ProcessLauncher::launchProcess()
return;
}

BString processIdentifier;
BString processIdentifier,processID;
team_id UIProcessID = getpid();
processID.SetToFormat("%ld",UIProcessID);
processIdentifier.SetToFormat("%" PRIu64, m_launchOptions.processIdentifier.toUInt64());
unsigned nargs = 5; // size of the argv array for g_spawn_async()

@@ -67,6 +83,11 @@ void ProcessLauncher::launchProcess()
}
#endif

entry_ref executableRef;
if(processRef(executablePath,&executableRef)!=B_OK)
{
return;
}
BStackOrHeapArray<const char*, 10> argv(nargs);
unsigned i = 0;
#if ENABLE(DEVELOPER_MODE)
@@ -77,15 +98,16 @@ void ProcessLauncher::launchProcess()
#endif
argv[i++] = executablePath.String();
argv[i++] = processIdentifier.String();
argv[i++] = processID.String();
// TODO pass our team_id so the web process can message us?
argv[i++] = nullptr;

assert(i <= nargs);

team_id child_id; // TODO do we need to store this somewhere?
status_t result = be_roster->Launch(executablePath, i, argv, &child_id);
status_t result = be_roster->Launch(&executableRef, i-1, argv, &child_id);

fprintf(stderr, "%s: %s\n", __PRETTY_FUNCTION__, strerror(result));
fprintf(stderr, "%s: %s %ld\n", __PRETTY_FUNCTION__, strerror(result),child_id);

// We've finished launching the process, message back to the main run loop.
RunLoop::main().dispatch([protectedThis = makeRef(*this), this, child_id] {
@@ -33,7 +33,7 @@ namespace WebKit {
using namespace WebCore;

Ref<WebConnectionToUIProcess> WebConnectionToUIProcess::create(WebProcess* process)
{
{fprintf(stderr,"%s\n",__PRETTY_FUNCTION__);
return adoptRef(*new WebConnectionToUIProcess(process));
}

@@ -90,6 +90,8 @@ void WebInspector::setFrontendConnection(IPC::Attachment encodedConnectionIdenti
IPC::Connection::Identifier connectionIdentifier(encodedConnectionIdentifier.port());
#elif OS(WINDOWS)
IPC::Connection::Identifier connectionIdentifier(encodedConnectionIdentifier.handle());
#elif PLATFORM(HAIKU)
IPC::Connection::Identifier connectionIdentifier(NULL);
#else
notImplemented();
return;
@@ -92,12 +92,15 @@ void WebInspectorUI::updateConnection()
IPC::Connection::Identifier connectionIdentifier, connClient;
IPC::Connection::createServerAndClientIdentifiers(connectionIdentifier, connClient);
IPC::Attachment connectionClientPort(connClient);
#elif PLATFORM(HAIKU)
IPC::Connection::Identifier connectionIdentifier;
IPC::Attachment connectionClientPort;
#else
notImplemented();
return;
#endif

#if USE(UNIX_DOMAIN_SOCKETS) || OS(DARWIN) || PLATFORM(WIN)
#if USE(UNIX_DOMAIN_SOCKETS) || OS(DARWIN) || PLATFORM(WIN) || PLATFORM(HAIKU)
m_backendConnection = IPC::Connection::createServerConnection(connectionIdentifier, *this);
m_backendConnection->open();
#endif
@@ -26,11 +26,12 @@
#include "config.h"
#include "WebProcessMainUnix.h"

#include "AuxiliaryProcessMain.h"
#include "AuxiliaryProcessMainHaiku.h"
#include "WebProcess.h"

#include <Application.h>
#include<Message.h>
#include <Message.h>
#include <Messenger.h>

using namespace std;
using namespace WebCore;
@@ -39,41 +40,37 @@ namespace WebKit {

class WebProcessApp: public BApplication
{
private:
int argc;
char** argv;
public:
WebProcessApp(void):BApplication("application/x-vnd.haiku-webkit.webprocess")
WebProcessApp(int argc,char** argv):BApplication("application/x-vnd.haiku-webkit.webprocess")
{
this->argc = argc;
this->argv = argv;
}

void MessageReceived(BMessage* msg)
{
fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
msg->PrintToStream();
//msg->PrintToStream();
switch(msg->what)
{
default:
BApplication::MessageReceived(msg);
}
}

void ReadyToRun()
{
fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
RunLoop::initializeMainRunLoop();
RunLoop::run();
AuxiliaryProcessMain<WebProcess>(argc,argv);
}
};


class WebProcessMain final : public AuxiliaryProcessMainBase {
public:
bool platformInitialize() override
{
WebProcessApp* app= new WebProcessApp();
fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
app->Run();
return true;
}
};

int WebProcessMainUnix(int argc, char** argv)
{
fprintf(stderr, "%s\n", __PRETTY_FUNCTION__);
return AuxiliaryProcessMain<WebProcess, WebProcessMain>(argc, argv);
WebProcessApp* app = new WebProcessApp(argc,argv);
return app->Run();
}

} // namespace WebKit
@@ -35,14 +35,11 @@ App::App(void)
void
App::MessageReceived(BMessage *msg)
{
switch(msg->what)
{
default:
{
BApplication::MessageReceived(msg);
break;
}
}
switch(msg->what)
{
default:
BApplication::MessageReceived(msg);
}
}
void App::ReadyToRun()
{