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_service_impl.h" | 5 #include "device/serial/serial_service_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "device/serial/serial_io_handler.h" | 9 #include "device/serial/serial_io_handler.h" |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 void SerialServiceImpl::GetDevices( | 54 void SerialServiceImpl::GetDevices( |
55 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) { | 55 const mojo::Callback<void(mojo::Array<serial::DeviceInfoPtr>)>& callback) { |
56 callback.Run(GetDeviceEnumerator()->GetDevices()); | 56 callback.Run(GetDeviceEnumerator()->GetDevices()); |
57 } | 57 } |
58 | 58 |
59 void SerialServiceImpl::Connect( | 59 void SerialServiceImpl::Connect( |
60 const mojo::String& path, | 60 const mojo::String& path, |
61 serial::ConnectionOptionsPtr options, | 61 serial::ConnectionOptionsPtr options, |
62 mojo::InterfaceRequest<serial::Connection> connection_request, | 62 mojo::InterfaceRequest<serial::Connection> connection_request, |
63 mojo::InterfaceRequest<serial::DataSink> sink, | 63 mojo::InterfaceRequest<serial::DataSink> sink, |
64 mojo::InterfaceRequest<serial::DataSource> source) { | 64 mojo::InterfaceRequest<serial::DataSource> source, |
| 65 mojo::InterfacePtr<serial::DataSourceClient> source_client) { |
65 if (!IsValidPath(path)) | 66 if (!IsValidPath(path)) |
66 return; | 67 return; |
67 connection_factory_->CreateConnection(path, | 68 connection_factory_->CreateConnection(path, options.Pass(), |
68 options.Pass(), | 69 connection_request.Pass(), sink.Pass(), |
69 connection_request.Pass(), | 70 source.Pass(), source_client.Pass()); |
70 sink.Pass(), | |
71 source.Pass()); | |
72 } | 71 } |
73 | 72 |
74 SerialDeviceEnumerator* SerialServiceImpl::GetDeviceEnumerator() { | 73 SerialDeviceEnumerator* SerialServiceImpl::GetDeviceEnumerator() { |
75 if (!device_enumerator_) | 74 if (!device_enumerator_) |
76 device_enumerator_ = SerialDeviceEnumerator::Create(); | 75 device_enumerator_ = SerialDeviceEnumerator::Create(); |
77 return device_enumerator_.get(); | 76 return device_enumerator_.get(); |
78 } | 77 } |
79 | 78 |
80 bool SerialServiceImpl::IsValidPath(const mojo::String& path) { | 79 bool SerialServiceImpl::IsValidPath(const mojo::String& path) { |
81 mojo::Array<serial::DeviceInfoPtr> devices( | 80 mojo::Array<serial::DeviceInfoPtr> devices( |
82 GetDeviceEnumerator()->GetDevices()); | 81 GetDeviceEnumerator()->GetDevices()); |
83 for (size_t i = 0; i < devices.size(); i++) { | 82 for (size_t i = 0; i < devices.size(); i++) { |
84 if (path == devices[i]->path) | 83 if (path == devices[i]->path) |
85 return true; | 84 return true; |
86 } | 85 } |
87 return false; | 86 return false; |
88 } | 87 } |
89 | 88 |
90 } // namespace device | 89 } // namespace device |
OLD | NEW |