mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-11 10:08:41 +00:00
Bug 1040017: Prevent ContentParent from sending broadcast message to Nuwa. r=khuey
This commit is contained in:
parent
96cc1fd517
commit
40e5b2e807
@ -334,6 +334,34 @@ const nsIID nsIConsoleService::COMTypeInfo<nsConsoleService, void>::kIID = NS_IC
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
bool ContentParent::sNuwaReady = false;
|
||||
|
||||
// Contains data that is observed by Nuwa and is going to be sent to
|
||||
// the new process when it is forked.
|
||||
struct ContentParent::NuwaReinitializeData {
|
||||
NuwaReinitializeData()
|
||||
: mReceivedFilePathUpdate(false)
|
||||
, mReceivedFileSystemUpdate(false) { }
|
||||
|
||||
bool mReceivedFilePathUpdate;
|
||||
nsString mFilePathUpdateStoageType;
|
||||
nsString mFilePathUpdateStorageName;
|
||||
nsString mFilePathUpdatePath;
|
||||
nsCString mFilePathUpdateReason;
|
||||
|
||||
bool mReceivedFileSystemUpdate;
|
||||
nsString mFileSystemUpdateFsName;
|
||||
nsString mFileSystemUpdateMountPount;
|
||||
int32_t mFileSystemUpdateState;
|
||||
int32_t mFileSystemUpdateMountGeneration;
|
||||
bool mFileSystemUpdateIsMediaPresent;
|
||||
bool mFileSystemUpdateIsSharing;
|
||||
bool mFileSystemUpdateIsFormatting;
|
||||
bool mFileSystemUpdateIsFake;
|
||||
};
|
||||
#endif
|
||||
|
||||
#define NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC "ipc:network:set-offline"
|
||||
|
||||
class MemoryReportRequestParent : public PMemoryReportRequestParent
|
||||
@ -574,6 +602,9 @@ ContentParent::RunNuwaProcess()
|
||||
PROCESS_PRIORITY_BACKGROUND,
|
||||
/* aIsNuwaProcess = */ true);
|
||||
nuwaProcess->Init();
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
sNuwaReady = false;
|
||||
#endif
|
||||
return nuwaProcess.forget();
|
||||
}
|
||||
|
||||
@ -1971,6 +2002,12 @@ ContentParent::~ContentParent()
|
||||
MOZ_ASSERT(!sAppContentParents ||
|
||||
sAppContentParents->Get(mAppManifestURL) != this);
|
||||
}
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
if (IsNuwaProcess()) {
|
||||
sNuwaReady = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@ -2431,6 +2468,7 @@ ContentParent::RecvNuwaReady()
|
||||
KillHard();
|
||||
return false;
|
||||
}
|
||||
sNuwaReady = true;
|
||||
PreallocatedProcessManager::OnNuwaReady();
|
||||
return true;
|
||||
#else
|
||||
@ -2466,6 +2504,32 @@ ContentParent::RecvAddNewProcess(const uint32_t& aPid,
|
||||
for (int i = 0; i < numNuwaPrefUpdates; i++) {
|
||||
content->SendPreferenceUpdate(sNuwaPrefUpdates->ElementAt(i));
|
||||
}
|
||||
|
||||
// Update offline settings.
|
||||
bool isOffline;
|
||||
RecvGetXPCOMProcessAttributes(&isOffline);
|
||||
content->SendSetOffline(isOffline);
|
||||
|
||||
// Send observed updates to new content.
|
||||
if (mReinitializeData) {
|
||||
if (mReinitializeData->mReceivedFilePathUpdate) {
|
||||
unused << content->SendFilePathUpdate(mReinitializeData->mFilePathUpdateStoageType,
|
||||
mReinitializeData->mFilePathUpdateStorageName,
|
||||
mReinitializeData->mFilePathUpdatePath,
|
||||
mReinitializeData->mFilePathUpdateReason);
|
||||
}
|
||||
if (mReinitializeData->mReceivedFilePathUpdate) {
|
||||
unused << content->SendFileSystemUpdate(mReinitializeData->mFileSystemUpdateFsName,
|
||||
mReinitializeData->mFileSystemUpdateMountPount,
|
||||
mReinitializeData->mFileSystemUpdateState,
|
||||
mReinitializeData->mFileSystemUpdateMountGeneration,
|
||||
mReinitializeData->mFileSystemUpdateIsMediaPresent,
|
||||
mReinitializeData->mFileSystemUpdateIsSharing,
|
||||
mReinitializeData->mFileSystemUpdateIsFormatting,
|
||||
mReinitializeData->mFileSystemUpdateIsFake);
|
||||
}
|
||||
}
|
||||
|
||||
PreallocatedProcessManager::PublishSpareProcess(content);
|
||||
return true;
|
||||
#else
|
||||
@ -2534,8 +2598,15 @@ ContentParent::Observe(nsISupports* aSubject,
|
||||
else if (!strcmp(aTopic, NS_IPC_IOSERVICE_SET_OFFLINE_TOPIC)) {
|
||||
NS_ConvertUTF16toUTF8 dataStr(aData);
|
||||
const char *offline = dataStr.get();
|
||||
if (!SendSetOffline(!strcmp(offline, "true") ? true : false))
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
if (!(IsNuwaReady() && IsNuwaProcess())) {
|
||||
#endif
|
||||
if (!SendSetOffline(!strcmp(offline, "true") ? true : false)) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
}
|
||||
#endif
|
||||
}
|
||||
// listening for alert notifications
|
||||
else if (!strcmp(aTopic, "alertfinished") ||
|
||||
@ -2600,7 +2671,24 @@ ContentParent::Observe(nsISupports* aSubject,
|
||||
CopyUTF16toUTF8(aData, creason);
|
||||
DeviceStorageFile* file = static_cast<DeviceStorageFile*>(aSubject);
|
||||
|
||||
unused << SendFilePathUpdate(file->mStorageType, file->mStorageName, file->mPath, creason);
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
if (!(IsNuwaReady() && IsNuwaProcess())) {
|
||||
#endif
|
||||
|
||||
unused << SendFilePathUpdate(file->mStorageType, file->mStorageName, file->mPath, creason);
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
} else {
|
||||
if (!mReinitializeData) {
|
||||
mReinitializeData = new NuwaReinitializeData();
|
||||
}
|
||||
mReinitializeData->mReceivedFilePathUpdate = true;
|
||||
mReinitializeData->mFilePathUpdateStoageType = file->mStorageType;
|
||||
mReinitializeData->mFilePathUpdateStorageName = file->mStorageName;
|
||||
mReinitializeData->mFilePathUpdatePath = file->mPath;
|
||||
mReinitializeData->mFilePathUpdateReason = creason;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifdef MOZ_WIDGET_GONK
|
||||
else if(!strcmp(aTopic, NS_VOLUME_STATE_CHANGED)) {
|
||||
@ -2627,9 +2715,30 @@ ContentParent::Observe(nsISupports* aSubject,
|
||||
vol->GetIsFormatting(&isFormatting);
|
||||
vol->GetIsFake(&isFake);
|
||||
|
||||
unused << SendFileSystemUpdate(volName, mountPoint, state,
|
||||
mountGeneration, isMediaPresent,
|
||||
isSharing, isFormatting, isFake);
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
if (!(IsNuwaReady() && IsNuwaProcess())) {
|
||||
#endif
|
||||
|
||||
unused << SendFileSystemUpdate(volName, mountPoint, state,
|
||||
mountGeneration, isMediaPresent,
|
||||
isSharing, isFormatting, isFake);
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
} else {
|
||||
if (!mReinitializeData) {
|
||||
mReinitializeData = new NuwaReinitializeData();
|
||||
}
|
||||
mReinitializeData->mReceivedFileSystemUpdate = true;
|
||||
mReinitializeData->mFileSystemUpdateFsName = volName;
|
||||
mReinitializeData->mFileSystemUpdateMountPount = mountPoint;
|
||||
mReinitializeData->mFileSystemUpdateState = state;
|
||||
mReinitializeData->mFileSystemUpdateMountPount = mountGeneration;
|
||||
mReinitializeData->mFileSystemUpdateIsMediaPresent = isMediaPresent;
|
||||
mReinitializeData->mFileSystemUpdateIsSharing = isSharing;
|
||||
mReinitializeData->mFileSystemUpdateIsFormatting = isFormatting;
|
||||
mReinitializeData->mFileSystemUpdateIsFake = isFake;
|
||||
}
|
||||
#endif
|
||||
} else if (!strcmp(aTopic, "phone-state-changed")) {
|
||||
nsString state(aData);
|
||||
unused << SendNotifyPhoneStateChange(state);
|
||||
|
@ -78,6 +78,11 @@ class ContentParent MOZ_FINAL : public PContentParent
|
||||
typedef mozilla::dom::ClonedMessageData ClonedMessageData;
|
||||
|
||||
public:
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
static bool IsNuwaReady() {
|
||||
return sNuwaReady;
|
||||
}
|
||||
#endif
|
||||
virtual bool IsContentParent() MOZ_OVERRIDE { return true; }
|
||||
/**
|
||||
* Start up the content-process machinery. This might include
|
||||
@ -701,6 +706,12 @@ private:
|
||||
// object instead of the child process's lifetime.
|
||||
ScopedClose mChildXSocketFdDup;
|
||||
#endif
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
static bool sNuwaReady;
|
||||
struct NuwaReinitializeData;
|
||||
nsAutoPtr<NuwaReinitializeData> mReinitializeData;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
Loading…
x
Reference in New Issue
Block a user