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

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

Issue 614893004: Refactor AppendToFile and WriteFileDescriptor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address nits Created 6 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 (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
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
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
OLDNEW
« no previous file with comments | « chromeos/process_proxy/process_output_watcher_unittest.cc ('k') | components/metrics/serialization/serialization_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698