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

Side by Side Diff: device/serial/serial_io_handler_posix.cc

Issue 401563002: Add a partial Mojo serial connection interface and implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 years, 5 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
« no previous file with comments | « device/serial/serial_io_handler_posix.h ('k') | device/serial/serial_io_handler_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "device/serial/serial_io_handler_posix.h" 5 #include "device/serial/serial_io_handler_posix.h"
6 6
7 #include <sys/ioctl.h> 7 #include <sys/ioctl.h>
8 #include <termios.h> 8 #include <termios.h>
9 9
10 #include "base/posix/eintr_wrapper.h" 10 #include "base/posix/eintr_wrapper.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 #else 115 #else
116 return false; 116 return false;
117 #endif 117 #endif
118 } 118 }
119 119
120 } // namespace 120 } // namespace
121 121
122 namespace device { 122 namespace device {
123 123
124 // static 124 // static
125 scoped_refptr<SerialIoHandler> SerialIoHandler::Create() { 125 scoped_refptr<SerialIoHandler> SerialIoHandler::Create(
126 return new SerialIoHandlerPosix(); 126 scoped_refptr<base::MessageLoopProxy> file_thread_message_loop) {
127 return new SerialIoHandlerPosix(file_thread_message_loop);
127 } 128 }
128 129
129 void SerialIoHandlerPosix::ReadImpl() { 130 void SerialIoHandlerPosix::ReadImpl() {
130 DCHECK(CalledOnValidThread()); 131 DCHECK(CalledOnValidThread());
131 DCHECK(pending_read_buffer()); 132 DCHECK(pending_read_buffer());
132 DCHECK(file().IsValid()); 133 DCHECK(file().IsValid());
133 134
134 EnsureWatchingReads(); 135 EnsureWatchingReads();
135 } 136 }
136 137
(...skipping 12 matching lines...) Expand all
149 QueueReadCompleted(0, read_cancel_reason()); 150 QueueReadCompleted(0, read_cancel_reason());
150 } 151 }
151 152
152 void SerialIoHandlerPosix::CancelWriteImpl() { 153 void SerialIoHandlerPosix::CancelWriteImpl() {
153 DCHECK(CalledOnValidThread()); 154 DCHECK(CalledOnValidThread());
154 is_watching_writes_ = false; 155 is_watching_writes_ = false;
155 file_write_watcher_.StopWatchingFileDescriptor(); 156 file_write_watcher_.StopWatchingFileDescriptor();
156 QueueWriteCompleted(0, write_cancel_reason()); 157 QueueWriteCompleted(0, write_cancel_reason());
157 } 158 }
158 159
159 SerialIoHandlerPosix::SerialIoHandlerPosix() 160 SerialIoHandlerPosix::SerialIoHandlerPosix(
160 : is_watching_reads_(false), is_watching_writes_(false) { 161 scoped_refptr<base::MessageLoopProxy> file_thread_message_loop)
162 : SerialIoHandler(file_thread_message_loop),
163 is_watching_reads_(false),
164 is_watching_writes_(false) {
161 } 165 }
162 166
163 SerialIoHandlerPosix::~SerialIoHandlerPosix() { 167 SerialIoHandlerPosix::~SerialIoHandlerPosix() {
164 } 168 }
165 169
166 void SerialIoHandlerPosix::OnFileCanReadWithoutBlocking(int fd) { 170 void SerialIoHandlerPosix::OnFileCanReadWithoutBlocking(int fd) {
167 DCHECK(CalledOnValidThread()); 171 DCHECK(CalledOnValidThread());
168 DCHECK_EQ(fd, file().GetPlatformFile()); 172 DCHECK_EQ(fd, file().GetPlatformFile());
169 173
170 if (pending_read_buffer()) { 174 if (pending_read_buffer()) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 (config.c_cflag & CSTOPB) ? serial::STOP_BITS_TWO : serial::STOP_BITS_ONE; 403 (config.c_cflag & CSTOPB) ? serial::STOP_BITS_TWO : serial::STOP_BITS_ONE;
400 info->cts_flow_control = (config.c_cflag & CRTSCTS) != 0; 404 info->cts_flow_control = (config.c_cflag & CRTSCTS) != 0;
401 return info.Pass(); 405 return info.Pass();
402 } 406 }
403 407
404 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) { 408 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) {
405 return port_name; 409 return port_name;
406 } 410 }
407 411
408 } // namespace device 412 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/serial_io_handler_posix.h ('k') | device/serial/serial_io_handler_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698