| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |