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

Unified Diff: ipc/ipc_channel_proxy.cc

Issue 2068343003: Revert "Send input event IPCs directly from the UI thread" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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') | ipc/ipc_sync_channel.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_channel_proxy.cc
diff --git a/ipc/ipc_channel_proxy.cc b/ipc/ipc_channel_proxy.cc
index 4fd8a9aa02cb268217b948660cbdffd6f9f272e3..b3424124158d5034c5cd142c8779a81c17c83923 100644
--- a/ipc/ipc_channel_proxy.cc
+++ b/ipc/ipc_channel_proxy.cc
@@ -318,20 +318,23 @@ void ChannelProxy::Context::ClearChannel() {
channel_.reset();
}
-bool ChannelProxy::Context::Send(std::unique_ptr<Message> message,
- bool force_io_thread) {
- if (channel_send_thread_safe_ && !force_io_thread) {
- base::AutoLock l(channel_lifetime_lock_);
- if (!channel_)
- return false;
- DCHECK(channel_->IsSendThreadSafe());
- return channel_->Send(message.release());
+void ChannelProxy::Context::SendFromThisThread(Message* message) {
+ base::AutoLock l(channel_lifetime_lock_);
+ if (!channel_)
+ return;
+ DCHECK(channel_->IsSendThreadSafe());
+ channel_->Send(message);
+}
+
+void ChannelProxy::Context::Send(Message* message) {
+ if (channel_send_thread_safe_) {
+ SendFromThisThread(message);
+ return;
}
ipc_task_runner()->PostTask(
FROM_HERE, base::Bind(&ChannelProxy::Context::OnSendMessage, this,
- base::Passed(&message)));
- return true;
+ base::Passed(base::WrapUnique(message))));
}
bool ChannelProxy::Context::IsChannelSendThreadSafe() const {
@@ -374,7 +377,11 @@ ChannelProxy::ChannelProxy(Context* context)
ChannelProxy::ChannelProxy(
Listener* listener,
const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner)
- : ChannelProxy(new Context(listener, ipc_task_runner)) {}
+ : context_(new Context(listener, ipc_task_runner)), did_init_(false) {
+#if defined(ENABLE_IPC_FUZZER)
+ outgoing_message_filter_ = NULL;
+#endif
+}
ChannelProxy::~ChannelProxy() {
DCHECK(CalledOnValidThread());
@@ -437,15 +444,25 @@ void ChannelProxy::Close() {
}
bool ChannelProxy::Send(Message* message) {
- return SendImpl(base::WrapUnique(message), true /* force_io_thread */);
-}
+ DCHECK(did_init_);
-bool ChannelProxy::SendNow(std::unique_ptr<Message> message) {
- return SendImpl(std::move(message), false /* force_io_thread */);
-}
+ // 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
-bool ChannelProxy::SendOnIPCThread(std::unique_ptr<Message> message) {
- return SendImpl(std::move(message), true /* force_io_thread */);
+ context_->Send(message);
+ return true;
}
void ChannelProxy::AddFilter(MessageFilter* filter) {
@@ -502,28 +519,6 @@ base::ScopedFD ChannelProxy::TakeClientFileDescriptor() {
void ChannelProxy::OnChannelInit() {
}
-bool ChannelProxy::SendImpl(std::unique_ptr<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.reset(outgoing_message_filter()->Rewrite(message.release()));
-#endif
-
-#ifdef IPC_MESSAGE_LOG_ENABLED
- Logging::GetInstance()->OnSendMessage(message.get(), context_->channel_id());
-#endif
-
- return context_->Send(std::move(message), force_io_thread);
-}
-
//-----------------------------------------------------------------------------
} // namespace IPC
« no previous file with comments | « ipc/ipc_channel_proxy.h ('k') | ipc/ipc_sync_channel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698