Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Unified Diff: ipc/ipc_channel_proxy.cc

Issue 159366: Fix memory leak in IPC::ChannelProxy (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ipc/ipc_channel_proxy.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_proxy.cc
===================================================================
--- ipc/ipc_channel_proxy.cc (revision 21433)
+++ ipc/ipc_channel_proxy.cc (working copy)
@@ -10,8 +10,30 @@
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,
MessageLoop* ipc_message_loop)
@@ -254,8 +276,8 @@
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;
}
« no previous file with comments | « ipc/ipc_channel_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698