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

Side by Side Diff: services/native_support/process_impl.cc

Issue 1375313006: For c++, Generate enum classes instead of enum from mojom. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "services/native_support/process_impl.h" 5 #include "services/native_support/process_impl.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 const SpawnWithTerminalCallback& callback) { 125 const SpawnWithTerminalCallback& callback) {
126 DCHECK(terminal_file); 126 DCHECK(terminal_file);
127 127
128 std::vector<int> fds_to_inherit(3, -1); 128 std::vector<int> fds_to_inherit(3, -1);
129 129
130 base::ScopedFD master_fd; 130 base::ScopedFD master_fd;
131 base::ScopedFD slave_fd; 131 base::ScopedFD slave_fd;
132 int errno_value = 0; 132 int errno_value = 0;
133 if (!MakePtyPair(&master_fd, &slave_fd, &errno_value)) { 133 if (!MakePtyPair(&master_fd, &slave_fd, &errno_value)) {
134 // TODO(vtl): Well, this is dumb (we should use errno_value). 134 // TODO(vtl): Well, this is dumb (we should use errno_value).
135 callback.Run(mojo::files::ERROR_UNKNOWN); 135 callback.Run(mojo::files::Error::UNKNOWN);
136 return; 136 return;
137 } 137 }
138 138
139 // stdin: 139 // stdin:
140 base::ScopedFD stdin_fd(slave_fd.Pass()); 140 base::ScopedFD stdin_fd(slave_fd.Pass());
141 fds_to_inherit[STDIN_FILENO] = stdin_fd.get(); 141 fds_to_inherit[STDIN_FILENO] = stdin_fd.get();
142 142
143 // stdout: 143 // stdout:
144 base::ScopedFD stdout_fd(HANDLE_EINTR(dup(stdin_fd.get()))); 144 base::ScopedFD stdout_fd(HANDLE_EINTR(dup(stdin_fd.get())));
145 fds_to_inherit[STDOUT_FILENO] = stdout_fd.get(); 145 fds_to_inherit[STDOUT_FILENO] = stdout_fd.get();
(...skipping 21 matching lines...) Expand all
167 DCHECK(!path.is_null()); 167 DCHECK(!path.is_null());
168 DCHECK(process_controller.is_pending()); 168 DCHECK(process_controller.is_pending());
169 169
170 size_t argc = std::max(argv.size(), static_cast<size_t>(1)); 170 size_t argc = std::max(argv.size(), static_cast<size_t>(1));
171 std::vector<const char*> argv_ptrs(argc); 171 std::vector<const char*> argv_ptrs(argc);
172 if (argv.is_null()) { 172 if (argv.is_null()) {
173 argv_ptrs[0] = path.data(); 173 argv_ptrs[0] = path.data();
174 } else { 174 } else {
175 if (!argv.size() || 175 if (!argv.size() ||
176 argv.size() > static_cast<size_t>(std::numeric_limits<int>::max())) { 176 argv.size() > static_cast<size_t>(std::numeric_limits<int>::max())) {
177 callback.Run(mojo::files::ERROR_INVALID_ARGUMENT); 177 callback.Run(mojo::files::Error::INVALID_ARGUMENT);
178 return; 178 return;
179 } 179 }
180 // TODO(vtl): Currently, we don't support setting argv[0], due to 180 // TODO(vtl): Currently, we don't support setting argv[0], due to
181 // |base::CommandLine| limitations. 181 // |base::CommandLine| limitations.
182 argv_ptrs[0] = path.data(); 182 argv_ptrs[0] = path.data();
183 for (size_t i = 1; i < argv.size(); i++) 183 for (size_t i = 1; i < argv.size(); i++)
184 argv_ptrs[i] = argv[i].data(); 184 argv_ptrs[i] = argv[i].data();
185 } 185 }
186 base::CommandLine command_line(static_cast<int>(argc), argv_ptrs.data()); 186 base::CommandLine command_line(static_cast<int>(argc), argv_ptrs.data());
187 187
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 #endif 220 #endif
221 // launch_options.kill_on_parent_death = true; 221 // launch_options.kill_on_parent_death = true;
222 // launch_options.current_directory 222 // launch_options.current_directory
223 launch_options.pre_exec_delegate = &pre_exec_delegate; 223 launch_options.pre_exec_delegate = &pre_exec_delegate;
224 224
225 base::Process process = LaunchProcess(command_line, launch_options); 225 base::Process process = LaunchProcess(command_line, launch_options);
226 // Note: Failure is extremely unusual. E.g., it won't fail even if |path| 226 // Note: Failure is extremely unusual. E.g., it won't fail even if |path|
227 // doesn't exist (since fork succeeds; it's the exec that fails). 227 // doesn't exist (since fork succeeds; it's the exec that fails).
228 if (!process.IsValid()) { 228 if (!process.IsValid()) {
229 // TODO(vtl): Well, this is dumb (can we check errno?). 229 // TODO(vtl): Well, this is dumb (can we check errno?).
230 callback.Run(mojo::files::ERROR_UNKNOWN); 230 callback.Run(mojo::files::Error::UNKNOWN);
231 return; 231 return;
232 } 232 }
233 233
234 new ProcessControllerImpl(worker_runner_, process_controller.Pass(), 234 new ProcessControllerImpl(worker_runner_, process_controller.Pass(),
235 process.Pass(), std::move(process_io_redirection)); 235 process.Pass(), std::move(process_io_redirection));
236 callback.Run(mojo::files::ERROR_OK); 236 callback.Run(mojo::files::Error::OK);
237 } 237 }
238 238
239 } // namespace native_support 239 } // namespace native_support
OLDNEW
« no previous file with comments | « services/native_support/process_controller_impl_unittest.cc ('k') | services/native_support/process_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698