Skip to content
Permalink
Browse files

Process launching done succesffuly but for now have ignored the case …

…of posting a message to main run loop
  • Loading branch information...
RAJAGOPALAN-GANGADHARAN authored and pulkomandy committed Apr 29, 2019
1 parent db73dba commit 4e6627e0fc3ddcb6a0346771051551499fd07029
@@ -58,7 +58,7 @@ class LoopHandler: public BHandler
void MessageReceived(BMessage* message)
{
if (message->what == 'loop')
m_loop->iterate();
m_loop->iterate();
else if (message->what == 'tmrf') {
RunLoop::TimerBase* timer
= (RunLoop::TimerBase*)message->GetPointer("timer");
@@ -100,7 +100,7 @@ void RunLoop::run()
looper->LockLooper();
looper->AddHandler(current().m_handler);
looper->UnlockLooper();

if (newLooper)
looper->Loop();
}
@@ -115,7 +115,8 @@ void RunLoop::stop()

void RunLoop::wakeUp()
{
m_handler->Looper()->PostMessage('loop', m_handler);
RunLoop::current().performWork();
//m_handler->Looper()->PostMessage('loop', m_handler);
}

RunLoop::TimerBase::TimerBase(RunLoop& runLoop)
@@ -97,7 +97,7 @@ list(APPEND WebCore_SOURCES
platform/graphics/texmap/GraphicsLayerTextureMapper.cpp
platform/graphics/texmap/TextureMapperImageBuffer.cpp

platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp
#platform/graphics/texmap/coordinated/CoordinatedGraphicsLayer.cpp

platform/image-decoders/haiku/ImageDecoderHaiku.cpp

@@ -34,6 +34,7 @@
#if USE(CG)
typedef struct CGAffineTransform CGAffineTransform;
#elif PLATFORM(HAIKU)
#include "PlatformExportMacros.h"
#include <AffineTransform.h>
#endif

@@ -28,6 +28,7 @@

#include <wtf/URL.h>
#include <wtf/text/WTFString.h>
#include "PlatformExportMacros.h"

namespace WebCore {

@@ -118,7 +118,7 @@ WTF::Optional<size_t> BFormDataIO::readFromFile(const FormDataElement::EncodedFi
m_fileHandle = FileSystem::openFile(fileData.filename, FileSystem::FileOpenMode::Read);

if (!FileSystem::isHandleValid(m_fileHandle)) {
LOG(Network, "Haiku - Failed while trying to open %s for upload\n", fileData.filename.utf8().data());
//LOG(Network, "Haiku - Failed while trying to open %s for upload\n", fileData.filename.utf8().data());
m_fileHandle = FileSystem::invalidPlatformFileHandle;
return WTF::nullopt;
}
@@ -127,7 +127,7 @@ WTF::Optional<size_t> BFormDataIO::readFromFile(const FormDataElement::EncodedFi
// handle open and read from the current position.
auto readBytes = FileSystem::readFromFile(m_fileHandle, buffer, size);
if (readBytes < 0) {
LOG(Network, "Haiku - Failed while trying to read %s for upload\n", fileData.filename.utf8().data());
//LOG(Network, "Haiku - Failed while trying to read %s for upload\n", fileData.filename.utf8().data());
FileSystem::closeFile(m_fileHandle);
m_fileHandle = FileSystem::invalidPlatformFileHandle;
return WTF::nullopt;
@@ -203,15 +203,15 @@ WTF::Optional<size_t> BFormDataIO::readFromBlob(const FormDataElement::EncodedBl


if (!FileSystem::isHandleValid(m_fileHandle)) {
LOG(Network, "Haiku - Failed while trying to open %s for upload\n", fileData.filename.utf8().data());
//LOG(Network, "Haiku - Failed while trying to open %s for upload\n", fileData.filename.utf8().data());
m_fileHandle = FileSystem::invalidPlatformFileHandle;
readBytes = -1;
} else {
// Note: there is no management of a file offset, we just keep the file
// handle open and read from the current position.
readBytes = FileSystem::readFromFile(m_fileHandle, buffer, size);
if (readBytes < 0) {
LOG(Network, "Haiku - Failed while trying to read %s for upload\n", fileData.filename.utf8().data());
//LOG(Network, "Haiku - Failed while trying to read %s for upload\n", fileData.filename.utf8().data());
}
}

@@ -16,7 +16,8 @@ list(APPEND WebKit_SOURCES
PluginProcess/unix/PluginProcessUnix.cpp

Shared/WebCoreArgumentCoders.cpp
Shared/haiku/AuxiliaryProcessMainHaiku.cpp
#Shared/haiku/AuxiliaryProcessMainHaiku.cpp
Shared/unix/AuxiliaryProcessMain.cpp
Shared/haiku/ProcessExecutablePathHaiku.cpp
Shared/haiku/ShareableBitmapHaiku.cpp
Shared/haiku/WebCoreArgumentCodersHaiku.cpp
@@ -26,7 +27,6 @@ list(APPEND WebKit_SOURCES
UIProcess/API/haiku/APIWebsiteDataStoreHaiku.cpp

UIProcess/DefaultUndoController.cpp
UIProcess/DrawingAreaProxyImpl.cpp
UIProcess/BackingStore.cpp
UIProcess/AcceleratedDrawingAreaProxy.cpp

@@ -33,10 +33,10 @@ 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]));
m_parameters.connectionIdentifier = atoi(argv[2]);
return true;
@@ -65,7 +65,7 @@ int AuxiliaryProcessMain(int argc, char** argv)
initializeAuxiliaryProcess<AuxiliaryProcessType>(auxiliaryMain.takeInitializationParameters());
RunLoop::run();
auxiliaryMain.platformFinalize();

return EXIT_SUCCESS;
}

@@ -27,6 +27,7 @@
#include "WebProcessPool.h"
#include "WebPageGroup.h"
#include "DrawingAreaProxyImpl.h"
#include <WebCore/IntRect.h>

using namespace WebKit;
using namespace WebCore;
@@ -62,6 +63,38 @@ const API::PageConfiguration& pageConfig)
fPage->drawingArea()->setSize(IntSize(rect.right - rect.left,
rect.top - rect.bottom));
}
BRect p(0,0,10,20);
paint(WebCore::IntRect(p));
}

static void drawPageBackground(const WebPageProxy* page,const BRect& rect)
{
if(!page->drawsBackground())
return;


}


void BWebView::paint(const IntRect& dirtyRect)
{
if(dirtyRect.isEmpty())
{
fprintf(stderr,"its empty\n");
return;
}
fPage->endPrinting();
if(DrawingAreaProxyImpl* drawingArea = static_cast <DrawingAreaProxyImpl*>(fPage->drawingArea()))
{
fprintf(stderr,"its painting\n");
WebCore::Region unpainted;
BView* surface = new BView("drawing_surface",B_WILL_DRAW);
drawingArea->paint(surface,dirtyRect,unpainted);
}
else
{
drawPageBackground(fPage.get(),dirtyRect);
}
}


@@ -34,7 +34,8 @@ using namespace WebKit;
namespace WebKit
{
class BWebView:public API::ObjectImpl<API::Object::Type::View>,
public BView{
public BView
{
public:
static RefPtr<BWebView> create(const char*name,BRect rect,
BWindow* parentWindow,const API::PageConfiguration& config)
@@ -48,6 +49,9 @@ namespace WebKit
BView* getView() const {return fViewPort;}
private:
BWebView(const char*,BRect,BWindow*,const API::PageConfiguration&);

void paint(const WebCore::IntRect&);

BView* fViewPort {nullptr};
RefPtr<WebPageProxy> fPage;
std::unique_ptr<PageClientImpl> fPageClient;
@@ -48,6 +48,7 @@ void ProcessLauncher::didFinishLaunchingProcess(ProcessID processIdentifier, IPC
m_processIdentifier = processIdentifier;
m_isLaunching = false;


if (!m_client) {
// FIXME: Make Identifier a move-only object and release port rights/connections in the destructor.
#if OS(DARWIN) && !PLATFORM(GTK)
@@ -57,7 +58,7 @@ void ProcessLauncher::didFinishLaunchingProcess(ProcessID processIdentifier, IPC
#endif
return;
}

m_client->didFinishLaunching(this, identifier);
}

@@ -26,12 +26,83 @@
#include "config.h"
#include "ProcessLauncher.h"

#define __STDC_FORMAT_MACROS
#include <unistd.h>
#include <string>
#include <inttypes.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sys/resource.h>

#include <Looper.h>


using namespace WebCore;

namespace WebKit {

static const char* processName(ProcessLauncher::ProcessType type)
{
switch(type)
{
case ProcessLauncher::ProcessType::Web:
//debug later will be taken system based absolute path
return "/WebKit/webkit/WebKitBuild/Release/bin/WebProcess";
case ProcessLauncher::ProcessType::Network:
return "/WebKit/webkit/WebKitBuild/Release/bin/NetworkProcess";
}
}

void ProcessLauncher::launchProcess()
{
const char* name=processName(m_launchOptions.processType);
char* procName;
switch(m_launchOptions.processType)
{
case ProcessLauncher::ProcessType::Web:
procName="WebProcess";
break;
case ProcessLauncher::ProcessType::Network:
procName="NetworkProcess";
break;
}
//process identifier
uint64_t prID = m_launchOptions.processIdentifier.toUInt64();
fprintf(stderr,"\nlaunch%d\n",prID);
char buff[21];
snprintf(buff,sizeof(buff),"%"PRIu64,prID);
//

//socket
int sockets[2];
if(socketpair(AF_UNIX, SOCK_STREAM, 0, sockets)==-1)
{
fprintf(stderr,":(%s\n",strerror(errno));
}
//1-> client 0-> server is taken convention

std::string sock = std::to_string(sockets[1]);
char* sockBuff = new char[sock.length()+1];
strcpy(sockBuff,sock.c_str());
//

pid_t pid=fork();
char* m_args[]={procName,buff,sockBuff,NULL};
if(pid==0)
{
execvp(name,m_args);
}
else
{
fprintf(stderr,"\nChild:%d\n",pid);
}
fprintf(stderr,"\ngoing to send\n");
RefPtr<ProcessLauncher> protectedLauncher(this);

RunLoop::main().dispatch([protectedLauncher,pid,sockets]{
fprintf(stderr,"Messaged function executing now\n");
protectedLauncher->didFinishLaunchingProcess(pid,sockets[0]);
});
}

void ProcessLauncher::terminateProcess()
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.device.usb</key>
<true/>
<key>com.apple.security.temporary-exception.mach-lookup.global-name</key>
<string>com.apple.Safari.SafeBrowsing.Service</string>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.temporary-exception.files.absolute-path.read-only</key>
<string>/</string>
</dict>
</plist>
@@ -35,7 +35,6 @@ void WebContextConnectionClient::didCreateConnection(WebProcessPool* processPool
{
if (!m_client.didCreateConnection)
return;

m_client.didCreateConnection(toAPI(processPool), toAPI(connection), m_client.base.clientInfo);
}

@@ -810,7 +810,7 @@ void WebPageProxy::swapToWebProcess(Ref<WebProcessProxy>&& process, std::unique_
void WebPageProxy::finishAttachingToWebProcess(IsProcessSwap isProcessSwap)
{
ASSERT(m_process->state() != AuxiliaryProcessProxy::State::Terminated);

fprintf(stderr,"step1\n");
if (m_process->state() == AuxiliaryProcessProxy::State::Running) {
// In the process-swap case, the ProvisionalPageProxy constructor already took care of calling webPageEnteringWebProcess()
// when the process was provisional.
@@ -1178,9 +1178,9 @@ RefPtr<API::Navigation> WebPageProxy::loadData(const IPC::DataReference& data, c
return nullptr;
}

if (!isValid())
reattachToWebProcess();
fprintf(stderr,"loadData: webPID = %i, pageID = %" PRIu64, m_process->processIdentifier(), m_pageID);
if (!hasRunningProcess())
launchProcess({ });

auto navigation = m_navigationState->createLoadDataNavigation(std::make_unique<API::SubstituteData>(data.vector(), MIMEType, encoding, baseURL, userData));
loadDataWithNavigationShared(m_process.copyRef(), navigation, data, MIMEType, encoding, baseURL, userData, ShouldTreatAsContinuingLoad::No);
return navigation;
@@ -34,13 +34,14 @@ namespace WebKit {

void BackingStore::incorporateUpdate(ShareableBitmap* bitmap, const UpdateInfo& updateInfo)
{
fprintf(stderr,"Updater\n");
notImplemented();
}

void BackingStore::paint(BView* context,const IntRect& rect)
{
fprintf(stderr,"Im drawing");
//needs to be filled


}

@@ -45,7 +45,7 @@ void WebProcessPool::platformInitializeNetworkProcess(NetworkProcessCreationPara

void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
{
fprintf(stderr,"YOLO");
fprintf(stderr,"YOLO webprocess\n");
notImplemented();
}

@@ -49,6 +49,5 @@ int main(int argc, char** argv)
#if USE(GCRYPT)
PAL::GCrypt::initialize();
#endif

return WebProcessMainUnix(argc, argv);
}
@@ -30,11 +30,16 @@

namespace WebKit {

void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& parameters)
void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters& parameters)
{
fprintf(stderr,"weprocess initialize\n");
notImplemented();
}

void WebProcess::platformSetWebsiteDataStoreParameters(WebProcessDataStoreParameters&&)
{
}

void WebProcess::platformTerminate()
{
}

0 comments on commit 4e6627e

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