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_connection_factory.h" | 5 #include "device/serial/serial_connection_factory.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "device/serial/serial_connection.h" | 12 #include "device/serial/serial_connection.h" |
13 #include "device/serial/serial_io_handler.h" | 13 #include "device/serial/serial_io_handler.h" |
| 14 #include "mojo/public/cpp/bindings/strong_binding.h" |
14 | 15 |
15 namespace device { | 16 namespace device { |
16 namespace { | 17 namespace { |
17 | 18 |
18 void FillDefaultConnectionOptions(serial::ConnectionOptions* options) { | 19 void FillDefaultConnectionOptions(serial::ConnectionOptions* options) { |
19 if (!options->bitrate) | 20 if (!options->bitrate) |
20 options->bitrate = 9600; | 21 options->bitrate = 9600; |
21 if (options->data_bits == serial::DataBits::NONE) | 22 if (options->data_bits == serial::DataBits::NONE) |
22 options->data_bits = serial::DataBits::EIGHT; | 23 options->data_bits = serial::DataBits::EIGHT; |
23 if (options->stop_bits == serial::StopBits::NONE) | 24 if (options->stop_bits == serial::StopBits::NONE) |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 path_, *options_, | 122 path_, *options_, |
122 base::Bind(&SerialConnectionFactory::ConnectTask::OnConnected, this)); | 123 base::Bind(&SerialConnectionFactory::ConnectTask::OnConnected, this)); |
123 } | 124 } |
124 | 125 |
125 void SerialConnectionFactory::ConnectTask::OnConnected(bool success) { | 126 void SerialConnectionFactory::ConnectTask::OnConnected(bool success) { |
126 DCHECK(io_handler_.get()); | 127 DCHECK(io_handler_.get()); |
127 if (!success) { | 128 if (!success) { |
128 return; | 129 return; |
129 } | 130 } |
130 | 131 |
131 new SerialConnection(io_handler_, std::move(sink_), std::move(source_), | 132 mojo::MakeStrongBinding(base::MakeUnique<SerialConnection>( |
132 mojo::MakeProxy(std::move(source_client_)), | 133 io_handler_, std::move(sink_), std::move(source_), |
133 std::move(connection_request_)); | 134 mojo::MakeProxy(std::move(source_client_))), |
| 135 std::move(connection_request_)); |
134 } | 136 } |
135 | 137 |
136 } // namespace device | 138 } // namespace device |
OLD | NEW |