| 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.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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |