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

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

Issue 2501613002: 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 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 if (!file.IsValid()) { 167 if (!file.IsValid()) {
168 LOG(ERROR) << "Failed to open serial port: " 168 LOG(ERROR) << "Failed to open serial port: "
169 << base::File::ErrorToString(file.error_details()); 169 << base::File::ErrorToString(file.error_details());
170 callback.Run(false); 170 callback.Run(false);
171 return; 171 return;
172 } 172 }
173 173
174 file_ = std::move(file); 174 file_ = std::move(file);
175 175
176 bool success = PostOpen() && ConfigurePortImpl(); 176 bool success = PostOpen() && ConfigurePortImpl();
177 if (!success) { 177 if (!success)
178 Close(); 178 Close();
179 }
180 179
181 callback.Run(success); 180 callback.Run(success);
182 } 181 }
183 182
184 bool SerialIoHandler::PostOpen() { 183 bool SerialIoHandler::PostOpen() {
185 return true; 184 return true;
186 } 185 }
187 186
188 void SerialIoHandler::Close() { 187 void SerialIoHandler::Close() {
189 if (file_.IsValid()) { 188 if (file_.IsValid()) {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 } 286 }
288 287
289 void SerialIoHandler::QueueWriteCompleted(int bytes_written, 288 void SerialIoHandler::QueueWriteCompleted(int bytes_written,
290 serial::SendError error) { 289 serial::SendError error) {
291 base::ThreadTaskRunnerHandle::Get()->PostTask( 290 base::ThreadTaskRunnerHandle::Get()->PostTask(
292 FROM_HERE, 291 FROM_HERE,
293 base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error)); 292 base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error));
294 } 293 }
295 294
296 } // namespace device 295 } // 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