Bug 1771234 - Make it easier to use a specific serial event target when binding an actor, r=ipc-reviewers,mccr8

Differential Revision: https://phabricator.services.mozilla.com/D147381
This commit is contained in:
Nika Layzell 2022-06-01 14:35:16 +00:00
Родитель 60e4c4c184
Коммит fc7c1048de
3 изменённых файлов: 12 добавлений и 5 удалений

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

@ -98,11 +98,16 @@ class Endpoint {
// This method binds aActor to this endpoint. After this call, the actor can
// be used to send and receive messages. The endpoint becomes invalid.
bool Bind(PFooSide* aActor) {
//
// If specified, aEventTarget is the target the actor will be bound to, and
// must be on the current thread. Otherwise, GetCurrentSerialEventTarget() is
// used.
bool Bind(PFooSide* aActor, nsISerialEventTarget* aEventTarget = nullptr) {
MOZ_RELEASE_ASSERT(IsValid());
MOZ_RELEASE_ASSERT(mMyPid == base::kInvalidProcessId ||
mMyPid == base::GetCurrentProcId());
return aActor->Open(std::move(mPort), mOtherPid);
MOZ_RELEASE_ASSERT(!aEventTarget || aEventTarget->IsOnCurrentThread());
return aActor->Open(std::move(mPort), mOtherPid, aEventTarget);
}
bool IsValid() const { return mPort.IsValid(); }

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

@ -598,9 +598,10 @@ void IToplevelProtocol::SetOtherProcessId(base::ProcessId aOtherPid) {
mOtherPid = aOtherPid;
}
bool IToplevelProtocol::Open(ScopedPort aPort, base::ProcessId aOtherPid) {
bool IToplevelProtocol::Open(ScopedPort aPort, base::ProcessId aOtherPid,
nsISerialEventTarget* aEventTarget) {
SetOtherProcessId(aOtherPid);
return GetIPCChannel()->Open(std::move(aPort), mSide);
return GetIPCChannel()->Open(std::move(aPort), mSide, aEventTarget);
}
bool IToplevelProtocol::Open(IToplevelProtocol* aTarget,

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

@ -417,7 +417,8 @@ class IToplevelProtocol : public IProtocol {
virtual void OnChannelError() = 0;
virtual void ProcessingError(Result aError, const char* aMsgName) {}
bool Open(ScopedPort aPort, base::ProcessId aOtherPid);
bool Open(ScopedPort aPort, base::ProcessId aOtherPid,
nsISerialEventTarget* aEventTarget = nullptr);
bool Open(IToplevelProtocol* aTarget, nsISerialEventTarget* aEventTarget,
mozilla::ipc::Side aSide = mozilla::ipc::UnknownSide);