| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_ | 5 #ifndef TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_ |
| 6 #define TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_ | 6 #define TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 17 #include "ipc/ipc_channel_proxy.h" | 17 #include "ipc/ipc_channel_proxy.h" |
| 18 #include "ipc/ipc_listener.h" | 18 #include "ipc/ipc_listener.h" |
| 19 #include "ipc/ipc_message.h" | 19 #include "ipc/ipc_message.h" |
| 20 #include "ipc/mojo/scoped_ipc_support.h" | |
| 21 #include "tools/ipc_fuzzer/message_lib/message_file.h" | 20 #include "tools/ipc_fuzzer/message_lib/message_file.h" |
| 22 | 21 |
| 22 namespace mojo { |
| 23 namespace edk { |
| 24 class ScopedIPCSupport; |
| 25 } // namespace edk |
| 26 } // namespace mojo |
| 27 |
| 23 namespace ipc_fuzzer { | 28 namespace ipc_fuzzer { |
| 24 | 29 |
| 25 class ReplayProcess : public IPC::Listener { | 30 class ReplayProcess : public IPC::Listener { |
| 26 public: | 31 public: |
| 27 ReplayProcess(); | 32 ReplayProcess(); |
| 28 ~ReplayProcess() override; | 33 ~ReplayProcess() override; |
| 29 | 34 |
| 30 // Set up command line, logging, IO thread. Returns true on success, false | 35 // Set up command line, logging, IO thread. Returns true on success, false |
| 31 // otherwise. | 36 // otherwise. |
| 32 bool Initialize(int argc, const char** argv); | 37 bool Initialize(int argc, const char** argv); |
| 33 | 38 |
| 34 // Open a channel to the browser process. It will think we are a renderer. | 39 // Open a channel to the browser process. It will think we are a renderer. |
| 35 void OpenChannel(); | 40 void OpenChannel(); |
| 36 | 41 |
| 37 // Extract messages from a file specified by --ipc-fuzzer-testcase= | 42 // Extract messages from a file specified by --ipc-fuzzer-testcase= |
| 38 // Returns true on success, false otherwise. | 43 // Returns true on success, false otherwise. |
| 39 bool OpenTestcase(); | 44 bool OpenTestcase(); |
| 40 | 45 |
| 41 // Send messages to the browser. | 46 // Send messages to the browser. |
| 42 void Run(); | 47 void Run(); |
| 43 | 48 |
| 44 // IPC::Listener implementation. | 49 // IPC::Listener implementation. |
| 45 bool OnMessageReceived(const IPC::Message& message) override; | 50 bool OnMessageReceived(const IPC::Message& message) override; |
| 46 void OnChannelError() override; | 51 void OnChannelError() override; |
| 47 | 52 |
| 48 private: | 53 private: |
| 49 void SendNextMessage(); | 54 void SendNextMessage(); |
| 50 | 55 |
| 51 std::unique_ptr<IPC::ScopedIPCSupport> mojo_ipc_support_; | 56 std::unique_ptr<mojo::edk::ScopedIPCSupport> mojo_ipc_support_; |
| 52 std::unique_ptr<IPC::ChannelProxy> channel_; | 57 std::unique_ptr<IPC::ChannelProxy> channel_; |
| 53 base::MessageLoop main_loop_; | 58 base::MessageLoop main_loop_; |
| 54 base::Thread io_thread_; | 59 base::Thread io_thread_; |
| 55 base::WaitableEvent shutdown_event_; | 60 base::WaitableEvent shutdown_event_; |
| 56 std::unique_ptr<base::Timer> timer_; | 61 std::unique_ptr<base::Timer> timer_; |
| 57 MessageVector messages_; | 62 MessageVector messages_; |
| 58 size_t message_index_; | 63 size_t message_index_; |
| 59 | 64 |
| 60 DISALLOW_COPY_AND_ASSIGN(ReplayProcess); | 65 DISALLOW_COPY_AND_ASSIGN(ReplayProcess); |
| 61 }; | 66 }; |
| 62 | 67 |
| 63 } // namespace ipc_fuzzer | 68 } // namespace ipc_fuzzer |
| 64 | 69 |
| 65 #endif // TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_ | 70 #endif // TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_ |
| OLD | NEW |