Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: tools/ipc_fuzzer/message_replay/replay_process.cc

Issue 2389193004: Always use ChannelMojo for content child processes. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tools/ipc_fuzzer/fuzzer/fuzzer.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/message_replay/replay_process.h" 5 #include "tools/ipc_fuzzer/message_replay/replay_process.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/posix/global_descriptors.h" 14 #include "base/posix/global_descriptors.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
18 #include "content/public/common/content_switches.h" 18 #include "content/public/common/content_switches.h"
19 #include "content/public/common/mojo_channel_switches.h" 19 #include "content/public/common/mojo_channel_switches.h"
20 #include "ipc/ipc_channel_mojo.h" 20 #include "ipc/ipc_channel_mojo.h"
21 #include "ipc/ipc_descriptors.h" 21 #include "ipc/ipc_descriptors.h"
22 #include "ipc/ipc_switches.h"
23 #include "mojo/edk/embedder/embedder.h" 22 #include "mojo/edk/embedder/embedder.h"
24 #include "mojo/edk/embedder/platform_channel_pair.h" 23 #include "mojo/edk/embedder/platform_channel_pair.h"
25 #include "mojo/edk/embedder/scoped_ipc_support.h" 24 #include "mojo/edk/embedder/scoped_ipc_support.h"
26 25
27 #if defined(OS_POSIX) 26 #if defined(OS_POSIX)
28 #include "content/public/common/content_descriptors.h" 27 #include "content/public/common/content_descriptors.h"
29 #endif 28 #endif
30 29
31 namespace ipc_fuzzer { 30 namespace ipc_fuzzer {
32 31
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 #endif 95 #endif
97 96
98 mojo_ipc_support_.reset( 97 mojo_ipc_support_.reset(
99 new mojo::edk::ScopedIPCSupport(io_thread_.task_runner())); 98 new mojo::edk::ScopedIPCSupport(io_thread_.task_runner()));
100 InitializeMojoIPCChannel(); 99 InitializeMojoIPCChannel();
101 100
102 return true; 101 return true;
103 } 102 }
104 103
105 void ReplayProcess::OpenChannel() { 104 void ReplayProcess::OpenChannel() {
106 // TODO(morrita): As the adoption of ChannelMojo spreads, this 105 channel_ = IPC::ChannelProxy::Create(
107 // criteria has to be updated. 106 IPC::ChannelMojo::CreateClientFactory(
108 std::string process_type = 107 mojo::edk::CreateChildMessagePipe(
109 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 108 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
110 switches::kProcessType); 109 switches::kMojoChannelToken)),
111 bool should_use_mojo = process_type == switches::kRendererProcess; 110 io_thread_.task_runner()),
112 if (should_use_mojo) { 111 this, io_thread_.task_runner());
113 std::string token =
114 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
115 switches::kMojoChannelToken);
116 channel_ = IPC::ChannelProxy::Create(
117 IPC::ChannelMojo::CreateClientFactory(
118 mojo::edk::CreateChildMessagePipe(
119 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
120 switches::kMojoChannelToken)),
121 io_thread_.task_runner()),
122 this, io_thread_.task_runner());
123 } else {
124 std::string channel_name =
125 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
126 switches::kProcessChannelID);
127 channel_ =
128 IPC::ChannelProxy::Create(channel_name, IPC::Channel::MODE_CLIENT, this,
129 io_thread_.task_runner());
130 }
131 } 112 }
132 113
133 bool ReplayProcess::OpenTestcase() { 114 bool ReplayProcess::OpenTestcase() {
134 base::FilePath path = 115 base::FilePath path =
135 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath( 116 base::CommandLine::ForCurrentProcess()->GetSwitchValuePath(
136 switches::kIpcFuzzerTestcase); 117 switches::kIpcFuzzerTestcase);
137 return MessageFile::Read(path, &messages_); 118 return MessageFile::Read(path, &messages_);
138 } 119 }
139 120
140 void ReplayProcess::SendNextMessage() { 121 void ReplayProcess::SendNextMessage() {
(...skipping 26 matching lines...) Expand all
167 return true; 148 return true;
168 } 149 }
169 150
170 void ReplayProcess::OnChannelError() { 151 void ReplayProcess::OnChannelError() {
171 LOG(ERROR) << "Channel error, quitting after " 152 LOG(ERROR) << "Channel error, quitting after "
172 << message_index_ << " messages"; 153 << message_index_ << " messages";
173 base::MessageLoop::current()->QuitWhenIdle(); 154 base::MessageLoop::current()->QuitWhenIdle();
174 } 155 }
175 156
176 } // namespace ipc_fuzzer 157 } // namespace ipc_fuzzer
OLDNEW
« no previous file with comments | « tools/ipc_fuzzer/fuzzer/fuzzer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698