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

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

Issue 9121035: [hterm:crosh] Add support for terminal window resizing to terminal API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 11 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> 7 #include <cstdio>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include <sys/ioctl.h> 10 #include <sys/ioctl.h>
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 return false; 149 return false;
150 150
151 // We don't want to write '\0' to the pipe. 151 // We don't want to write '\0' to the pipe.
152 size_t data_size = text.length() * sizeof(*text.c_str()); 152 size_t data_size = text.length() * sizeof(*text.c_str());
153 int bytes_written = 153 int bytes_written =
154 file_util::WriteFileDescriptor(pt_pair_[PT_MASTER_FD], 154 file_util::WriteFileDescriptor(pt_pair_[PT_MASTER_FD],
155 text.c_str(), data_size); 155 text.c_str(), data_size);
156 return (bytes_written == static_cast<int>(data_size)); 156 return (bytes_written == static_cast<int>(data_size));
157 } 157 }
158 158
159 bool ProcessProxy::OnTerminalResize(int width, int height) {
160 if (width < 0 || height < 0)
tbarzic 2012/01/27 04:14:27 we might check upper bound, too (but I'm not sure
rginda 2012/02/06 22:49:43 I'm not sure it makes sense to set an upper bound.
161 return false;
162
163 winsize ws;
164 // Number of rows.
165 ws.ws_row = height;
166 // Number of columns.
167 ws.ws_col = width;
168
169 return (HANDLE_EINTR(ioctl(pt_pair_[PT_MASTER_FD], TIOCSWINSZ, &ws)) != -1);
170 }
171
159 ProcessProxy::~ProcessProxy() { 172 ProcessProxy::~ProcessProxy() {
160 // In case watcher did not started, we may get deleted without calling Close. 173 // In case watcher did not started, we may get deleted without calling Close.
161 // In that case we have to clean up created pipes. If watcher had been 174 // In that case we have to clean up created pipes. If watcher had been
162 // started, there will be a callback with our reference owned by 175 // started, there will be a callback with our reference owned by
163 // process_output_watcher until Close is called, so we know Close has been 176 // process_output_watcher until Close is called, so we know Close has been
164 // called by now (and pipes have been cleaned). 177 // called by now (and pipes have been cleaned).
165 if (!watcher_started_) 178 if (!watcher_started_)
166 CloseAllFdPairs(); 179 CloseAllFdPairs();
167 } 180 }
168 181
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 241
229 void ProcessProxy::ClearAllFdPairs() { 242 void ProcessProxy::ClearAllFdPairs() {
230 ClearFdPair(pt_pair_); 243 ClearFdPair(pt_pair_);
231 ClearFdPair(shutdown_pipe_); 244 ClearFdPair(shutdown_pipe_);
232 } 245 }
233 246
234 void ProcessProxy::ClearFdPair(int* pipe) { 247 void ProcessProxy::ClearFdPair(int* pipe) {
235 pipe[PIPE_END_READ] = kInvalidFd; 248 pipe[PIPE_END_READ] = kInvalidFd;
236 pipe[PIPE_END_WRITE] = kInvalidFd; 249 pipe[PIPE_END_WRITE] = kInvalidFd;
237 } 250 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/process_proxy/process_proxy.h ('k') | chrome/browser/chromeos/process_proxy/process_proxy_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698