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

Side by Side Diff: ipc/ipc_sync_message_filter.cc

Issue 2344333002: Expose remote associated interfaces through SyncMessageFilter (Closed)
Patch Set: Created 4 years, 3 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') | no next file » | 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/macros.h" 10 #include "base/macros.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 166
167 return pending_message.send_result; 167 return pending_message.send_result;
168 } 168 }
169 169
170 void SyncMessageFilter::OnFilterAdded(Channel* channel) { 170 void SyncMessageFilter::OnFilterAdded(Channel* channel) {
171 std::vector<std::unique_ptr<Message>> pending_messages; 171 std::vector<std::unique_ptr<Message>> pending_messages;
172 { 172 {
173 base::AutoLock auto_lock(lock_); 173 base::AutoLock auto_lock(lock_);
174 channel_ = channel; 174 channel_ = channel;
175 Channel::AssociatedInterfaceSupport* support =
176 channel_->GetAssociatedInterfaceSupport();
177 if (support)
178 channel_associated_group_ = *support->GetAssociatedGroup();
179
175 io_task_runner_ = base::ThreadTaskRunnerHandle::Get(); 180 io_task_runner_ = base::ThreadTaskRunnerHandle::Get();
176 shutdown_watcher_.StartWatching( 181 shutdown_watcher_.StartWatching(
177 shutdown_event_, 182 shutdown_event_,
178 base::Bind(&SyncMessageFilter::OnShutdownEventSignaled, this)); 183 base::Bind(&SyncMessageFilter::OnShutdownEventSignaled, this));
179 io_message_loop_observer_->StartOnIOThread(); 184 io_message_loop_observer_->StartOnIOThread();
180 std::swap(pending_messages_, pending_messages); 185 std::swap(pending_messages_, pending_messages);
181 } 186 }
182 for (auto& msg : pending_messages) 187 for (auto& msg : pending_messages)
183 SendOnIOThread(msg.release()); 188 SendOnIOThread(msg.release());
184 } 189 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 } 268 }
264 269
265 void SyncMessageFilter::OnIOMessageLoopDestroyed() { 270 void SyncMessageFilter::OnIOMessageLoopDestroyed() {
266 // Since we use an async WaitableEventWatcher to watch the shutdown event 271 // Since we use an async WaitableEventWatcher to watch the shutdown event
267 // from the IO thread, we can't forward the shutdown signal after the IO 272 // from the IO thread, we can't forward the shutdown signal after the IO
268 // message loop is destroyed. Since that destruction indicates shutdown 273 // message loop is destroyed. Since that destruction indicates shutdown
269 // anyway, we manually signal the shutdown event in this case. 274 // anyway, we manually signal the shutdown event in this case.
270 shutdown_mojo_event_.Signal(); 275 shutdown_mojo_event_.Signal();
271 } 276 }
272 277
278 void SyncMessageFilter::GetGenericRemoteAssociatedInterface(
279 const std::string& interface_name,
280 mojo::ScopedInterfaceEndpointHandle handle) {
281 base::AutoLock auto_lock(lock_);
282 DCHECK(io_task_runner_ && io_task_runner_->BelongsToCurrentThread());
283 if (!channel_)
284 return;
285
286 Channel::AssociatedInterfaceSupport* support =
287 channel_->GetAssociatedInterfaceSupport();
288 support->GetGenericRemoteAssociatedInterface(
289 interface_name, std::move(handle));
290 }
291
273 } // namespace IPC 292 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_sync_message_filter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698