Bug 1445249 - Part 2 - avoid calling OtherPid() where it might return an invalid pid on android; r=jld

MozReview-Commit-ID: EXio3oNJy4U

--HG--
extra : rebase_source : a7fe96470b138bb8758c6b8683ba6ad029adb5a1
This commit is contained in:
Alex Gaynor 2018-03-13 12:54:35 -04:00
Родитель b5a231f297
Коммит 83b1d64e22
2 изменённых файлов: 20 добавлений и 1 удалений

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

@ -596,6 +596,12 @@ IToplevelProtocol::~IToplevelProtocol()
base::ProcessId
IToplevelProtocol::OtherPid() const
{
return OtherPidMaybeInvalid();
}
base::ProcessId
IToplevelProtocol::OtherPidMaybeInvalid() const
{
return mOtherPid;
}
@ -721,8 +727,19 @@ IToplevelProtocol::CreateSharedMemory(size_t aSize,
Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(),
segment.get(),
id);
base::ProcessId pid =
#ifdef ANDROID
// We use OtherPidMaybeInvalid() because on Android this method is actually
// called on an unconnected protocol, but Android's shared memory
// implementation doesn't actually use the PID.
OtherPidMaybeInvalid();
#else
OtherPid();
#endif
Message* descriptor = shmem.ShareTo(
Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), OtherPid(), MSG_ROUTING_CONTROL);
Shmem::IHadBetterBeIPDLCodeCallingThis_OtherwiseIAmADoodyhead(), pid, MSG_ROUTING_CONTROL);
if (!descriptor) {
return nullptr;
}

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

@ -432,6 +432,8 @@ protected:
GetActorEventTargetInternal(IProtocol* aActor) override;
private:
base::ProcessId OtherPidMaybeInvalid() const;
ProtocolId mProtocolId;
UniquePtr<Transport> mTrans;
base::ProcessId mOtherPid;