b=539406 retain existing listener in AyncChannel for GeckoChildProcessHost::OnChannelConnected r=cjones

This commit is contained in:
Josh Matthews 2010-04-12 12:13:00 +12:00
parent f61df0bf35
commit 7354faf277
7 changed files with 44 additions and 5 deletions

View File

@ -72,7 +72,11 @@ class Channel : public Message::Sender {
void Close();
// Modify the Channel's listener.
#ifdef CHROMIUM_MOZILLA_BUILD
Listener* set_listener(Listener* listener);
#else
void set_listener(Listener* listener);
#endif
// Send a message over the Channel to the listener on the other end.
//

View File

@ -807,9 +807,15 @@ void Channel::Close() {
channel_impl_->Close();
}
#ifdef CHROMIUM_MOZILLA_BUILD
Channel::Listener* Channel::set_listener(Listener* listener) {
return channel_impl_->set_listener(listener);
}
#else
void Channel::set_listener(Listener* listener) {
channel_impl_->set_listener(listener);
}
#endif
bool Channel::Send(Message* message) {
return channel_impl_->Send(message);

View File

@ -27,7 +27,15 @@ class Channel::ChannelImpl : public MessageLoopForIO::Watcher {
~ChannelImpl() { Close(); }
bool Connect();
void Close();
#ifdef CHROMIUM_MOZILLA_BUILD
Listener* set_listener(Listener* listener) {
Listener* old = listener_;
listener_ = listener;
return old;
}
#else
void set_listener(Listener* listener) { listener_ = listener; }
#endif
bool Send(Message* message);
void GetClientFileDescriptorMapping(int *src_fd, int *dest_fd) const;

View File

@ -430,9 +430,15 @@ void Channel::Close() {
channel_impl_->Close();
}
#ifdef CHROMIUM_MOZILLA_BUILD
Channel::Listener* Channel::set_listener(Listener* listener) {
return channel_impl_->set_listener(listener);
}
#else
void Channel::set_listener(Listener* listener) {
channel_impl_->set_listener(listener);
}
#endif
bool Channel::Send(Message* message) {
return channel_impl_->Send(message);

View File

@ -23,7 +23,15 @@ class Channel::ChannelImpl : public MessageLoopForIO::IOHandler {
~ChannelImpl() { Close(); }
bool Connect();
void Close();
#ifdef CHROMIUM_MOZILLA_BUILD
Listener* set_listener(Listener* listener) {
Listener* old = listener_;
listener_ = listener;
return old;
}
#else
void set_listener(Listener* listener) { listener_ = listener; }
#endif
bool Send(Message* message);
private:
const std::wstring PipeName(const std::wstring& channel_id) const;

View File

@ -92,7 +92,8 @@ AsyncChannel::AsyncChannel(AsyncListener* aListener)
mIOLoop(),
mWorkerLoop(),
mChild(false),
mChannelErrorTask(NULL)
mChannelErrorTask(NULL),
mExistingListener(NULL)
{
MOZ_COUNT_CTOR(AsyncChannel);
}
@ -112,7 +113,7 @@ AsyncChannel::Open(Transport* aTransport, MessageLoop* aIOLoop)
// FIXME need to check for valid channel
mTransport = aTransport;
mTransport->set_listener(this);
mExistingListener = mTransport->set_listener(this);
// FIXME figure out whether we're in parent or child, grab IO loop
// appropriately
@ -432,9 +433,14 @@ AsyncChannel::OnChannelConnected(int32 peer_pid)
{
AssertIOThread();
MutexAutoLock lock(mMutex);
mChannelState = ChannelConnected;
mCvar.Notify();
{
MutexAutoLock lock(mMutex);
mChannelState = ChannelConnected;
mCvar.Notify();
}
if(mExistingListener)
mExistingListener->OnChannelConnected(peer_pid);
}
void

View File

@ -191,6 +191,7 @@ protected:
MessageLoop* mWorkerLoop; // thread where work is done
bool mChild; // am I the child or parent?
CancelableTask* mChannelErrorTask; // NotifyMaybeChannelError runnable
IPC::Channel::Listener* mExistingListener; // channel's previous listener
};