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

Side by Side Diff: ipc/ipc_sync_message_filter.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 unified diff | Download patch
« no previous file with comments | « ipc/ipc_sync_message_filter.h ('k') | ipc/mojo/ipc_channel_mojo.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ipc/ipc_sync_message_filter.h" 5 #include "ipc/ipc_sync_message_filter.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 17 matching lines...) Expand all
28 *signal = true; 28 *signal = true;
29 *error = result != MOJO_RESULT_OK; 29 *error = result != MOJO_RESULT_OK;
30 } 30 }
31 31
32 } // namespace 32 } // namespace
33 33
34 bool SyncMessageFilter::Send(Message* message) { 34 bool SyncMessageFilter::Send(Message* message) {
35 if (!message->is_sync()) { 35 if (!message->is_sync()) {
36 { 36 {
37 base::AutoLock auto_lock(lock_); 37 base::AutoLock auto_lock(lock_);
38 if (!io_task_runner_.get()) { 38 if (sender_ && is_channel_send_thread_safe_) {
39 sender_->Send(message);
40 return true;
41 } else if (!io_task_runner_.get()) {
39 pending_messages_.emplace_back(base::WrapUnique(message)); 42 pending_messages_.emplace_back(base::WrapUnique(message));
40 return true; 43 return true;
41 } 44 }
42 } 45 }
43 io_task_runner_->PostTask( 46 io_task_runner_->PostTask(
44 FROM_HERE, 47 FROM_HERE,
45 base::Bind(&SyncMessageFilter::SendOnIOThread, this, message)); 48 base::Bind(&SyncMessageFilter::SendOnIOThread, this, message));
46 return true; 49 return true;
47 } 50 }
48 51
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 "SyncMessageFilter::OnMessageReceived", 149 "SyncMessageFilter::OnMessageReceived",
147 (*iter)->done_event); 150 (*iter)->done_event);
148 (*iter)->done_event->Signal(); 151 (*iter)->done_event->Signal();
149 return true; 152 return true;
150 } 153 }
151 } 154 }
152 155
153 return false; 156 return false;
154 } 157 }
155 158
156 bool SyncMessageFilter::SendNow(std::unique_ptr<Message> message) {
157 if (!message->is_sync()) {
158 base::AutoLock auto_lock(lock_);
159 if (sender_ && is_channel_send_thread_safe_) {
160 sender_->Send(message.release());
161 return true;
162 }
163 }
164
165 // Fall back on default Send behavior.
166 return Send(message.release());
167 }
168
169 SyncMessageFilter::SyncMessageFilter(base::WaitableEvent* shutdown_event, 159 SyncMessageFilter::SyncMessageFilter(base::WaitableEvent* shutdown_event,
170 bool is_channel_send_thread_safe) 160 bool is_channel_send_thread_safe)
171 : sender_(NULL), 161 : sender_(NULL),
172 is_channel_send_thread_safe_(is_channel_send_thread_safe), 162 is_channel_send_thread_safe_(is_channel_send_thread_safe),
173 listener_task_runner_(base::ThreadTaskRunnerHandle::Get()), 163 listener_task_runner_(base::ThreadTaskRunnerHandle::Get()),
174 shutdown_event_(shutdown_event) { 164 shutdown_event_(shutdown_event) {
175 } 165 }
176 166
177 SyncMessageFilter::~SyncMessageFilter() { 167 SyncMessageFilter::~SyncMessageFilter() {
178 } 168 }
(...skipping 24 matching lines...) Expand all
203 (*iter)->done_event->Signal(); 193 (*iter)->done_event->Signal();
204 } 194 }
205 } 195 }
206 196
207 void SyncMessageFilter::OnShutdownEventSignaled(base::WaitableEvent* event) { 197 void SyncMessageFilter::OnShutdownEventSignaled(base::WaitableEvent* event) {
208 DCHECK_EQ(event, shutdown_event_); 198 DCHECK_EQ(event, shutdown_event_);
209 shutdown_mojo_event_.Signal(); 199 shutdown_mojo_event_.Signal();
210 } 200 }
211 201
212 } // namespace IPC 202 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_sync_message_filter.h ('k') | ipc/mojo/ipc_channel_mojo.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698