Chromium Code Reviews| 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" | |
| 17 | 18 |
| 18 namespace ipc_fuzzer { | 19 namespace ipc_fuzzer { |
| 19 | 20 |
| 20 ReplayProcess::ReplayProcess() | 21 ReplayProcess::ReplayProcess() |
| 21 : io_thread_("Chrome_ChildIOThread"), | 22 : io_thread_("Chrome_ChildIOThread"), |
| 22 shutdown_event_(true, false), | 23 shutdown_event_(true, false), |
| 23 message_index_(0) { | 24 message_index_(0) { |
| 24 } | 25 } |
| 25 | 26 |
| 26 ReplayProcess::~ReplayProcess() { | 27 ReplayProcess::~ReplayProcess() { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 #endif | 60 #endif |
| 60 | 61 |
| 61 return true; | 62 return true; |
| 62 } | 63 } |
| 63 | 64 |
| 64 void ReplayProcess::OpenChannel() { | 65 void ReplayProcess::OpenChannel() { |
| 65 std::string channel_name = | 66 std::string channel_name = |
| 66 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 67 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 67 switches::kProcessChannelID); | 68 switches::kProcessChannelID); |
| 68 | 69 |
| 69 channel_ = IPC::ChannelProxy::Create(channel_name, | 70 bool should_use_mojo = base::CommandLine::ForCurrentProcess()->HasSwitch( |
|
Tom Sepez
2015/01/29 23:41:15
isn't this now hard-wired to true independent of t
| |
| 70 IPC::Channel::MODE_CLIENT, | 71 "enable-channel-mojo"); |
| 71 this, | 72 if (should_use_mojo) { |
| 72 io_thread_.message_loop_proxy()); | 73 channel_ = IPC::ChannelProxy::Create( |
| 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 } | |
| 73 } | 83 } |
| 74 | 84 |
| 75 bool ReplayProcess::OpenTestcase() { | 85 bool ReplayProcess::OpenTestcase() { |
| 76 base::FilePath path = | 86 base::FilePath path = |
| 77 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 87 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
| 78 switches::kIpcFuzzerTestcase); | 88 switches::kIpcFuzzerTestcase); |
| 79 return MessageFile::Read(path, &messages_); | 89 return MessageFile::Read(path, &messages_); |
| 80 } | 90 } |
| 81 | 91 |
| 82 void ReplayProcess::SendNextMessage() { | 92 void ReplayProcess::SendNextMessage() { |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 109 return true; | 119 return true; |
| 110 } | 120 } |
| 111 | 121 |
| 112 void ReplayProcess::OnChannelError() { | 122 void ReplayProcess::OnChannelError() { |
| 113 LOG(ERROR) << "Channel error, quitting after " | 123 LOG(ERROR) << "Channel error, quitting after " |
| 114 << message_index_ << " messages"; | 124 << message_index_ << " messages"; |
| 115 base::MessageLoop::current()->Quit(); | 125 base::MessageLoop::current()->Quit(); |
| 116 } | 126 } |
| 117 | 127 |
| 118 } // namespace ipc_fuzzer | 128 } // namespace ipc_fuzzer |
| OLD | NEW |