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 "content/public/common/content_switches.h" | |
15 #include "ipc/ipc_descriptors.h" | 16 #include "ipc/ipc_descriptors.h" |
16 #include "ipc/ipc_switches.h" | 17 #include "ipc/ipc_switches.h" |
18 #include "ipc/mojo/ipc_channel_mojo.h" | |
17 | 19 |
18 namespace ipc_fuzzer { | 20 namespace ipc_fuzzer { |
19 | 21 |
20 ReplayProcess::ReplayProcess() | 22 ReplayProcess::ReplayProcess() |
21 : io_thread_("Chrome_ChildIOThread"), | 23 : io_thread_("Chrome_ChildIOThread"), |
22 shutdown_event_(true, false), | 24 shutdown_event_(true, false), |
23 message_index_(0) { | 25 message_index_(0) { |
24 } | 26 } |
25 | 27 |
26 ReplayProcess::~ReplayProcess() { | 28 ReplayProcess::~ReplayProcess() { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 #endif | 61 #endif |
60 | 62 |
61 return true; | 63 return true; |
62 } | 64 } |
63 | 65 |
64 void ReplayProcess::OpenChannel() { | 66 void ReplayProcess::OpenChannel() { |
65 std::string channel_name = | 67 std::string channel_name = |
66 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 68 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
67 switches::kProcessChannelID); | 69 switches::kProcessChannelID); |
68 | 70 |
69 channel_ = IPC::ChannelProxy::Create(channel_name, | 71 // TODO(morrita): As the adoption of ChannelMojo spreads, this |
70 IPC::Channel::MODE_CLIENT, | 72 // criteria has to be updated. |
71 this, | 73 std::string process_type = |
72 io_thread_.message_loop_proxy()); | 74 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
75 switches::kProcessType); | |
76 bool should_use_mojo = process_type == switches::kRendererProcess && | |
inferno
2015/01/30 19:21:49
We launch reply process with the following prefixe
Hajime Morrita
2015/01/30 19:29:49
I think so. ChannelMojo is enabled only for the re
| |
77 IPC::ChannelMojo::ShouldBeUsed(); | |
78 if (should_use_mojo) { | |
79 channel_ = IPC::ChannelProxy::Create( | |
80 IPC::ChannelMojo::CreateClientFactory(channel_name), this, | |
81 io_thread_.message_loop_proxy()); | |
82 } else { | |
83 channel_ = | |
84 IPC::ChannelProxy::Create(channel_name, IPC::Channel::MODE_CLIENT, this, | |
85 io_thread_.message_loop_proxy()); | |
86 } | |
73 } | 87 } |
74 | 88 |
75 bool ReplayProcess::OpenTestcase() { | 89 bool ReplayProcess::OpenTestcase() { |
76 base::FilePath path = | 90 base::FilePath path = |
77 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( | 91 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( |
78 switches::kIpcFuzzerTestcase); | 92 switches::kIpcFuzzerTestcase); |
79 return MessageFile::Read(path, &messages_); | 93 return MessageFile::Read(path, &messages_); |
80 } | 94 } |
81 | 95 |
82 void ReplayProcess::SendNextMessage() { | 96 void ReplayProcess::SendNextMessage() { |
(...skipping 26 matching lines...) Expand all Loading... | |
109 return true; | 123 return true; |
110 } | 124 } |
111 | 125 |
112 void ReplayProcess::OnChannelError() { | 126 void ReplayProcess::OnChannelError() { |
113 LOG(ERROR) << "Channel error, quitting after " | 127 LOG(ERROR) << "Channel error, quitting after " |
114 << message_index_ << " messages"; | 128 << message_index_ << " messages"; |
115 base::MessageLoop::current()->Quit(); | 129 base::MessageLoop::current()->Quit(); |
116 } | 130 } |
117 | 131 |
118 } // namespace ipc_fuzzer | 132 } // namespace ipc_fuzzer |
OLD | NEW |