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

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

Issue 2494513002: Explicitly put serial port fd in non-blocking mode on Chrome OS. (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | device/serial/serial_io_handler_posix.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.h" 5 #include "device/serial/serial_io_handler.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (!file.IsValid()) { 151 if (!file.IsValid()) {
152 LOG(ERROR) << "Failed to open serial port: " 152 LOG(ERROR) << "Failed to open serial port: "
153 << base::File::ErrorToString(file.error_details()); 153 << base::File::ErrorToString(file.error_details());
154 callback.Run(false); 154 callback.Run(false);
155 return; 155 return;
156 } 156 }
157 157
158 file_ = std::move(file); 158 file_ = std::move(file);
159 159
160 bool success = PostOpen() && ConfigurePortImpl(); 160 bool success = PostOpen() && ConfigurePortImpl();
161 if (!success) { 161 if (!success)
162 Close(); 162 Close();
163 }
164 163
165 callback.Run(success); 164 callback.Run(success);
166 } 165 }
167 166
168 bool SerialIoHandler::PostOpen() { 167 bool SerialIoHandler::PostOpen() {
169 return true; 168 return true;
170 } 169 }
171 170
172 void SerialIoHandler::Close() { 171 void SerialIoHandler::Close() {
173 if (file_.IsValid()) { 172 if (file_.IsValid()) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 270 }
272 271
273 void SerialIoHandler::QueueWriteCompleted(int bytes_written, 272 void SerialIoHandler::QueueWriteCompleted(int bytes_written,
274 serial::SendError error) { 273 serial::SendError error) {
275 base::ThreadTaskRunnerHandle::Get()->PostTask( 274 base::ThreadTaskRunnerHandle::Get()->PostTask(
276 FROM_HERE, 275 FROM_HERE,
277 base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error)); 276 base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error));
278 } 277 }
279 278
280 } // namespace device 279 } // namespace device
OLDNEW
« no previous file with comments | « no previous file | device/serial/serial_io_handler_posix.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698