OLD | NEW |
(Empty) | |
| 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 |
| 8 #include <list> |
| 9 |
| 10 #include "base/files/memory_mapped_file.h" |
| 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/message_loop/message_loop.h" |
| 13 #include "base/synchronization/waitable_event.h" |
| 14 #include "base/threading/thread.h" |
| 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" |
| 19 |
| 20 namespace ipc_fuzzer { |
| 21 |
| 22 class ReplayProcess : public IPC::Listener { |
| 23 public: |
| 24 ReplayProcess(); |
| 25 virtual ~ReplayProcess(); |
| 26 |
| 27 // Set up command line, logging, IO thread. Returns true on success, false |
| 28 // otherwise. |
| 29 bool Initialize(int argc, const char** argv); |
| 30 |
| 31 // Open a channel to the browser process. It will think we are a renderer. |
| 32 void OpenChannel(); |
| 33 |
| 34 // Extract messages from a file specified by --ipc-fuzzer-testcase= |
| 35 // Returns true on success, false otherwise. |
| 36 bool OpenTestcase(); |
| 37 |
| 38 // Send messages to the browser. |
| 39 void Run(); |
| 40 |
| 41 // IPC::Listener implementation. |
| 42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 43 virtual void OnChannelError() OVERRIDE; |
| 44 |
| 45 private: |
| 46 bool ExtractMessages(const char *data, size_t len); |
| 47 void SendNextMessage(); |
| 48 |
| 49 scoped_ptr<IPC::ChannelProxy> channel_; |
| 50 base::MessageLoop main_loop_; |
| 51 base::Thread io_thread_; |
| 52 base::WaitableEvent shutdown_event_; |
| 53 scoped_ptr<base::Timer> timer_; |
| 54 scoped_ptr<base::MemoryMappedFile> mapped_testcase_; |
| 55 std::list<IPC::Message*> messages_; |
| 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(ReplayProcess); |
| 58 }; |
| 59 |
| 60 } // namespace ipc_fuzzer |
| 61 |
| 62 #endif // TOOLS_IPC_FUZZER_REPLAY_REPLAY_PROCESS_H_ |
OLD | NEW |