summaryrefslogtreecommitdiffstats
path: root/ipc
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 02:24:28 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-29 02:24:28 +0000
commitb53225088747643b4ef35bc4e10e2622ec63ce30 (patch)
tree9a9714078420fef884baf776882fa503c5e58103 /ipc
parent3f2efe60bb9d1829f6ba2f09b8752581b9b6b481 (diff)
downloadchromium_src-b53225088747643b4ef35bc4e10e2622ec63ce30.zip
chromium_src-b53225088747643b4ef35bc4e10e2622ec63ce30.tar.gz
chromium_src-b53225088747643b4ef35bc4e10e2622ec63ce30.tar.bz2
base::Bind: Convert IPC::SendTask.
BUG=none TEST=none R=groby@chromium.org Review URL: http://codereview.chromium.org/8714003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111837 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ipc')
-rw-r--r--ipc/ipc_channel_proxy.cc20
-rw-r--r--ipc/ipc_channel_proxy.h6
2 files changed, 14 insertions, 12 deletions
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc
index fb365d6..f542eae 100644
--- a/ipc/ipc_channel_proxy.cc
+++ b/ipc/ipc_channel_proxy.cc
@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include "base/bind.h"
+#include "base/compiler_specific.h"
#include "base/location.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
@@ -12,18 +13,17 @@
namespace IPC {
-//------------------------------------------------------------------------------
-
-// This task ensures the message is deleted if the task is deleted without
+// This helper ensures the message is deleted if the task is deleted without
// having been run.
-class SendTask : public Task {
+class SendCallbackHelper
+ : public base::RefCountedThreadSafe<SendCallbackHelper> {
public:
- SendTask(ChannelProxy::Context* context, Message* message)
+ SendCallbackHelper(ChannelProxy::Context* context, Message* message)
: context_(context),
message_(message) {
}
- virtual void Run() {
+ void Send() {
context_->OnSendMessage(message_.release());
}
@@ -31,7 +31,7 @@ class SendTask : public Task {
scoped_refptr<ChannelProxy::Context> context_;
scoped_ptr<Message> message_;
- DISALLOW_COPY_AND_ASSIGN(SendTask);
+ DISALLOW_COPY_AND_ASSIGN(SendCallbackHelper);
};
//------------------------------------------------------------------------------
@@ -354,8 +354,10 @@ bool ChannelProxy::Send(Message* message) {
Logging::GetInstance()->OnSendMessage(message, context_->channel_id());
#endif
- context_->ipc_message_loop()->PostTask(FROM_HERE,
- new SendTask(context_.get(), message));
+ context_->ipc_message_loop()->PostTask(
+ FROM_HERE,
+ base::Bind(&SendCallbackHelper::Send,
+ new SendCallbackHelper(context_.get(), message)));
return true;
}
diff --git a/ipc/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h
index ea951fe..49d237e 100644
--- a/ipc/ipc_channel_proxy.h
+++ b/ipc/ipc_channel_proxy.h
@@ -17,7 +17,7 @@
namespace IPC {
-class SendTask;
+class SendCallbackHelper;
//-----------------------------------------------------------------------------
// IPC::ChannelProxy
@@ -222,7 +222,7 @@ class IPC_EXPORT ChannelProxy : public Message::Sender {
private:
friend class ChannelProxy;
- friend class SendTask;
+ friend class SendCallbackHelper;
// Create the Channel
void CreateChannel(const IPC::ChannelHandle& channel_handle,
@@ -263,7 +263,7 @@ class IPC_EXPORT ChannelProxy : public Message::Sender {
}
private:
- friend class SendTask;
+ friend class SendCallbackHelper;
// By maintaining this indirection (ref-counted) to our internal state, we
// can safely be destroyed while the background thread continues to do stuff