Bug 1580168 Part 1 - Add processID and isParent accessors to ProcessMessageManager, r=nika.

Differential Revision: https://phabricator.services.mozilla.com/D48084

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brian Hackett 2019-10-09 20:49:28 +00:00
Родитель 2ea9213a98
Коммит 2ed60fe6f2
5 изменённых файлов: 21 добавлений и 1 удалений

Просмотреть файл

@ -17,7 +17,10 @@ ProcessMessageManager::ProcessMessageManager(
ParentProcessMessageManager* aParentManager, MessageManagerFlags aFlags)
: MessageSender(aCallback, aParentManager,
aFlags | MessageManagerFlags::MM_CHROME |
MessageManagerFlags::MM_PROCESSMANAGER) {
MessageManagerFlags::MM_PROCESSMANAGER),
mPid(-1),
// aCallback is only specified if this is the in-process manager.
mInProcess(!!aCallback) {
MOZ_ASSERT(!(aFlags & ~(MessageManagerFlags::MM_GLOBAL |
MessageManagerFlags::MM_OWNSCALLBACK)));

Просмотреть файл

@ -41,6 +41,15 @@ class ProcessMessageManager final : public MessageSender {
mozilla::ErrorResult& aError) {
GetDelayedScripts(aCx, aScripts, aError);
}
void SetOsPid(int32_t aPid) { mPid = aPid; }
int32_t OsPid() const { return mPid; }
bool IsInProcess() const { return mInProcess; }
private:
int32_t mPid;
bool mInProcess;
};
} // namespace dom

Просмотреть файл

@ -1592,6 +1592,7 @@ ProcessMessageManager* nsFrameMessageManager::NewProcessMessageManager(
new ProcessMessageManager(new SameParentProcessMessageManagerCallback(),
nsFrameMessageManager::sParentProcessManager,
MessageManagerFlags::MM_OWNSCALLBACK);
mm->SetOsPid(base::GetCurrentProcId());
sSameProcessParentManager = mm;
}
return mm;

Просмотреть файл

@ -611,5 +611,10 @@ ChromeMessageSender includes FrameScriptLoader;
[ChromeOnly, Exposed=Window]
interface ProcessMessageManager : MessageSender
{
// PID of the process being communicated with.
readonly attribute long osPid;
// Whether this is message manager for the current process.
readonly attribute boolean isInProcess;
};
ProcessMessageManager includes ProcessScriptLoader;

Просмотреть файл

@ -1514,6 +1514,7 @@ void ContentParent::ShutDownMessageManager() {
mMessageManager, nullptr, CHILD_PROCESS_SHUTDOWN_MESSAGE, false, nullptr,
nullptr, nullptr, nullptr, IgnoreErrors());
mMessageManager->SetOsPid(-1);
mMessageManager->Disconnect();
mMessageManager = nullptr;
}
@ -2556,6 +2557,7 @@ bool ContentParent::InitInternal(ProcessPriority aInitialPriority) {
// Initialize the message manager (and load delayed scripts) now that we
// have established communications with the child.
mMessageManager->InitWithCallback(this);
mMessageManager->SetOsPid(Pid());
// Set the subprocess's priority. We do this early on because we're likely
// /lowering/ the process's CPU and memory priority, which it has inherited