diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-28 22:09:45 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-28 22:09:45 +0000 |
commit | 16395142c1bd6b2203fa67585ec52316f8156aaa (patch) | |
tree | bb0b96512330d037e96563dd1dc9686250162661 /ipc/ipc_channel_proxy.cc | |
parent | 6349deef4335dee8a99fdbec27baf93bdf33adbb (diff) | |
download | chromium_src-16395142c1bd6b2203fa67585ec52316f8156aaa.zip chromium_src-16395142c1bd6b2203fa67585ec52316f8156aaa.tar.gz chromium_src-16395142c1bd6b2203fa67585ec52316f8156aaa.tar.bz2 |
The messages attached to the task created by an IPC ChannelProxy are leaked when the message loop is destroyed (the MessageLoop deletes its pending tasks on destruction, but not the messages).
BUG=17091
TEST=Run the ui_tests with Purify. We should not be leaking messages.
Review URL: http://codereview.chromium.org/159366
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21900 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc/ipc_channel_proxy.cc')
-rw-r--r-- | ipc/ipc_channel_proxy.cc | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc index eba506d..cbe8cc2 100644 --- a/ipc/ipc_channel_proxy.cc +++ b/ipc/ipc_channel_proxy.cc @@ -10,7 +10,29 @@ namespace IPC { -//----------------------------------------------------------------------------- +//------------------------------------------------------------------------------ + +// This task ensures the message is deleted if the task is deleted without +// having been run. +class SendTask : public Task { + public: + SendTask(ChannelProxy::Context* context, Message* message) + : context_(context), + message_(message) { + } + + virtual void Run() { + context_->OnSendMessage(message_.release()); + } + + private: + scoped_refptr<ChannelProxy::Context> context_; + scoped_ptr<Message> message_; + + DISALLOW_COPY_AND_ASSIGN(SendTask); +}; + +//------------------------------------------------------------------------------ ChannelProxy::Context::Context(Channel::Listener* listener, MessageFilter* filter, @@ -254,8 +276,8 @@ bool ChannelProxy::Send(Message* message) { Logging::current()->OnSendMessage(message, context_->channel_id()); #endif - context_->ipc_message_loop()->PostTask(FROM_HERE, NewRunnableMethod( - context_.get(), &Context::OnSendMessage, message)); + context_->ipc_message_loop()->PostTask(FROM_HERE, + new SendTask(context_.get(), message)); return true; } |