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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 if (options.has_cts_flow_control) { | 119 if (options.has_cts_flow_control) { |
120 DCHECK(options_.has_cts_flow_control); | 120 DCHECK(options_.has_cts_flow_control); |
121 options_.cts_flow_control = options.cts_flow_control; | 121 options_.cts_flow_control = options.cts_flow_control; |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 void SerialIoHandler::StartOpen( | 125 void SerialIoHandler::StartOpen( |
126 const std::string& port, | 126 const std::string& port, |
127 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { | 127 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) { |
128 DCHECK(!open_complete_.is_null()); | 128 DCHECK(!open_complete_.is_null()); |
129 DCHECK(file_thread_task_runner_->RunsTasksOnCurrentThread()); | 129 DCHECK(file_thread_task_runner_->RunsTasksInCurrentSequence()); |
130 DCHECK(!file_.IsValid()); | 130 DCHECK(!file_.IsValid()); |
131 // It's the responsibility of the API wrapper around SerialIoHandler to | 131 // It's the responsibility of the API wrapper around SerialIoHandler to |
132 // validate the supplied path against the set of valid port names, and | 132 // validate the supplied path against the set of valid port names, and |
133 // it is a reasonable assumption that serial port names are ASCII. | 133 // it is a reasonable assumption that serial port names are ASCII. |
134 DCHECK(base::IsStringASCII(port)); | 134 DCHECK(base::IsStringASCII(port)); |
135 base::FilePath path(base::FilePath::FromUTF8Unsafe(MaybeFixUpPortName(port))); | 135 base::FilePath path(base::FilePath::FromUTF8Unsafe(MaybeFixUpPortName(port))); |
136 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | | 136 int flags = base::File::FLAG_OPEN | base::File::FLAG_READ | |
137 base::File::FLAG_EXCLUSIVE_READ | base::File::FLAG_WRITE | | 137 base::File::FLAG_EXCLUSIVE_READ | base::File::FLAG_WRITE | |
138 base::File::FLAG_EXCLUSIVE_WRITE | base::File::FLAG_ASYNC | | 138 base::File::FLAG_EXCLUSIVE_WRITE | base::File::FLAG_ASYNC | |
139 base::File::FLAG_TERMINAL_DEVICE; | 139 base::File::FLAG_TERMINAL_DEVICE; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } | 270 } |
271 | 271 |
272 void SerialIoHandler::QueueWriteCompleted(int bytes_written, | 272 void SerialIoHandler::QueueWriteCompleted(int bytes_written, |
273 serial::SendError error) { | 273 serial::SendError error) { |
274 base::ThreadTaskRunnerHandle::Get()->PostTask( | 274 base::ThreadTaskRunnerHandle::Get()->PostTask( |
275 FROM_HERE, | 275 FROM_HERE, |
276 base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error)); | 276 base::Bind(&SerialIoHandler::WriteCompleted, this, bytes_written, error)); |
277 } | 277 } |
278 | 278 |
279 } // namespace device | 279 } // namespace device |
OLD | NEW |