diff options
Diffstat (limited to 'ipc')
-rw-r--r-- | ipc/ipc_channel_proxy.cc | 15 | ||||
-rw-r--r-- | ipc/ipc_channel_proxy.h | 27 | ||||
-rw-r--r-- | ipc/ipc_sync_channel.cc | 13 | ||||
-rw-r--r-- | ipc/ipc_sync_channel.h | 4 | ||||
-rw-r--r-- | ipc/ipc_sync_channel_unittest.cc | 4 | ||||
-rw-r--r-- | ipc/ipc_tests.cc | 2 |
6 files changed, 35 insertions, 30 deletions
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc index c219829..8f981f4 100644 --- a/ipc/ipc_channel_proxy.cc +++ b/ipc/ipc_channel_proxy.cc @@ -4,7 +4,6 @@ #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" -#include "base/message_loop.h" #include "ipc/ipc_channel_proxy.h" #include "ipc/ipc_logging.h" #include "ipc/ipc_message_utils.h" @@ -60,14 +59,17 @@ void ChannelProxy::MessageFilter::OnDestruct() const { //------------------------------------------------------------------------------ ChannelProxy::Context::Context(Channel::Listener* listener, - MessageLoop* ipc_message_loop) - : listener_message_loop_(MessageLoop::current()), + base::MessageLoopProxy* ipc_message_loop) + : listener_message_loop_(base::MessageLoopProxy::CreateForCurrentThread()), listener_(listener), ipc_message_loop_(ipc_message_loop), peer_pid_(0), channel_connected_called_(false) { } +ChannelProxy::Context::~Context() { +} + void ChannelProxy::Context::CreateChannel(const IPC::ChannelHandle& handle, const Channel::Mode& mode) { DCHECK(channel_.get() == NULL); @@ -280,14 +282,14 @@ void ChannelProxy::Context::OnDispatchError() { ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, Channel::Listener* listener, - MessageLoop* ipc_thread) + base::MessageLoopProxy* ipc_thread) : context_(new Context(listener, ipc_thread)) { Init(channel_handle, mode, ipc_thread, true); } ChannelProxy::ChannelProxy(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, - MessageLoop* ipc_thread, + base::MessageLoopProxy* ipc_thread, Context* context, bool create_pipe_now) : context_(context) { @@ -299,7 +301,8 @@ ChannelProxy::~ChannelProxy() { } void ChannelProxy::Init(const IPC::ChannelHandle& channel_handle, - Channel::Mode mode, MessageLoop* ipc_thread_loop, + Channel::Mode mode, + base::MessageLoopProxy* ipc_thread_loop, bool create_pipe_now) { #if defined(OS_POSIX) // When we are creating a server on POSIX, we need its file descriptor diff --git a/ipc/ipc_channel_proxy.h b/ipc/ipc_channel_proxy.h index 0c0176f..2b1dea8 100644 --- a/ipc/ipc_channel_proxy.h +++ b/ipc/ipc_channel_proxy.h @@ -2,20 +2,19 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#ifndef IPC_IPC_CHANNEL_PROXY_H__ -#define IPC_IPC_CHANNEL_PROXY_H__ +#ifndef IPC_IPC_CHANNEL_PROXY_H_ +#define IPC_IPC_CHANNEL_PROXY_H_ #pragma once #include <vector> #include "base/memory/ref_counted.h" #include "base/memory/scoped_ptr.h" +#include "base/message_loop_proxy.h" #include "base/synchronization/lock.h" #include "ipc/ipc_channel.h" #include "ipc/ipc_channel_handle.h" -class MessageLoop; - namespace IPC { class SendTask; @@ -110,7 +109,7 @@ class ChannelProxy : public Message::Sender { ChannelProxy(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, Channel::Listener* listener, - MessageLoop* ipc_thread_loop); + base::MessageLoopProxy* ipc_thread_loop); virtual ~ChannelProxy(); @@ -156,7 +155,7 @@ class ChannelProxy : public Message::Sender { // immediately. Otherwise it's created on the IO thread. ChannelProxy(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, - MessageLoop* ipc_thread_loop, + base::MessageLoopProxy* ipc_thread_loop, Context* context, bool create_pipe_now); @@ -164,9 +163,11 @@ class ChannelProxy : public Message::Sender { class Context : public base::RefCountedThreadSafe<Context>, public Channel::Listener { public: - Context(Channel::Listener* listener, MessageLoop* ipc_thread); + Context(Channel::Listener* listener, base::MessageLoopProxy* ipc_thread); void ClearIPCMessageLoop() { ipc_message_loop_ = NULL; } - MessageLoop* ipc_message_loop() const { return ipc_message_loop_; } + base::MessageLoopProxy* ipc_message_loop() const { + return ipc_message_loop_.get(); + } const std::string& channel_id() const { return channel_id_; } // Dispatches a message on the listener thread. @@ -174,7 +175,7 @@ class ChannelProxy : public Message::Sender { protected: friend class base::RefCountedThreadSafe<Context>; - virtual ~Context() { } + virtual ~Context(); // IPC::Channel::Listener methods: virtual bool OnMessageReceived(const Message& message); @@ -215,12 +216,12 @@ class ChannelProxy : public Message::Sender { void OnDispatchConnected(); void OnDispatchError(); - MessageLoop* listener_message_loop_; + scoped_refptr<base::MessageLoopProxy> listener_message_loop_; Channel::Listener* listener_; // List of filters. This is only accessed on the IPC thread. std::vector<scoped_refptr<MessageFilter> > filters_; - MessageLoop* ipc_message_loop_; + scoped_refptr<base::MessageLoopProxy> ipc_message_loop_; scoped_ptr<Channel> channel_; std::string channel_id_; int peer_pid_; @@ -239,7 +240,7 @@ class ChannelProxy : public Message::Sender { friend class SendTask; void Init(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, - MessageLoop* ipc_thread_loop, bool create_pipe_now); + base::MessageLoopProxy* ipc_thread_loop, bool create_pipe_now); // By maintaining this indirection (ref-counted) to our internal state, we // can safely be destroyed while the background thread continues to do stuff @@ -249,4 +250,4 @@ class ChannelProxy : public Message::Sender { } // namespace IPC -#endif // IPC_IPC_CHANNEL_PROXY_H__ +#endif // IPC_IPC_CHANNEL_PROXY_H_ diff --git a/ipc/ipc_sync_channel.cc b/ipc/ipc_sync_channel.cc index 97e1c18..f3a6a47 100644 --- a/ipc/ipc_sync_channel.cc +++ b/ipc/ipc_sync_channel.cc @@ -6,7 +6,6 @@ #include "base/lazy_instance.h" #include "base/logging.h" -#include "base/message_loop.h" #include "base/threading/thread_local.h" #include "base/synchronization/waitable_event.h" #include "base/synchronization/waitable_event_watcher.h" @@ -134,7 +133,9 @@ class SyncChannel::ReceivedSyncMsgQueue : } WaitableEvent* dispatch_event() { return &dispatch_event_; } - MessageLoop* listener_message_loop() { return listener_message_loop_; } + base::MessageLoopProxy* listener_message_loop() { + return listener_message_loop_; + } // Holds a pointer to the per-thread ReceivedSyncMsgQueue object. static base::LazyInstance<base::ThreadLocalPointer<ReceivedSyncMsgQueue> > @@ -168,7 +169,7 @@ class SyncChannel::ReceivedSyncMsgQueue : // as manual reset. ReceivedSyncMsgQueue() : dispatch_event_(true, false), - listener_message_loop_(MessageLoop::current()), + listener_message_loop_(base::MessageLoopProxy::CreateForCurrentThread()), task_pending_(false), listener_count_(0), top_send_done_watcher_(NULL) { @@ -192,7 +193,7 @@ class SyncChannel::ReceivedSyncMsgQueue : // sender needs its reply before it can reply to our original synchronous // message. WaitableEvent dispatch_event_; - MessageLoop* listener_message_loop_; + scoped_refptr<base::MessageLoopProxy> listener_message_loop_; base::Lock message_lock_; bool task_pending_; int listener_count_; @@ -208,7 +209,7 @@ base::LazyInstance<base::ThreadLocalPointer<SyncChannel::ReceivedSyncMsgQueue> > SyncChannel::SyncContext::SyncContext( Channel::Listener* listener, - MessageLoop* ipc_thread, + base::MessageLoopProxy* ipc_thread, WaitableEvent* shutdown_event) : ChannelProxy::Context(listener, ipc_thread), received_sync_msgs_(ReceivedSyncMsgQueue::AddContext()), @@ -371,7 +372,7 @@ SyncChannel::SyncChannel( const IPC::ChannelHandle& channel_handle, Channel::Mode mode, Channel::Listener* listener, - MessageLoop* ipc_message_loop, + base::MessageLoopProxy* ipc_message_loop, bool create_pipe_now, WaitableEvent* shutdown_event) : ChannelProxy( diff --git a/ipc/ipc_sync_channel.h b/ipc/ipc_sync_channel.h index 549c35d..8cea5a8 100644 --- a/ipc/ipc_sync_channel.h +++ b/ipc/ipc_sync_channel.h @@ -66,7 +66,7 @@ class SyncChannel : public ChannelProxy, SyncChannel(const IPC::ChannelHandle& channel_handle, Channel::Mode mode, Channel::Listener* listener, - MessageLoop* ipc_message_loop, + base::MessageLoopProxy* ipc_message_loop, bool create_pipe_now, base::WaitableEvent* shutdown_event); virtual ~SyncChannel(); @@ -101,7 +101,7 @@ class SyncChannel : public ChannelProxy, public base::WaitableEventWatcher::Delegate { public: SyncContext(Channel::Listener* listener, - MessageLoop* ipc_thread, + base::MessageLoopProxy* ipc_thread, base::WaitableEvent* shutdown_event); // Adds information about an outgoing sync message to the context so that diff --git a/ipc/ipc_sync_channel_unittest.cc b/ipc/ipc_sync_channel_unittest.cc index 6952aac..fe17c14 100644 --- a/ipc/ipc_sync_channel_unittest.cc +++ b/ipc/ipc_sync_channel_unittest.cc @@ -166,7 +166,7 @@ class Worker : public Channel::Listener, public Message::Sender { // Link ipc_thread_, listener_thread_ and channel_ altogether. StartThread(&ipc_thread_, MessageLoop::TYPE_IO); channel_.reset(new SyncChannel( - channel_name_, mode_, this, ipc_thread_.message_loop(), true, + channel_name_, mode_, this, ipc_thread_.message_loop_proxy(), true, &shutdown_event_)); channel_created_->Signal(); Run(); @@ -1250,7 +1250,7 @@ class RestrictedDispatchClient : public Worker { scoped_ptr<SyncChannel> non_restricted_channel(new SyncChannel( "non_restricted_channel", Channel::MODE_CLIENT, this, - ipc_thread().message_loop(), true, shutdown_event())); + ipc_thread().message_loop_proxy(), true, shutdown_event())); server_->ListenerThread()->message_loop()->PostTask(FROM_HERE, NewRunnableMethod(server_, &RestrictedDispatchServer::OnDoPing, 2)); diff --git a/ipc/ipc_tests.cc b/ipc/ipc_tests.cc index 93276f4..d8e3aeb 100644 --- a/ipc/ipc_tests.cc +++ b/ipc/ipc_tests.cc @@ -251,7 +251,7 @@ TEST_F(IPCChannelTest, ChannelProxyTest) { { // setup IPC channel proxy IPC::ChannelProxy chan(kTestClientChannel, IPC::Channel::MODE_SERVER, - &channel_listener, thread.message_loop()); + &channel_listener, thread.message_loop_proxy()); channel_listener.Init(&chan); |