[email protected] | e90d0f33 | 2013-12-06 14:15:52 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
5 | #ifndef TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_ | ||||
6 | #define TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_ | ||||
7 | |||||
avi | cab0f83 | 2015-12-26 07:00:39 | [diff] [blame] | 8 | #include <stddef.h> |
9 | |||||
dcheng | a500b69 | 2016-04-08 19:55:42 | [diff] [blame] | 10 | #include <memory> |
11 | |||||
[email protected] | e90d0f33 | 2013-12-06 14:15:52 | [diff] [blame] | 12 | #include "base/synchronization/waitable_event.h" |
Alex Clarke | f7fb8a8 | 2019-06-06 15:41:53 | [diff] [blame] | 13 | #include "base/task/single_thread_task_executor.h" |
[email protected] | e90d0f33 | 2013-12-06 14:15:52 | [diff] [blame] | 14 | #include "base/threading/thread.h" |
[email protected] | e90d0f33 | 2013-12-06 14:15:52 | [diff] [blame] | 15 | #include "base/timer/timer.h" |
16 | #include "ipc/ipc_channel_proxy.h" | ||||
17 | #include "ipc/ipc_listener.h" | ||||
18 | #include "ipc/ipc_message.h" | ||||
[email protected] | ea24690 | 2013-12-10 20:02:12 | [diff] [blame] | 19 | #include "tools/ipc_fuzzer/message_lib/message_file.h" |
[email protected] | e90d0f33 | 2013-12-06 14:15:52 | [diff] [blame] | 20 | |
amistry | cafcdff | 2016-06-17 03:33:48 | [diff] [blame] | 21 | namespace mojo { |
Ken Rockot | fe962ba | 2018-05-30 16:32:42 | [diff] [blame] | 22 | class IncomingInvitation; |
Ken Rockot | dba46db | 2018-07-04 18:41:04 | [diff] [blame] | 23 | namespace core { |
amistry | cafcdff | 2016-06-17 03:33:48 | [diff] [blame] | 24 | class ScopedIPCSupport; |
Ken Rockot | f03d97c95 | 2018-07-04 22:08:10 | [diff] [blame] | 25 | } // namespace core |
amistry | cafcdff | 2016-06-17 03:33:48 | [diff] [blame] | 26 | } // namespace mojo |
27 | |||||
[email protected] | e90d0f33 | 2013-12-06 14:15:52 | [diff] [blame] | 28 | namespace ipc_fuzzer { |
29 | |||||
30 | class ReplayProcess : public IPC::Listener { | ||||
31 | public: | ||||
32 | ReplayProcess(); | ||||
Peter Boström | c68c5aa | 2021-09-28 00:28:00 | [diff] [blame] | 33 | |
34 | ReplayProcess(const ReplayProcess&) = delete; | ||||
35 | ReplayProcess& operator=(const ReplayProcess&) = delete; | ||||
36 | |||||
dcheng | 6bda0a3 | 2015-01-01 00:01:20 | [diff] [blame] | 37 | ~ReplayProcess() override; |
[email protected] | e90d0f33 | 2013-12-06 14:15:52 | [diff] [blame] | 38 | |
39 | // Set up command line, logging, IO thread. Returns true on success, false | ||||
40 | // otherwise. | ||||
41 | bool Initialize(int argc, const char** argv); | ||||
42 | |||||
43 | // Open a channel to the browser process. It will think we are a renderer. | ||||
44 | void OpenChannel(); | ||||
45 | |||||
46 | // Extract messages from a file specified by --ipc-fuzzer-testcase= | ||||
47 | // Returns true on success, false otherwise. | ||||
48 | bool OpenTestcase(); | ||||
49 | |||||
50 | // Send messages to the browser. | ||||
51 | void Run(); | ||||
52 | |||||
53 | // IPC::Listener implementation. | ||||
dcheng | 6bda0a3 | 2015-01-01 00:01:20 | [diff] [blame] | 54 | bool OnMessageReceived(const IPC::Message& message) override; |
55 | void OnChannelError() override; | ||||
[email protected] | e90d0f33 | 2013-12-06 14:15:52 | [diff] [blame] | 56 | |
57 | private: | ||||
[email protected] | e90d0f33 | 2013-12-06 14:15:52 | [diff] [blame] | 58 | void SendNextMessage(); |
59 | |||||
Ken Rockot | dba46db | 2018-07-04 18:41:04 | [diff] [blame] | 60 | std::unique_ptr<mojo::core::ScopedIPCSupport> mojo_ipc_support_; |
Ken Rockot | fe962ba | 2018-05-30 16:32:42 | [diff] [blame] | 61 | std::unique_ptr<mojo::IncomingInvitation> mojo_invitation_; |
dcheng | a500b69 | 2016-04-08 19:55:42 | [diff] [blame] | 62 | std::unique_ptr<IPC::ChannelProxy> channel_; |
Alex Clarke | f7fb8a8 | 2019-06-06 15:41:53 | [diff] [blame] | 63 | base::SingleThreadTaskExecutor main_task_executor_; |
[email protected] | e90d0f33 | 2013-12-06 14:15:52 | [diff] [blame] | 64 | base::Thread io_thread_; |
65 | base::WaitableEvent shutdown_event_; | ||||
[email protected] | ea24690 | 2013-12-10 20:02:12 | [diff] [blame] | 66 | MessageVector messages_; |
67 | size_t message_index_; | ||||
[email protected] | e90d0f33 | 2013-12-06 14:15:52 | [diff] [blame] | 68 | }; |
69 | |||||
70 | } // namespace ipc_fuzzer | ||||
71 | |||||
72 | #endif // TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_ |