blob: 9fa45281a3e152f43ded658395023e90b714e036 [file] [log] [blame]
[email protected]e90d0f332013-12-06 14:15:521// 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
avicab0f832015-12-26 07:00:398#include <stddef.h>
9
dchenga500b692016-04-08 19:55:4210#include <memory>
11
[email protected]e90d0f332013-12-06 14:15:5212#include "base/synchronization/waitable_event.h"
Alex Clarkef7fb8a82019-06-06 15:41:5313#include "base/task/single_thread_task_executor.h"
[email protected]e90d0f332013-12-06 14:15:5214#include "base/threading/thread.h"
[email protected]e90d0f332013-12-06 14:15:5215#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]ea246902013-12-10 20:02:1219#include "tools/ipc_fuzzer/message_lib/message_file.h"
[email protected]e90d0f332013-12-06 14:15:5220
amistrycafcdff2016-06-17 03:33:4821namespace mojo {
Ken Rockotfe962ba2018-05-30 16:32:4222class IncomingInvitation;
Ken Rockotdba46db2018-07-04 18:41:0423namespace core {
amistrycafcdff2016-06-17 03:33:4824class ScopedIPCSupport;
Ken Rockotf03d97c952018-07-04 22:08:1025} // namespace core
amistrycafcdff2016-06-17 03:33:4826} // namespace mojo
27
[email protected]e90d0f332013-12-06 14:15:5228namespace ipc_fuzzer {
29
30class ReplayProcess : public IPC::Listener {
31 public:
32 ReplayProcess();
Peter Boströmc68c5aa2021-09-28 00:28:0033
34 ReplayProcess(const ReplayProcess&) = delete;
35 ReplayProcess& operator=(const ReplayProcess&) = delete;
36
dcheng6bda0a32015-01-01 00:01:2037 ~ReplayProcess() override;
[email protected]e90d0f332013-12-06 14:15:5238
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.
dcheng6bda0a32015-01-01 00:01:2054 bool OnMessageReceived(const IPC::Message& message) override;
55 void OnChannelError() override;
[email protected]e90d0f332013-12-06 14:15:5256
57 private:
[email protected]e90d0f332013-12-06 14:15:5258 void SendNextMessage();
59
Ken Rockotdba46db2018-07-04 18:41:0460 std::unique_ptr<mojo::core::ScopedIPCSupport> mojo_ipc_support_;
Ken Rockotfe962ba2018-05-30 16:32:4261 std::unique_ptr<mojo::IncomingInvitation> mojo_invitation_;
dchenga500b692016-04-08 19:55:4262 std::unique_ptr<IPC::ChannelProxy> channel_;
Alex Clarkef7fb8a82019-06-06 15:41:5363 base::SingleThreadTaskExecutor main_task_executor_;
[email protected]e90d0f332013-12-06 14:15:5264 base::Thread io_thread_;
65 base::WaitableEvent shutdown_event_;
[email protected]ea246902013-12-10 20:02:1266 MessageVector messages_;
67 size_t message_index_;
[email protected]e90d0f332013-12-06 14:15:5268};
69
70} // namespace ipc_fuzzer
71
72#endif // TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_