Skip to content

Commit

Permalink
Hackish fix for preferences usage in Parent process. Added basic comp…
Browse files Browse the repository at this point in the history
…osito initialization in Parent process
  • Loading branch information
tmeshkova committed Jan 21, 2015
1 parent 83642ac commit 18b3279
Show file tree
Hide file tree
Showing 20 changed files with 598 additions and 47 deletions.
20 changes: 20 additions & 0 deletions dom/ipc/DOMTypes.ipdlh
Expand Up @@ -15,6 +15,9 @@ using struct mozilla::SerializedStructuredCloneBuffer
using struct nsID
from "nsID.h";

using struct mozilla::null_t
from "ipc/IPCMessageUtils.h";

namespace mozilla {
namespace dom {

Expand Down Expand Up @@ -135,5 +138,22 @@ union BlobConstructorParams
ParentBlobConstructorParams;
};

union PrefValue {
nsCString;
int32_t;
bool;
};

union MaybePrefValue {
PrefValue;
null_t;
};

struct PrefSetting {
nsCString name;
MaybePrefValue defaultValue;
MaybePrefValue userValue;
};

} // namespace dom
} // namespace mozilla
17 changes: 0 additions & 17 deletions dom/ipc/PContent.ipdl
Expand Up @@ -282,23 +282,6 @@ union FileSystemParams
FileSystemRemoveParams;
};

union PrefValue {
nsCString;
int32_t;
bool;
};

union MaybePrefValue {
PrefValue;
null_t;
};

struct PrefSetting {
nsCString name;
MaybePrefValue defaultValue;
MaybePrefValue userValue;
};

struct DataStoreSetting {
nsString name;
nsString originURL;
Expand Down
2 changes: 2 additions & 0 deletions embedding/embedlite/EmbedLiteApp.cpp
Expand Up @@ -30,6 +30,7 @@
namespace mozilla {
namespace startup {
extern bool sIsEmbedlite;
extern GeckoProcessType sChildProcessType;
}
namespace embedlite {

Expand Down Expand Up @@ -236,6 +237,7 @@ EmbedLiteApp::StartChildThread()
}

GeckoLoader::InitEmbedding(mProfilePath);
mAppParent = EmbedLiteAppProcessParent::CreateEmbedLiteAppProcessParent();

mAppParent = new EmbedLiteAppThreadParent();
mAppChild = new EmbedLiteAppThreadChild(mUILoop);
Expand Down
3 changes: 3 additions & 0 deletions embedding/embedlite/PEmbedLiteApp.ipdl
Expand Up @@ -5,6 +5,8 @@
include protocol PCompositor;
include protocol PEmbedLiteView;

include DOMTypes;

namespace mozilla {
namespace embedlite {

Expand All @@ -16,6 +18,7 @@ parent:
ReadyToShutdown();
sync CreateWindow(uint32_t parentId, nsCString uri, uint32_t chromeFlags, uint32_t contextFlags)
returns (uint32_t createdID, bool cancel);
PrefsArrayInitialized(PrefSetting[] prefs);

child:
PEmbedLiteView(uint32_t id, uint32_t parentId, bool isPrivateWindow);
Expand Down
6 changes: 6 additions & 0 deletions embedding/embedlite/embedprocess/EmbedLiteAppProcessChild.cpp
Expand Up @@ -33,6 +33,8 @@
#include "mozilla/ModuleUtils.h" // for NS_GENERIC_FACTORY_CONSTRUCTOR
#include "mozilla/layers/PCompositorChild.h"

#include "mozilla/Preferences.h"
#include "mozilla/dom/PContent.h"

using namespace base;
using namespace mozilla::ipc;
Expand Down Expand Up @@ -119,6 +121,10 @@ EmbedLiteAppProcessChild::InitXPCOM()
}

unused << SendInitialized();

InfallibleTArray<mozilla::dom::PrefSetting> prefs;
Preferences::GetPreferences(&prefs);
SendPrefsArrayInitialized(prefs);
}

void
Expand Down
31 changes: 26 additions & 5 deletions embedding/embedlite/embedprocess/EmbedLiteAppProcessParent.cpp
Expand Up @@ -34,6 +34,7 @@
#include "mozilla/layers/ImageBridgeParent.h"

#include "EmbedLiteViewProcessParent.h"
#include "EmbedLiteCompositorProcessParent.h"

static BrowserProcessSubThread* sIOThread;

Expand Down Expand Up @@ -74,6 +75,14 @@ class EmbedLiteAppProcessParentManager MOZ_FINAL : public mozilla::layers::Layer
virtual void GetBackendName(nsAString_internal&) {}
};

static EmbedLiteAppProcessParent* sAppProcessParent = nullptr;

EmbedLiteAppProcessParent*
EmbedLiteAppProcessParent::GetInstance()
{
return sAppProcessParent;
}

EmbedLiteAppProcessParent*
EmbedLiteAppProcessParent::CreateEmbedLiteAppProcessParent()
{
Expand All @@ -94,6 +103,7 @@ EmbedLiteAppProcessParent::EmbedLiteAppProcessParent()
{
LOGT();
MOZ_COUNT_CTOR(EmbedLiteAppProcessParent);
sAppProcessParent = this;

mSubprocess = new GeckoChildProcessHost(GeckoProcessType_Content, base::PRIVILEGES_DEFAULT);

Expand Down Expand Up @@ -174,17 +184,14 @@ EmbedLiteAppProcessParent::OnChannelConnected(int32_t pid)
}
#endif
}

// Set a reply timeout. The only time the parent process will actually
// timeout is through urgent messages (which are used by CPOWs).
SetReplyTimeoutMs(Preferences::GetInt("dom.ipc.cpow.timeout", 3000));
}


bool
EmbedLiteAppProcessParent::RecvInitialized()
{
LOGT();
PR_SetEnv("MOZ_LAYERS_PREFER_OFFSCREEN=1");
mApp->Initialized();
return true;
}
Expand Down Expand Up @@ -320,9 +327,23 @@ EmbedLiteAppProcessParent::AllocPCompositorParent(Transport* aTransport,
{
LOGT();
RefPtr<EmbedLiteAppProcessParentManager> mgr = new EmbedLiteAppProcessParentManager(); // Dummy manager in order to initialize layers log, fix me by creating proper manager for this process type
return CompositorParent::Create(aTransport, aOtherProcess);
// return CompositorParent::Create(aTransport, aOtherProcess);
return EmbedLiteCompositorProcessParent::Create(aTransport, aOtherProcess, 480, 800, 1);
}

bool
EmbedLiteAppProcessParent::RecvPrefsArrayInitialized(const nsTArray<mozilla::dom::PrefSetting>& prefs)
{
LOGT();
mPrefs = prefs;
return true;
}

void
EmbedLiteAppProcessParent::GetPrefs(InfallibleTArray<PrefSetting>* prefs)
{
prefs = &mPrefs;
}

} // namespace embedlite
} // namespace mozilla
Expand Down
12 changes: 12 additions & 0 deletions embedding/embedlite/embedprocess/EmbedLiteAppProcessParent.h
Expand Up @@ -12,8 +12,12 @@ namespace mozilla {
namespace ipc {
class GeckoChildProcessHost;
}
namespace dom {
class PrefSetting;
}
namespace embedlite {

class EmbedLiteApp;
class EmbedLiteAppProcessParent : public PEmbedLiteAppParent
{
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(EmbedLiteAppProcessParent)
Expand All @@ -22,6 +26,10 @@ class EmbedLiteAppProcessParent : public PEmbedLiteAppParent
public:
static EmbedLiteAppProcessParent* CreateEmbedLiteAppProcessParent();

static EmbedLiteAppProcessParent* GetInstance();

void GetPrefs(InfallibleTArray<PrefSetting>* prefs);

protected:
void OnChannelConnected(int32_t pid) MOZ_OVERRIDE;

Expand Down Expand Up @@ -57,12 +65,16 @@ class EmbedLiteAppProcessParent : public PEmbedLiteAppParent
virtual PCompositorParent*
AllocPCompositorParent(Transport* aTransport, ProcessId aOtherProcess);

virtual bool
RecvPrefsArrayInitialized(const nsTArray<mozilla::dom::PrefSetting>& prefs);

private:
virtual ~EmbedLiteAppProcessParent();
void ShutDownProcess(bool aCloseWithError);

EmbedLiteApp* mApp;
mozilla::ipc::GeckoChildProcessHost* mSubprocess;
InfallibleTArray<PrefSetting> mPrefs;

DISALLOW_EVIL_CONSTRUCTORS(EmbedLiteAppProcessParent);
};
Expand Down

0 comments on commit 18b3279

Please sign in to comment.