OLD | NEW |
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 "chromeos/process_proxy/process_proxy.h" | 5 #include "chromeos/process_proxy/process_proxy.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <stdlib.h> | 8 #include <stdlib.h> |
9 #include <sys/ioctl.h> | 9 #include <sys/ioctl.h> |
10 | 10 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 153 |
154 CloseAllFdPairs(); | 154 CloseAllFdPairs(); |
155 } | 155 } |
156 | 156 |
157 bool ProcessProxy::Write(const std::string& text) { | 157 bool ProcessProxy::Write(const std::string& text) { |
158 if (!process_launched_) | 158 if (!process_launched_) |
159 return false; | 159 return false; |
160 | 160 |
161 // We don't want to write '\0' to the pipe. | 161 // We don't want to write '\0' to the pipe. |
162 size_t data_size = text.length() * sizeof(*text.c_str()); | 162 size_t data_size = text.length() * sizeof(*text.c_str()); |
163 int bytes_written = | 163 return base::WriteFileDescriptor( |
164 base::WriteFileDescriptor(pt_pair_[PT_MASTER_FD], | 164 pt_pair_[PT_MASTER_FD], text.c_str(), data_size); |
165 text.c_str(), data_size); | |
166 return (bytes_written == static_cast<int>(data_size)); | |
167 } | 165 } |
168 | 166 |
169 bool ProcessProxy::OnTerminalResize(int width, int height) { | 167 bool ProcessProxy::OnTerminalResize(int width, int height) { |
170 if (width < 0 || height < 0) | 168 if (width < 0 || height < 0) |
171 return false; | 169 return false; |
172 | 170 |
173 winsize ws; | 171 winsize ws; |
174 // Number of rows. | 172 // Number of rows. |
175 ws.ws_row = height; | 173 ws.ws_row = height; |
176 // Number of columns. | 174 // Number of columns. |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 ClearFdPair(pt_pair_); | 257 ClearFdPair(pt_pair_); |
260 ClearFdPair(shutdown_pipe_); | 258 ClearFdPair(shutdown_pipe_); |
261 } | 259 } |
262 | 260 |
263 void ProcessProxy::ClearFdPair(int* pipe) { | 261 void ProcessProxy::ClearFdPair(int* pipe) { |
264 pipe[PIPE_END_READ] = kInvalidFd; | 262 pipe[PIPE_END_READ] = kInvalidFd; |
265 pipe[PIPE_END_WRITE] = kInvalidFd; | 263 pipe[PIPE_END_WRITE] = kInvalidFd; |
266 } | 264 } |
267 | 265 |
268 } // namespace chromeos | 266 } // namespace chromeos |
OLD | NEW |