| Index: ipc/ipc_channel_proxy.cc
|
| diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc
|
| index b3424124158d5034c5cd142c8779a81c17c83923..bd368850cdcfb429a2fddfd7853145cb72309a68 100644
|
| --- a/ipc/ipc_channel_proxy.cc
|
| +++ b/ipc/ipc_channel_proxy.cc
|
| @@ -318,23 +318,22 @@ void ChannelProxy::Context::ClearChannel() {
|
| channel_.reset();
|
| }
|
|
|
| -void ChannelProxy::Context::SendFromThisThread(Message* message) {
|
| +bool ChannelProxy::Context::SendFromThisThread(Message* message) {
|
| base::AutoLock l(channel_lifetime_lock_);
|
| if (!channel_)
|
| - return;
|
| + return false;
|
| DCHECK(channel_->IsSendThreadSafe());
|
| - channel_->Send(message);
|
| + return channel_->Send(message);
|
| }
|
|
|
| -void ChannelProxy::Context::Send(Message* message) {
|
| - if (channel_send_thread_safe_) {
|
| - SendFromThisThread(message);
|
| - return;
|
| - }
|
| +bool ChannelProxy::Context::Send(Message* message, bool force_io_thread) {
|
| + if (channel_send_thread_safe_ && !force_io_thread)
|
| + return SendFromThisThread(message);
|
|
|
| ipc_task_runner()->PostTask(
|
| FROM_HERE, base::Bind(&ChannelProxy::Context::OnSendMessage, this,
|
| base::Passed(base::WrapUnique(message))));
|
| + return true;
|
| }
|
|
|
| bool ChannelProxy::Context::IsChannelSendThreadSafe() const {
|
| @@ -377,11 +376,7 @@ ChannelProxy::ChannelProxy(Context* context)
|
| ChannelProxy::ChannelProxy(
|
| Listener* listener,
|
| const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner)
|
| - : context_(new Context(listener, ipc_task_runner)), did_init_(false) {
|
| -#if defined(ENABLE_IPC_FUZZER)
|
| - outgoing_message_filter_ = NULL;
|
| -#endif
|
| -}
|
| + : ChannelProxy(new Context(listener, ipc_task_runner)) {}
|
|
|
| ChannelProxy::~ChannelProxy() {
|
| DCHECK(CalledOnValidThread());
|
| @@ -444,25 +439,15 @@ void ChannelProxy::Close() {
|
| }
|
|
|
| bool ChannelProxy::Send(Message* message) {
|
| - DCHECK(did_init_);
|
| -
|
| - // TODO(alexeypa): add DCHECK(CalledOnValidThread()) here. Currently there are
|
| - // tests that call Send() from a wrong thread. See http://crbug.com/163523.
|
| -
|
| -#ifdef ENABLE_IPC_FUZZER
|
| - // In IPC fuzzing builds, it is possible to define a filter to apply to
|
| - // outgoing messages. It will either rewrite the message and return a new
|
| - // one, freeing the original, or return the message unchanged.
|
| - if (outgoing_message_filter())
|
| - message = outgoing_message_filter()->Rewrite(message);
|
| -#endif
|
| + return SendOnIPCThread(message);
|
| +}
|
|
|
| -#ifdef IPC_MESSAGE_LOG_ENABLED
|
| - Logging::GetInstance()->OnSendMessage(message, context_->channel_id());
|
| -#endif
|
| +bool ChannelProxy::SendNow(Message* message) {
|
| + return SendImpl(message, false /* force_io_thread */);
|
| +}
|
|
|
| - context_->Send(message);
|
| - return true;
|
| +bool ChannelProxy::SendOnIPCThread(Message* message) {
|
| + return SendImpl(message, true /* force_io_thread */);
|
| }
|
|
|
| void ChannelProxy::AddFilter(MessageFilter* filter) {
|
| @@ -519,6 +504,27 @@ base::ScopedFD ChannelProxy::TakeClientFileDescriptor() {
|
| void ChannelProxy::OnChannelInit() {
|
| }
|
|
|
| +bool ChannelProxy::SendImpl(Message* message, bool force_io_thread) {
|
| + DCHECK(did_init_);
|
| +
|
| + // TODO(alexeypa): add DCHECK(CalledOnValidThread()) here. Currently there are
|
| + // tests that call Send() from a wrong thread. See http://crbug.com/163523.
|
| +
|
| +#ifdef ENABLE_IPC_FUZZER
|
| + // In IPC fuzzing builds, it is possible to define a filter to apply to
|
| + // outgoing messages. It will either rewrite the message and return a new
|
| + // one, freeing the original, or return the message unchanged.
|
| + if (outgoing_message_filter())
|
| + message = outgoing_message_filter()->Rewrite(message);
|
| +#endif
|
| +
|
| +#ifdef IPC_MESSAGE_LOG_ENABLED
|
| + Logging::GetInstance()->OnSendMessage(message, context_->channel_id());
|
| +#endif
|
| +
|
| + return context_->Send(message, force_io_thread);
|
| +}
|
| +
|
| //-----------------------------------------------------------------------------
|
|
|
| } // namespace IPC
|
|
|