Skip to content

Commit

Permalink
[sailfishos][embedlite] Hackish fix for preferences usage in Parent p…
Browse files Browse the repository at this point in the history
…rocess

Inspired by SHA1: 18b3279 Mon Sep 17 00:00:00 2001
From: Tatiana Meshkova <tanya.meshkova@gmail.com>
Date: Tue, 20 Jan 2015 23:49:38 -0800

Hackish fix for preferences usage in Parent process. Added basic
compositor initialization in Parent process

Signed-off-by: Raine Makelainen <raine.makelainen@jolla.com>
  • Loading branch information
rainemak committed May 27, 2020
1 parent 017d7e4 commit a8057ff
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 25 deletions.
20 changes: 20 additions & 0 deletions dom/ipc/DOMTypes.ipdlh
Expand Up @@ -15,6 +15,9 @@ using struct mozilla::void_t
using struct mozilla::SerializedStructuredCloneBuffer
from "ipc/IPCMessageUtils.h";

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

namespace mozilla {
namespace dom {

Expand Down Expand Up @@ -177,5 +180,22 @@ struct IPCDataTransfer
IPCDataTransferItem[] items;
};

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 @@ -115,23 +115,6 @@ struct FontListEntry {
bool isHidden;
};

union PrefValue {
nsCString;
int32_t;
bool;
};

union MaybePrefValue {
PrefValue;
null_t;
};

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

struct DataStorageItem {
nsCString key;
nsCString value;
Expand Down
4 changes: 3 additions & 1 deletion gfx/layers/composite/LayerManagerComposite.cpp
Expand Up @@ -149,7 +149,9 @@ void
LayerManagerComposite::Destroy()
{
if (!mDestroyed) {
mCompositor->GetWidget()->CleanupWindowEffects();
if (mCompositor->GetWidget()) {
mCompositor->GetWidget()->CleanupWindowEffects();
}
if (mRoot) {
RootLayer()->Destroy();
}
Expand Down
5 changes: 5 additions & 0 deletions gfx/layers/ipc/LayerTransactionParent.h
Expand Up @@ -18,6 +18,10 @@

namespace mozilla {

namespace embedlite {
class EmbedLiteCompositorProcessParent;
}

namespace ipc {
class Shmem;
} // namespace ipc
Expand Down Expand Up @@ -189,6 +193,7 @@ class LayerTransactionParent final : public PLayerTransactionParent,
friend class CompositorBridgeParent;
friend class CrossProcessCompositorBridgeParent;
friend class layout::RenderFrameParent;
friend class mozilla::embedlite::EmbedLiteCompositorProcessParent;

private:
RefPtr<LayerManagerComposite> mLayerManager;
Expand Down
4 changes: 3 additions & 1 deletion gfx/thebes/gfxPlatform.cpp
Expand Up @@ -83,6 +83,7 @@
#include "qcms.h"

#include "imgITools.h"
#include "mozilla/embedlite/EmbedLiteAppProcessParent.h"

#include "plstr.h"
#include "nsCRT.h"
Expand Down Expand Up @@ -787,7 +788,8 @@ gfxPlatform::Init()
// Request the imgITools service, implicitly initializing ImageLib.
nsCOMPtr<imgITools> imgTools = do_GetService("@mozilla.org/image/tools;1");
if (!imgTools) {
NS_RUNTIMEABORT("Could not initialize ImageLib");
// return;
// NS_RUNTIMEABORT("Could not initialize ImageLib");
}

RegisterStrongMemoryReporter(new GfxMemoryImageReporter());
Expand Down
64 changes: 58 additions & 6 deletions modules/libpref/Preferences.cpp
Expand Up @@ -51,6 +51,7 @@
#include "nsRefPtrHashtable.h"
#include "nsIMemoryReporter.h"
#include "nsThreadUtils.h"
#include "mozilla/embedlite/EmbedLiteAppProcessParent.h"

#ifdef DEBUG
#define ENSURE_MAIN_PROCESS(message, pref) do { \
Expand Down Expand Up @@ -541,6 +542,10 @@ NS_INTERFACE_MAP_BEGIN(Preferences)
NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
NS_INTERFACE_MAP_END

static mozilla::embedlite::EmbedLiteAppProcessParent* GetEmbedLiteParent()
{
return mozilla::embedlite::EmbedLiteAppProcessParent::GetInstance();
}

/*
* nsIPrefService Implementation
Expand All @@ -560,14 +565,25 @@ Preferences::Init()
using mozilla::dom::ContentChild;
if (XRE_IsContentProcess()) {
InfallibleTArray<PrefSetting> prefs;
ContentChild::GetSingleton()->SendReadPrefsArray(&prefs);
if (ContentChild::GetSingleton()) {
ContentChild::GetSingleton()->SendReadPrefsArray(&prefs);
}

// Store the array
for (uint32_t i = 0; i < prefs.Length(); ++i) {
pref_SetPref(prefs[i]);
}
return NS_OK;
}
mozilla::embedlite::EmbedLiteAppProcessParent* parent = GetEmbedLiteParent();
if (parent != nullptr) {
InfallibleTArray<PrefSetting> prefs;
parent->GetPrefs(&prefs);
for (uint32_t i = 0; i < prefs.Length(); ++i) {
pref_SetPref(prefs[i]);
}
return NS_OK;
}

nsXPIDLCString lockFileName;
/*
Expand Down Expand Up @@ -1388,7 +1404,10 @@ nsresult
Preferences::GetBool(const char* aPref, bool* aResult)
{
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
if (!GetEmbedLiteParent()) {
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
}

return PREF_GetBoolPref(aPref, aResult, false);
}

Expand All @@ -1397,7 +1416,10 @@ nsresult
Preferences::GetInt(const char* aPref, int32_t* aResult)
{
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
if (!GetEmbedLiteParent()) {
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
}

return PREF_GetIntPref(aPref, aResult, false);
}

Expand All @@ -1406,7 +1428,9 @@ nsresult
Preferences::GetFloat(const char* aPref, float* aResult)
{
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
if (!GetEmbedLiteParent()) {
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
}
nsAutoCString result;
nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), false);
if (NS_SUCCEEDED(rv)) {
Expand Down Expand Up @@ -1439,7 +1463,9 @@ nsresult
Preferences::GetCString(const char* aPref, nsACString* aResult)
{
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
if (!GetEmbedLiteParent()) {
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
}
nsAutoCString result;
nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), false);
if (NS_SUCCEEDED(rv)) {
Expand All @@ -1453,7 +1479,9 @@ nsresult
Preferences::GetString(const char* aPref, nsAString* aResult)
{
NS_PRECONDITION(aResult, "aResult must not be NULL");
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
if (!GetEmbedLiteParent()) {
NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
}
nsAutoCString result;
nsresult rv = PREF_CopyCharPref(aPref, getter_Copies(result), false);
if (NS_SUCCEEDED(rv)) {
Expand Down Expand Up @@ -1620,6 +1648,10 @@ nsresult
Preferences::AddStrongObserver(nsIObserver* aObserver,
const char* aPref)
{
if (GetEmbedLiteParent()) {
return NS_OK;
}

NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return sRootBranch->AddObserver(aPref, aObserver, false);
}
Expand All @@ -1629,6 +1661,10 @@ nsresult
Preferences::AddWeakObserver(nsIObserver* aObserver,
const char* aPref)
{
if (GetEmbedLiteParent()) {
return NS_OK;
}

NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);
return sRootBranch->AddObserver(aPref, aObserver, true);
}
Expand Down Expand Up @@ -1693,6 +1729,10 @@ Preferences::RegisterCallback(PrefChangedFunc aCallback,
void* aClosure,
MatchKind aMatchKind)
{
if (GetEmbedLiteParent()) {
return NS_OK;
}

NS_ENSURE_TRUE(InitStaticMembers(), NS_ERROR_NOT_AVAILABLE);

ValueObserverHashKey hashKey(aPref, aCallback, aMatchKind);
Expand Down Expand Up @@ -1770,6 +1810,9 @@ Preferences::AddBoolVarCache(bool* aCache,
AssertNotAlreadyCached("bool", aPref, aCache);
#endif
*aCache = GetBool(aPref, aDefault);
if (GetEmbedLiteParent()) {
return NS_OK;
}
CacheData* data = new CacheData();
data->cacheLocation = aCache;
data->defaultValueBool = aDefault;
Expand All @@ -1795,6 +1838,9 @@ Preferences::AddIntVarCache(int32_t* aCache,
AssertNotAlreadyCached("int", aPref, aCache);
#endif
*aCache = Preferences::GetInt(aPref, aDefault);
if (GetEmbedLiteParent()) {
return NS_OK;
}
CacheData* data = new CacheData();
data->cacheLocation = aCache;
data->defaultValueInt = aDefault;
Expand All @@ -1820,6 +1866,9 @@ Preferences::AddUintVarCache(uint32_t* aCache,
AssertNotAlreadyCached("uint", aPref, aCache);
#endif
*aCache = Preferences::GetUint(aPref, aDefault);
if (GetEmbedLiteParent()) {
return NS_OK;
}
CacheData* data = new CacheData();
data->cacheLocation = aCache;
data->defaultValueUint = aDefault;
Expand Down Expand Up @@ -1879,6 +1928,9 @@ Preferences::AddFloatVarCache(float* aCache,
AssertNotAlreadyCached("float", aPref, aCache);
#endif
*aCache = Preferences::GetFloat(aPref, aDefault);
if (GetEmbedLiteParent()) {
return NS_OK;
}
CacheData* data = new CacheData();
data->cacheLocation = aCache;
data->defaultValueFloat = aDefault;
Expand Down

0 comments on commit a8057ff

Please sign in to comment.