xref: /aosp_15_r20/external/libchrome/ipc/ipc_security_test_util.cc (revision 635a864187cb8b6c713ff48b7e790a6b21769273)
1*635a8641SAndroid Build Coastguard Worker // Copyright 2014 The Chromium Authors. All rights reserved.
2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be
3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file.
4*635a8641SAndroid Build Coastguard Worker 
5*635a8641SAndroid Build Coastguard Worker #include "ipc/ipc_security_test_util.h"
6*635a8641SAndroid Build Coastguard Worker 
7*635a8641SAndroid Build Coastguard Worker #include "base/bind.h"
8*635a8641SAndroid Build Coastguard Worker #include "base/bind_helpers.h"
9*635a8641SAndroid Build Coastguard Worker #include "base/run_loop.h"
10*635a8641SAndroid Build Coastguard Worker #include "ipc/ipc_channel_proxy.h"
11*635a8641SAndroid Build Coastguard Worker 
12*635a8641SAndroid Build Coastguard Worker namespace IPC {
13*635a8641SAndroid Build Coastguard Worker 
PwnMessageReceived(ChannelProxy * channel,const IPC::Message & message)14*635a8641SAndroid Build Coastguard Worker void IpcSecurityTestUtil::PwnMessageReceived(ChannelProxy* channel,
15*635a8641SAndroid Build Coastguard Worker                                              const IPC::Message& message) {
16*635a8641SAndroid Build Coastguard Worker   base::RunLoop run_loop;
17*635a8641SAndroid Build Coastguard Worker   base::Closure inject_message = base::Bind(
18*635a8641SAndroid Build Coastguard Worker       base::IgnoreResult(&IPC::ChannelProxy::Context::OnMessageReceived),
19*635a8641SAndroid Build Coastguard Worker       channel->context(), message);
20*635a8641SAndroid Build Coastguard Worker   channel->context()->ipc_task_runner()->PostTaskAndReply(
21*635a8641SAndroid Build Coastguard Worker       FROM_HERE, inject_message, run_loop.QuitClosure());
22*635a8641SAndroid Build Coastguard Worker   run_loop.Run();
23*635a8641SAndroid Build Coastguard Worker }
24*635a8641SAndroid Build Coastguard Worker 
25*635a8641SAndroid Build Coastguard Worker }  // namespace IPC
26