зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1032125: Part 1: Prevent from sending message to Nuwa after Nuwa frozen. r=khuey
This commit is contained in:
Родитель
261cdd6f71
Коммит
c5cc9fe0f1
|
@ -341,6 +341,7 @@ namespace mozilla {
|
|||
namespace dom {
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
int32_t ContentParent::sNuwaPid = 0;
|
||||
bool ContentParent::sNuwaReady = false;
|
||||
#endif
|
||||
|
||||
|
@ -586,6 +587,7 @@ ContentParent::RunNuwaProcess()
|
|||
/* aIsNuwaProcess = */ true);
|
||||
nuwaProcess->Init();
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
sNuwaPid = nuwaProcess->Pid();
|
||||
sNuwaReady = false;
|
||||
#endif
|
||||
return nuwaProcess.forget();
|
||||
|
@ -1987,6 +1989,7 @@ ContentParent::~ContentParent()
|
|||
#ifdef MOZ_NUWA_PROCESS
|
||||
if (IsNuwaProcess()) {
|
||||
sNuwaReady = false;
|
||||
sNuwaPid = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -79,6 +79,10 @@ class ContentParent MOZ_FINAL : public PContentParent
|
|||
|
||||
public:
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
static int32_t NuwaPid() {
|
||||
return sNuwaPid;
|
||||
}
|
||||
|
||||
static bool IsNuwaReady() {
|
||||
return sNuwaReady;
|
||||
}
|
||||
|
@ -712,6 +716,7 @@ private:
|
|||
#endif
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
static int32_t sNuwaPid;
|
||||
static bool sNuwaReady;
|
||||
#endif
|
||||
};
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#ifdef MOZ_NUWA_PROCESS
|
||||
#include "ipc/Nuwa.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#endif
|
||||
|
||||
#include "mozilla/Assertions.h"
|
||||
|
@ -70,6 +71,9 @@ ProcessLink::ProcessLink(MessageChannel *aChan)
|
|||
, mTransport(nullptr)
|
||||
, mIOLoop(nullptr)
|
||||
, mExistingListener(nullptr)
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
, mIsToNuwaProcess(false)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -168,6 +172,20 @@ ProcessLink::SendMessage(Message *msg)
|
|||
mChan->AssertWorkerThread();
|
||||
mChan->mMonitor->AssertCurrentThreadOwns();
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
if (mIsToNuwaProcess && ContentParent::IsNuwaReady()) {
|
||||
switch (msg->type()) {
|
||||
case mozilla::dom::PContent::Msg_NuwaFork__ID:
|
||||
case mozilla::dom::PContent::Reply_AddNewProcess__ID:
|
||||
case mozilla::dom::PContent::Msg_NotifyPhoneStateChange__ID:
|
||||
case GOODBYE_MESSAGE_TYPE:
|
||||
break;
|
||||
default:
|
||||
MOZ_CRASH();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
mIOLoop->PostTask(
|
||||
FROM_HERE,
|
||||
NewRunnableMethod(mTransport, &Transport::Send, msg));
|
||||
|
@ -360,6 +378,10 @@ ProcessLink::OnChannelConnected(int32_t peer_pid)
|
|||
if (mExistingListener)
|
||||
mExistingListener->OnChannelConnected(peer_pid);
|
||||
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
mIsToNuwaProcess = (peer_pid == ContentParent::NuwaPid());
|
||||
#endif
|
||||
|
||||
if (notifyChannel) {
|
||||
mChan->OnChannelConnected(peer_pid);
|
||||
}
|
||||
|
|
|
@ -170,6 +170,9 @@ class ProcessLink
|
|||
Transport* mTransport;
|
||||
MessageLoop* mIOLoop; // thread where IO happens
|
||||
Transport::Listener* mExistingListener; // channel's previous listener
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
bool mIsToNuwaProcess;
|
||||
#endif
|
||||
};
|
||||
|
||||
class ThreadLink : public MessageLink
|
||||
|
|
Загрузка…
Ссылка в новой задаче