Skip to content

Commit

Permalink
Bug 1333968 - Add GetSpecificMessageEventTarget method to change the …
Browse files Browse the repository at this point in the history
…event target for specific IPC messages (r=dvander)

MozReview-Commit-ID: EIyfNgKWCRo
  • Loading branch information
bill-mccloskey committed Apr 11, 2017
1 parent ea4f15c commit 5203251
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion ipc/glue/ProtocolUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,9 @@ IToplevelProtocol::GetMessageEventTarget(const Message& aMsg)
{
int32_t route = aMsg.routing_id();

MutexAutoLock lock(mEventTargetMutex);
Maybe<MutexAutoLock> lock;
lock.emplace(mEventTargetMutex);

nsCOMPtr<nsIEventTarget> target = mEventTargetMap.Lookup(route);

if (aMsg.is_constructor()) {
Expand All @@ -820,6 +822,11 @@ IToplevelProtocol::GetMessageEventTarget(const Message& aMsg)
}

mEventTargetMap.AddWithID(target, handle.mId);
} else if (!target) {
// We don't need the lock after this point.
lock.reset();

target = GetSpecificMessageEventTarget(aMsg);
}

return target.forget();
Expand Down
7 changes: 7 additions & 0 deletions ipc/glue/ProtocolUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,16 @@ class IToplevelProtocol : public IProtocol
GetActorEventTarget();

protected:
// Override this method in top-level protocols to change the event target
// for a new actor (and its sub-actors).
virtual already_AddRefed<nsIEventTarget>
GetConstructedEventTarget(const Message& aMsg) { return nullptr; }

// Override this method in top-level protocols to change the event target
// for specific messages.
virtual already_AddRefed<nsIEventTarget>
GetSpecificMessageEventTarget(const Message& aMsg) { return nullptr; }

virtual void SetEventTargetForActorInternal(IProtocol* aActor, nsIEventTarget* aEventTarget);

virtual already_AddRefed<nsIEventTarget>
Expand Down

0 comments on commit 5203251

Please sign in to comment.