From f729d15a933e28cfc000953b75535acc90c3aa5e Mon Sep 17 00:00:00 2001 From: "rsleevi@chromium.org" Date: Sat, 28 Apr 2012 02:12:00 +0000 Subject: RefCounted types should not have public destructors, ipc/ edition BUG=123295 TEST=none Review URL: http://codereview.chromium.org/10008108 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@134421 0039d316-1c4b-4281-b951-d872f2087c98 --- ipc/ipc_channel_proxy.cc | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) (limited to 'ipc/ipc_channel_proxy.cc') diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc index 7eed1bd..f0e9715 100644 --- a/ipc/ipc_channel_proxy.cc +++ b/ipc/ipc_channel_proxy.cc @@ -14,33 +14,10 @@ namespace IPC { -// This helper ensures the message is deleted if the task is deleted without -// having been run. -class SendCallbackHelper - : public base::RefCountedThreadSafe { - public: - SendCallbackHelper(ChannelProxy::Context* context, Message* message) - : context_(context), - message_(message) { - } - - void Send() { - context_->OnSendMessage(message_.release()); - } - - private: - scoped_refptr context_; - scoped_ptr message_; - - DISALLOW_COPY_AND_ASSIGN(SendCallbackHelper); -}; - //------------------------------------------------------------------------------ ChannelProxy::MessageFilter::MessageFilter() {} -ChannelProxy::MessageFilter::~MessageFilter() {} - void ChannelProxy::MessageFilter::OnFilterAdded(Channel* channel) {} void ChannelProxy::MessageFilter::OnFilterRemoved() {} @@ -59,6 +36,8 @@ void ChannelProxy::MessageFilter::OnDestruct() const { delete this; } +ChannelProxy::MessageFilter::~MessageFilter() {} + //------------------------------------------------------------------------------ ChannelProxy::Context::Context(Channel::Listener* listener, @@ -186,13 +165,12 @@ void ChannelProxy::Context::OnChannelClosed() { } // Called on the IPC::Channel thread -void ChannelProxy::Context::OnSendMessage(Message* message) { +void ChannelProxy::Context::OnSendMessage(scoped_ptr message) { if (!channel_.get()) { - delete message; OnChannelClosed(); return; } - if (!channel_->Send(message)) + if (!channel_->Send(message.release())) OnChannelError(); } @@ -368,8 +346,8 @@ bool ChannelProxy::Send(Message* message) { context_->ipc_message_loop()->PostTask( FROM_HERE, - base::Bind(&SendCallbackHelper::Send, - new SendCallbackHelper(context_.get(), message))); + base::Bind(&ChannelProxy::Context::OnSendMessage, + context_, base::Passed(scoped_ptr(message)))); return true; } -- cgit v1.1