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

Side by Side Diff: chrome/browser/chromeos/process_proxy/process_proxy.cc

Issue 9429039: Cleanup: Remove base::environment_vector and base::file_handle_mapping_vector to StudlyCaps. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/chromeos/process_proxy/process_proxy.h" 5 #include "chrome/browser/chromeos/process_proxy/process_proxy.h"
6 6
7 #include <cstdio>
8 #include <fcntl.h> 7 #include <fcntl.h>
9 #include <stdlib.h> 8 #include <stdlib.h>
10 #include <sys/ioctl.h> 9 #include <sys/ioctl.h>
11 10
12 #include "base/bind.h" 11 #include "base/bind.h"
13 #include "base/command_line.h" 12 #include "base/command_line.h"
14 #include "base/eintr_wrapper.h" 13 #include "base/eintr_wrapper.h"
15 #include "base/file_util.h" 14 #include "base/file_util.h"
16 #include "base/process_util.h" 15 #include "base/process_util.h"
17 #include "base/logging.h" 16 #include "base/logging.h"
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // We may receive some output even after Close was called (crosh process does 112 // We may receive some output even after Close was called (crosh process does
114 // not have to quit instantly, or there may be some trailing data left in 113 // not have to quit instantly, or there may be some trailing data left in
115 // output stream fds). In that case owner of the callback may be gone so we 114 // output stream fds). In that case owner of the callback may be gone so we
116 // don't want to send it anything. |callback_set_| is reset when this gets 115 // don't want to send it anything. |callback_set_| is reset when this gets
117 // closed. 116 // closed.
118 if (callback_set_) 117 if (callback_set_)
119 callback_.Run(type, output); 118 callback_.Run(type, output);
120 } 119 }
121 120
122 bool ProcessProxy::StopWatching() { 121 bool ProcessProxy::StopWatching() {
123 if (!watcher_started_) 122 if (!watcher_started_)
124 return true; 123 return true;
125 // Signal Watcher that we are done. We use self-pipe trick to unblock watcher. 124 // Signal Watcher that we are done. We use self-pipe trick to unblock watcher.
126 // Anything may be written to the pipe. 125 // Anything may be written to the pipe.
127 const char message[] = "q"; 126 const char message[] = "q";
128 return file_util::WriteFileDescriptor(shutdown_pipe_[PIPE_END_WRITE], 127 return file_util::WriteFileDescriptor(shutdown_pipe_[PIPE_END_WRITE],
129 message, sizeof(message)); 128 message, sizeof(message));
130 } 129 }
131 130
132 void ProcessProxy::Close() { 131 void ProcessProxy::Close() {
133 if (!process_launched_) 132 if (!process_launched_)
134 return; 133 return;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 199
201 if (pt_pair_[PT_SLAVE_FD] == -1) { 200 if (pt_pair_[PT_SLAVE_FD] == -1) {
202 CloseFdPair(pt_pair); 201 CloseFdPair(pt_pair);
203 return false; 202 return false;
204 } 203 }
205 204
206 return true; 205 return true;
207 } 206 }
208 207
209 bool ProcessProxy::LaunchProcess(const std::string& command, int slave_fd, 208 bool ProcessProxy::LaunchProcess(const std::string& command, int slave_fd,
210 pid_t *pid) { 209 pid_t* pid) {
211 // Redirect crosh process' output and input so we can read it. 210 // Redirect crosh process' output and input so we can read it.
212 base::file_handle_mapping_vector fds_mapping; 211 base::FileHandleMappingVector fds_mapping;
213 fds_mapping.push_back(std::make_pair(slave_fd, STDIN_FILENO)); 212 fds_mapping.push_back(std::make_pair(slave_fd, STDIN_FILENO));
214 fds_mapping.push_back(std::make_pair(slave_fd, STDOUT_FILENO)); 213 fds_mapping.push_back(std::make_pair(slave_fd, STDOUT_FILENO));
215 fds_mapping.push_back(std::make_pair(slave_fd, STDERR_FILENO)); 214 fds_mapping.push_back(std::make_pair(slave_fd, STDERR_FILENO));
216 base::LaunchOptions options; 215 base::LaunchOptions options;
217 options.fds_to_remap = &fds_mapping; 216 options.fds_to_remap = &fds_mapping;
218 options.ctrl_terminal_fd = slave_fd; 217 options.ctrl_terminal_fd = slave_fd;
219 218
220 // Launch the process. 219 // Launch the process.
221 return base::LaunchProcess(CommandLine(FilePath(command)), options, pid); 220 return base::LaunchProcess(CommandLine(FilePath(command)), options, pid);
222 } 221 }
(...skipping 18 matching lines...) Expand all
241 240
242 void ProcessProxy::ClearAllFdPairs() { 241 void ProcessProxy::ClearAllFdPairs() {
243 ClearFdPair(pt_pair_); 242 ClearFdPair(pt_pair_);
244 ClearFdPair(shutdown_pipe_); 243 ClearFdPair(shutdown_pipe_);
245 } 244 }
246 245
247 void ProcessProxy::ClearFdPair(int* pipe) { 246 void ProcessProxy::ClearFdPair(int* pipe) {
248 pipe[PIPE_END_READ] = kInvalidFd; 247 pipe[PIPE_END_READ] = kInvalidFd;
249 pipe[PIPE_END_WRITE] = kInvalidFd; 248 pipe[PIPE_END_WRITE] = kInvalidFd;
250 } 249 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/process_proxy/process_proxy.h ('k') | chrome/browser/importer/external_process_importer_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698