Skip to content

Commit

Permalink
Bug 1283609 - Part 1: Add an IToplevelProtocol::Open overload that ta…
Browse files Browse the repository at this point in the history
…kes an nsIEventTarget; r=billm
  • Loading branch information
janvarga committed Aug 3, 2017
1 parent ca57d29 commit df32731
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
6 changes: 3 additions & 3 deletions ipc/glue/MessageChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ MessageChannel::Open(Transport* aTransport, MessageLoop* aIOLoop, Side aSide)
}

bool
MessageChannel::Open(MessageChannel *aTargetChan, MessageLoop *aTargetLoop, Side aSide)
MessageChannel::Open(MessageChannel *aTargetChan, nsIEventTarget *aEventTarget, Side aSide)
{
// Opens a connection to another thread in the same process.

Expand Down Expand Up @@ -801,12 +801,12 @@ MessageChannel::Open(MessageChannel *aTargetChan, MessageLoop *aTargetLoop, Side

MonitorAutoLock lock(*mMonitor);
mChannelState = ChannelOpening;
aTargetLoop->PostTask(NewNonOwningRunnableMethod<MessageChannel*, Side>(
MOZ_ALWAYS_SUCCEEDS(aEventTarget->Dispatch(NewNonOwningRunnableMethod<MessageChannel*, Side>(
"ipc::MessageChannel::OnOpenAsSlave",
aTargetChan,
&MessageChannel::OnOpenAsSlave,
this,
oppSide));
oppSide)));

while (ChannelOpening == mChannelState)
mMonitor->Wait();
Expand Down
4 changes: 3 additions & 1 deletion ipc/glue/MessageChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include <stack>
#include <vector>

class nsIEventTarget;

namespace mozilla {
namespace ipc {

Expand Down Expand Up @@ -146,7 +148,7 @@ class MessageChannel : HasResultCodes, MessageLoop::DestructionObserver
// For more details on the process of opening a channel between
// threads, see the extended comment on this function
// in MessageChannel.cpp.
bool Open(MessageChannel *aTargetChan, MessageLoop *aTargetLoop, Side aSide);
bool Open(MessageChannel *aTargetChan, nsIEventTarget *aEventTarget, Side aSide);

// Close the underlying transport channel.
void Close();
Expand Down
11 changes: 10 additions & 1 deletion ipc/glue/ProtocolUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,16 @@ IToplevelProtocol::Open(MessageChannel* aChannel,
mozilla::ipc::Side aSide)
{
SetOtherProcessId(base::GetCurrentProcId());
return GetIPCChannel()->Open(aChannel, aMessageLoop, aSide);
return GetIPCChannel()->Open(aChannel, aMessageLoop->SerialEventTarget(), aSide);
}

bool
IToplevelProtocol::Open(MessageChannel* aChannel,
nsIEventTarget* aEventTarget,
mozilla::ipc::Side aSide)
{
SetOtherProcessId(base::GetCurrentProcId());
return GetIPCChannel()->Open(aChannel, aEventTarget, aSide);
}

void
Expand Down
4 changes: 4 additions & 0 deletions ipc/glue/ProtocolUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,10 @@ class IToplevelProtocol : public IProtocol
MessageLoop* aMessageLoop,
mozilla::ipc::Side aSide = mozilla::ipc::UnknownSide);

bool Open(MessageChannel* aChannel,
nsIEventTarget* aEventTarget,
mozilla::ipc::Side aSide = mozilla::ipc::UnknownSide);

void Close();

void SetReplyTimeoutMs(int32_t aTimeoutMs);
Expand Down

0 comments on commit df32731

Please sign in to comment.