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.
5 #ifndef TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_
6 #define TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/synchronization/waitable_event.h"
11 #include "base/threading/thread.h"
12 #include "base/timer/timer.h"
13 #include "ipc/ipc_channel_proxy.h"
14 #include "ipc/ipc_listener.h"
15 #include "ipc/ipc_message.h"
16 #include "tools/ipc_fuzzer/message_lib/message_file.h"
18 namespace ipc_fuzzer
{
20 class ReplayProcess
: public IPC::Listener
{
23 ~ReplayProcess() override
;
25 // Set up command line, logging, IO thread. Returns true on success, false
27 bool Initialize(int argc
, const char** argv
);
29 // Open a channel to the browser process. It will think we are a renderer.
32 // Extract messages from a file specified by --ipc-fuzzer-testcase=
33 // Returns true on success, false otherwise.
36 // Send messages to the browser.
39 // IPC::Listener implementation.
40 bool OnMessageReceived(const IPC::Message
& message
) override
;
41 void OnChannelError() override
;
44 void SendNextMessage();
46 scoped_ptr
<IPC::ChannelProxy
> channel_
;
47 base::MessageLoop main_loop_
;
48 base::Thread io_thread_
;
49 base::WaitableEvent shutdown_event_
;
50 scoped_ptr
<base::Timer
> timer_
;
51 MessageVector messages_
;
52 size_t message_index_
;
54 DISALLOW_COPY_AND_ASSIGN(ReplayProcess
);
57 } // namespace ipc_fuzzer
59 #endif // TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_