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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 mojo::InterfaceRequest<serial::DataSource> source, | 65 mojo::InterfaceRequest<serial::DataSource> source, |
66 mojo::InterfacePtr<serial::DataSourceClient> source_client) { | 66 mojo::InterfacePtr<serial::DataSourceClient> source_client) { |
67 if (!IsValidPath(path)) | 67 if (!IsValidPath(path)) |
68 return; | 68 return; |
69 connection_factory_->CreateConnection(path, options.Pass(), | 69 connection_factory_->CreateConnection(path, options.Pass(), |
70 connection_request.Pass(), sink.Pass(), | 70 connection_request.Pass(), sink.Pass(), |
71 source.Pass(), source_client.Pass()); | 71 source.Pass(), source_client.Pass()); |
72 } | 72 } |
73 | 73 |
74 SerialDeviceEnumerator* SerialServiceImpl::GetDeviceEnumerator() { | 74 SerialDeviceEnumerator* SerialServiceImpl::GetDeviceEnumerator() { |
| 75 #if !defined(OS_ANDROID) |
75 if (!device_enumerator_) | 76 if (!device_enumerator_) |
76 device_enumerator_ = SerialDeviceEnumerator::Create(); | 77 device_enumerator_ = SerialDeviceEnumerator::Create(); |
77 return device_enumerator_.get(); | 78 return device_enumerator_.get(); |
| 79 #else |
| 80 NOTIMPLEMENTED(); |
| 81 return nullptr; |
| 82 #endif |
78 } | 83 } |
79 | 84 |
80 bool SerialServiceImpl::IsValidPath(const mojo::String& path) { | 85 bool SerialServiceImpl::IsValidPath(const mojo::String& path) { |
81 mojo::Array<serial::DeviceInfoPtr> devices( | 86 mojo::Array<serial::DeviceInfoPtr> devices( |
82 GetDeviceEnumerator()->GetDevices()); | 87 GetDeviceEnumerator()->GetDevices()); |
83 for (size_t i = 0; i < devices.size(); i++) { | 88 for (size_t i = 0; i < devices.size(); i++) { |
84 if (path == devices[i]->path) | 89 if (path == devices[i]->path) |
85 return true; | 90 return true; |
86 } | 91 } |
87 return false; | 92 return false; |
88 } | 93 } |
89 | 94 |
90 } // namespace device | 95 } // namespace device |
OLD | NEW |