OLD | NEW |
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return false; | 122 return false; |
123 #endif | 123 #endif |
124 } | 124 } |
125 | 125 |
126 } // namespace | 126 } // namespace |
127 | 127 |
128 namespace device { | 128 namespace device { |
129 | 129 |
130 // static | 130 // static |
131 scoped_refptr<SerialIoHandler> SerialIoHandler::Create( | 131 scoped_refptr<SerialIoHandler> SerialIoHandler::Create( |
132 scoped_refptr<base::MessageLoopProxy> file_thread_message_loop, | 132 scoped_refptr<base::SingleThreadTaskRunner> file_thread_message_loop, |
133 scoped_refptr<base::MessageLoopProxy> ui_thread_message_loop) { | 133 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_message_loop) { |
134 return new SerialIoHandlerPosix(file_thread_message_loop, | 134 return new SerialIoHandlerPosix(file_thread_message_loop, |
135 ui_thread_message_loop); | 135 ui_thread_message_loop); |
136 } | 136 } |
137 | 137 |
138 void SerialIoHandlerPosix::RequestAccess( | 138 void SerialIoHandlerPosix::RequestAccess( |
139 const std::string& port, | 139 const std::string& port, |
140 scoped_refptr<base::MessageLoopProxy> file_message_loop, | 140 scoped_refptr<base::SingleThreadTaskRunner> file_message_loop, |
141 scoped_refptr<base::MessageLoopProxy> ui_message_loop) { | 141 scoped_refptr<base::SingleThreadTaskRunner> ui_message_loop) { |
142 #if defined(OS_LINUX) && defined(OS_CHROMEOS) | 142 #if defined(OS_LINUX) && defined(OS_CHROMEOS) |
143 if (base::SysInfo::IsRunningOnChromeOS()) { | 143 if (base::SysInfo::IsRunningOnChromeOS()) { |
144 chromeos::PermissionBrokerClient* client = | 144 chromeos::PermissionBrokerClient* client = |
145 chromeos::DBusThreadManager::Get()->GetPermissionBrokerClient(); | 145 chromeos::DBusThreadManager::Get()->GetPermissionBrokerClient(); |
146 if (!client) { | 146 if (!client) { |
147 DVLOG(1) << "Could not get permission_broker client."; | 147 DVLOG(1) << "Could not get permission_broker client."; |
148 OnRequestAccessComplete(port, false /* failure */); | 148 OnRequestAccessComplete(port, false /* failure */); |
149 return; | 149 return; |
150 } | 150 } |
151 // PermissionBrokerClient should be called on the UI thread. | 151 // PermissionBrokerClient should be called on the UI thread. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 } | 272 } |
273 | 273 |
274 if (tcsetattr(file().GetPlatformFile(), TCSANOW, &config) != 0) { | 274 if (tcsetattr(file().GetPlatformFile(), TCSANOW, &config) != 0) { |
275 VPLOG(1) << "Failed to set port attributes"; | 275 VPLOG(1) << "Failed to set port attributes"; |
276 return false; | 276 return false; |
277 } | 277 } |
278 return true; | 278 return true; |
279 } | 279 } |
280 | 280 |
281 SerialIoHandlerPosix::SerialIoHandlerPosix( | 281 SerialIoHandlerPosix::SerialIoHandlerPosix( |
282 scoped_refptr<base::MessageLoopProxy> file_thread_message_loop, | 282 scoped_refptr<base::SingleThreadTaskRunner> file_thread_message_loop, |
283 scoped_refptr<base::MessageLoopProxy> ui_thread_message_loop) | 283 scoped_refptr<base::SingleThreadTaskRunner> ui_thread_message_loop) |
284 : SerialIoHandler(file_thread_message_loop, ui_thread_message_loop), | 284 : SerialIoHandler(file_thread_message_loop, ui_thread_message_loop), |
285 is_watching_reads_(false), | 285 is_watching_reads_(false), |
286 is_watching_writes_(false) { | 286 is_watching_writes_(false) { |
287 } | 287 } |
288 | 288 |
289 SerialIoHandlerPosix::~SerialIoHandlerPosix() { | 289 SerialIoHandlerPosix::~SerialIoHandlerPosix() { |
290 } | 290 } |
291 | 291 |
292 void SerialIoHandlerPosix::OnFileCanReadWithoutBlocking(int fd) { | 292 void SerialIoHandlerPosix::OnFileCanReadWithoutBlocking(int fd) { |
293 DCHECK(CalledOnValidThread()); | 293 DCHECK(CalledOnValidThread()); |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 (config.c_cflag & CSTOPB) ? serial::STOP_BITS_TWO : serial::STOP_BITS_ONE; | 454 (config.c_cflag & CSTOPB) ? serial::STOP_BITS_TWO : serial::STOP_BITS_ONE; |
455 info->cts_flow_control = (config.c_cflag & CRTSCTS) != 0; | 455 info->cts_flow_control = (config.c_cflag & CRTSCTS) != 0; |
456 return info.Pass(); | 456 return info.Pass(); |
457 } | 457 } |
458 | 458 |
459 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) { | 459 std::string SerialIoHandler::MaybeFixUpPortName(const std::string& port_name) { |
460 return port_name; | 460 return port_name; |
461 } | 461 } |
462 | 462 |
463 } // namespace device | 463 } // namespace device |
OLD | NEW |