| 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 #include "tools/ipc_fuzzer/replay/replay_process.h" | 5 #include "tools/ipc_fuzzer/replay/replay_process.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <string> | 8 #include <string> |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/posix/global_descriptors.h" | 13 #include "base/posix/global_descriptors.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "ipc/ipc_descriptors.h" | 15 #include "ipc/ipc_descriptors.h" |
| 16 #include "ipc/ipc_switches.h" | 16 #include "ipc/ipc_switches.h" |
| 17 #include "ipc/mojo/ipc_channel_mojo.h" | |
| 18 | 17 |
| 19 namespace ipc_fuzzer { | 18 namespace ipc_fuzzer { |
| 20 | 19 |
| 21 ReplayProcess::ReplayProcess() | 20 ReplayProcess::ReplayProcess() |
| 22 : io_thread_("Chrome_ChildIOThread"), | 21 : io_thread_("Chrome_ChildIOThread"), |
| 23 shutdown_event_(true, false), | 22 shutdown_event_(true, false), |
| 24 message_index_(0) { | 23 message_index_(0) { |
| 25 } | 24 } |
| 26 | 25 |
| 27 ReplayProcess::~ReplayProcess() { | 26 ReplayProcess::~ReplayProcess() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 #endif | 59 #endif |
| 61 | 60 |
| 62 return true; | 61 return true; |
| 63 } | 62 } |
| 64 | 63 |
| 65 void ReplayProcess::OpenChannel() { | 64 void ReplayProcess::OpenChannel() { |
| 66 std::string channel_name = | 65 std::string channel_name = |
| 67 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 66 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 68 switches::kProcessChannelID); | 67 switches::kProcessChannelID); |
| 69 | 68 |
| 70 bool should_use_mojo = base::CommandLine::ForCurrentProcess()->HasSwitch( | 69 channel_ = IPC::ChannelProxy::Create(channel_name, |
| 71 "enable-channel-mojo"); | 70 IPC::Channel::MODE_CLIENT, |
| 72 if (should_use_mojo) { | 71 this, |
| 73 channel_ = IPC::ChannelProxy::Create( | 72 io_thread_.message_loop_proxy()); |
| 74 IPC::ChannelMojo::CreateClientFactory(channel_name), | |
| 75 this, | |
| 76 io_thread_.message_loop_proxy()); | |
| 77 } else { | |
| 78 channel_ = IPC::ChannelProxy::Create(channel_name, | |
| 79 IPC::Channel::MODE_CLIENT, | |
| 80 this, | |
| 81 io_thread_.message_loop_proxy()); | |
| 82 } | |
| 83 } | 73 } |
| 84 | 74 |
| 85 bool ReplayProcess::OpenTestcase() { | 75 bool ReplayProcess::OpenTestcase() { |
| 86 base::FilePath path = | 76 base::FilePath path = |
| 87 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 77 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| 88 switches::kIpcFuzzerTestcase); | 78 switches::kIpcFuzzerTestcase); |
| 89 return MessageFile::Read(path, &messages_); | 79 return MessageFile::Read(path, &messages_); |
| 90 } | 80 } |
| 91 | 81 |
| 92 void ReplayProcess::SendNextMessage() { | 82 void ReplayProcess::SendNextMessage() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 119 return true; | 109 return true; |
| 120 } | 110 } |
| 121 | 111 |
| 122 void ReplayProcess::OnChannelError() { | 112 void ReplayProcess::OnChannelError() { |
| 123 LOG(ERROR) << "Channel error, quitting after " | 113 LOG(ERROR) << "Channel error, quitting after " |
| 124 << message_index_ << " messages"; | 114 << message_index_ << " messages"; |
| 125 base::MessageLoop::current()->Quit(); | 115 base::MessageLoop::current()->Quit(); |
| 126 } | 116 } |
| 127 | 117 |
| 128 } // namespace ipc_fuzzer | 118 } // namespace ipc_fuzzer |
| OLD | NEW |