Navigation Menu

Skip to content

Commit

Permalink
Initial version of EmbedLite process backend
Browse files Browse the repository at this point in the history
  • Loading branch information
tmeshkova committed Nov 24, 2014
1 parent d4e1581 commit 2034ebd
Show file tree
Hide file tree
Showing 7 changed files with 274 additions and 0 deletions.
4 changes: 4 additions & 0 deletions embedding/embedlite/EmbedLiteApp.cpp
Expand Up @@ -18,6 +18,7 @@
#include "EmbedLiteSubThread.h"
#include "GeckoLoader.h"

#include "EmbedLiteSubProcess.h"
#include "EmbedLiteAppThreadParent.h"
#include "EmbedLiteAppThreadChild.h"
#include "EmbedLiteView.h"
Expand Down Expand Up @@ -135,6 +136,9 @@ EmbedLiteApp::StartChild(EmbedLiteApp* aApp)
LOGE("Failed to start child thread");
}
}
} else if (aApp->mEmbedType == EMBED_PROCESS) {
aApp->mSubProcess = new EmbedLiteSubProcess();
aApp->mSubProcess->StartEmbedProcess();
}
}

Expand Down
2 changes: 2 additions & 0 deletions embedding/embedlite/EmbedLiteApp.h
Expand Up @@ -24,6 +24,7 @@ class EmbedLiteUILoop;
class EmbedLiteAppThreadChild;
class EmbedLiteAppThreadParent;
class EmbedLiteSubThread;
class EmbedLiteSubProcess;
class EmbedLiteView;
class PEmbedLiteAppParent;
class EmbedLiteAppListener
Expand Down Expand Up @@ -185,6 +186,7 @@ class EmbedLiteApp
RefPtr<EmbedLiteSubThread> mSubThread;
PEmbedLiteAppParent* mAppParent;
RefPtr<EmbedLiteAppThreadChild> mAppChild;
RefPtr<EmbedLiteSubProcess> mSubProcess;

EmbedType mEmbedType;
std::map<uint32_t, EmbedLiteView*> mViews;
Expand Down
82 changes: 82 additions & 0 deletions embedding/embedlite/embedprocess/EmbedLiteAppProcessParent.cpp
@@ -0,0 +1,82 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "EmbedLog.h"
#include "EmbedLiteAppProcessParent.h"
#include "EmbedLiteApp.h"
#include "mozilla/unused.h"

using namespace base;
using namespace mozilla::ipc;

namespace mozilla {
namespace embedlite {

EmbedLiteAppProcessParent::EmbedLiteAppProcessParent()
{
LOGT();
MOZ_COUNT_CTOR(EmbedLiteAppProcessParent);
}

EmbedLiteAppProcessParent::~EmbedLiteAppProcessParent()
{
LOGT();
MOZ_COUNT_DTOR(EmbedLiteAppProcessParent);
}

bool
EmbedLiteAppProcessParent::RecvInitialized()
{
return false;
}

bool
EmbedLiteAppProcessParent::RecvReadyToShutdown()
{
return false;
}

bool
EmbedLiteAppProcessParent::RecvCreateWindow(
const uint32_t& parentId,
const nsCString& uri,
const uint32_t& chromeFlags,
const uint32_t& contextFlags,
uint32_t* createdID,
bool* cancel)
{
return false;
}

bool
EmbedLiteAppProcessParent::RecvObserve(
const nsCString& topic,
const nsString& data)
{
return false;
}

PEmbedLiteViewParent*
EmbedLiteAppProcessParent::AllocPEmbedLiteViewParent(
const uint32_t& id,
const uint32_t& parentId)
{
return 0;
}

bool
EmbedLiteAppProcessParent::DeallocPEmbedLiteViewParent(PEmbedLiteViewParent* aActor)
{
return false;
}

void
EmbedLiteAppProcessParent::ActorDestroy(ActorDestroyReason aWhy)
{
}

} // namespace embedlite
} // namespace mozilla

62 changes: 62 additions & 0 deletions embedding/embedlite/embedprocess/EmbedLiteAppProcessParent.h
@@ -0,0 +1,62 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef MOZ_APP_EMBED_PROCESS_PARENT_H
#define MOZ_APP_EMBED_PROCESS_PARENT_H

#include "mozilla/embedlite/PEmbedLiteAppParent.h"

namespace mozilla {
namespace embedlite {

class EmbedLiteAppProcessParent : public PEmbedLiteAppParent
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(EmbedLiteAppProcessParent)
public:
EmbedLiteAppProcessParent();

protected:
virtual bool
RecvInitialized();

virtual bool
RecvReadyToShutdown();

virtual bool
RecvCreateWindow(
const uint32_t& parentId,
const nsCString& uri,
const uint32_t& chromeFlags,
const uint32_t& contextFlags,
uint32_t* createdID,
bool* cancel);

virtual bool
RecvObserve(
const nsCString& topic,
const nsString& data);

virtual PEmbedLiteViewParent*
AllocPEmbedLiteViewParent(
const uint32_t& id,
const uint32_t& parentId);

virtual bool
DeallocPEmbedLiteViewParent(PEmbedLiteViewParent* aActor);

virtual void
ActorDestroy(ActorDestroyReason aWhy);

private:
virtual ~EmbedLiteAppProcessParent();

private:
DISALLOW_EVIL_CONSTRUCTORS(EmbedLiteAppProcessParent);
};

} // namespace embedlite
} // namespace mozilla

#endif // MOZ_APP_EMBED_PROCESS_PARENT_H
83 changes: 83 additions & 0 deletions embedding/embedlite/embedprocess/EmbedLiteSubProcess.cpp
@@ -0,0 +1,83 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 et :
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "EmbedLog.h"

#include "nsXPCOMPrivate.h"
#include "EmbedLiteSubProcess.h"
#include "GeckoLoader.h"
#include "EmbedLiteApp.h"
#include "GeckoProfiler.h"
#include "EmbedLiteAppProcessParent.h"
#include "mozilla/ipc/BrowserProcessSubThread.h"
#include "nsThreadManager.h"
#include "nsAutoPtr.h"
#include "base/command_line.h"
#include "nsDirectoryService.h"
#include "nsDirectoryServiceDefs.h"

using namespace mozilla::ipc;
using namespace mozilla::dom;
using namespace mozilla::layers;
static BrowserProcessSubThread* sIOThread;

namespace mozilla {
namespace embedlite {

//
// EmbedLiteSubProcess
//

EmbedLiteSubProcess::EmbedLiteSubProcess()
: GeckoChildProcessHost(GeckoProcessType_Content)
{
LOGT();
}

EmbedLiteSubProcess::~EmbedLiteSubProcess()
{
LOGT();
}

void EmbedLiteSubProcess::StartEmbedProcess()
{
LOGT();
if (!BrowserProcessSubThread::GetMessageLoop(BrowserProcessSubThread::IO)) {
UniquePtr<BrowserProcessSubThread> ioThread(new BrowserProcessSubThread(BrowserProcessSubThread::IO));
if (!ioThread.get()) {
return;
}

base::Thread::Options options;
options.message_loop_type = MessageLoop::TYPE_IO;
if (!ioThread->StartWithOptions(options)) {
return;
}
sIOThread = ioThread.release();
}

// Establish the main thread here.
if (NS_FAILED(nsThreadManager::get()->Init())) {
NS_ERROR("Could not initialize thread manager");
return;
}
NS_SetMainThread();
mAppParent = new EmbedLiteAppProcessParent();

// set gGREBinPath
gGREBinPath = ToNewUnicode(nsDependentCString(getenv("GRE_HOME")));

if (!CommandLine::IsInitialized()) {
CommandLine::Init(0, nullptr);
}

LaunchAndWaitForProcessHandle();
mAppParent->Open(GetChannel(), GetOwnedChildProcessHandle());
}

} // namespace embedlite
} // namespace mozilla
36 changes: 36 additions & 0 deletions embedding/embedlite/embedprocess/EmbedLiteSubProcess.h
@@ -0,0 +1,36 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: sw=2 ts=8 et :
*/
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_ipc_EmbedLiteSubProcess_h
#define mozilla_ipc_EmbedLiteSubProcess_h

#include "mozilla/ipc/GeckoChildProcessHost.h"
#include "nsISupportsImpl.h"
#include "nsAutoPtr.h"

namespace mozilla {
namespace embedlite {

class EmbedLiteAppProcessParent;
// Copied from browser_process_impl.cc, modified slightly.
class EmbedLiteSubProcess : public mozilla::ipc::GeckoChildProcessHost
{
public:
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(EmbedLiteSubProcess)
explicit EmbedLiteSubProcess();

void StartEmbedProcess();

private:
virtual ~EmbedLiteSubProcess();
RefPtr<EmbedLiteAppProcessParent> mAppParent;
};

} // namespace embedlite
} // namespace mozilla

#endif // mozilla_embedlite_EmbedLiteSubProcess_h
5 changes: 5 additions & 0 deletions embedding/embedlite/moz.build
Expand Up @@ -36,9 +36,11 @@ EXPORTS.ipc = ['embedhelpers/InputDataIPC.h']
UNIFIED_SOURCES += [
'embedhelpers/EmbedLiteSubThread.cpp',
'embedhelpers/EmbedLiteUILoop.cpp',
'embedprocess/EmbedLiteSubProcess.cpp',
'EmbedLiteApp.cpp',
'EmbedLiteMessagePump.cpp',
'EmbedLiteView.cpp',
'embedprocess/EmbedLiteAppProcessParent.cpp',
'embedthread/EmbedContentController.cpp',
'embedthread/EmbedLiteAppThreadChild.cpp',
'embedthread/EmbedLiteAppThreadParent.cpp',
Expand Down Expand Up @@ -72,7 +74,10 @@ LOCAL_INCLUDES += [
'/gfx/layers/apz/util',
'/js/xpconnect/src',
'/widget',
'/xpcom/build',
'/xpcom/threads',
'embedhelpers',
'embedprocess',
'embedthread',
'modules',
'utils',
Expand Down

0 comments on commit 2034ebd

Please sign in to comment.