| 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_device_enumerator_linux.h" | 5 #include "device/serial/serial_device_enumerator_linux.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 | 9 |
| 10 namespace device { | 10 namespace device { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 return scoped_ptr<SerialDeviceEnumerator>(new SerialDeviceEnumeratorLinux()); | 38 return scoped_ptr<SerialDeviceEnumerator>(new SerialDeviceEnumeratorLinux()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 SerialDeviceEnumeratorLinux::SerialDeviceEnumeratorLinux() { | 41 SerialDeviceEnumeratorLinux::SerialDeviceEnumeratorLinux() { |
| 42 udev_.reset(udev_new()); | 42 udev_.reset(udev_new()); |
| 43 } | 43 } |
| 44 | 44 |
| 45 SerialDeviceEnumeratorLinux::~SerialDeviceEnumeratorLinux() {} | 45 SerialDeviceEnumeratorLinux::~SerialDeviceEnumeratorLinux() {} |
| 46 | 46 |
| 47 mojo::Array<serial::DeviceInfoPtr> SerialDeviceEnumeratorLinux::GetDevices() { | 47 mojo::Array<serial::DeviceInfoPtr> SerialDeviceEnumeratorLinux::GetDevices() { |
| 48 mojo::Array<serial::DeviceInfoPtr> devices; | 48 mojo::Array<serial::DeviceInfoPtr> devices(0); |
| 49 ScopedUdevEnumeratePtr enumerate(udev_enumerate_new(udev_.get())); | 49 ScopedUdevEnumeratePtr enumerate(udev_enumerate_new(udev_.get())); |
| 50 if (!enumerate) { | 50 if (!enumerate) { |
| 51 LOG(ERROR) << "Serial device enumeration failed."; | 51 LOG(ERROR) << "Serial device enumeration failed."; |
| 52 return devices.Pass(); | 52 return devices.Pass(); |
| 53 } | 53 } |
| 54 if (udev_enumerate_add_match_subsystem(enumerate.get(), kSerialSubsystem)) { | 54 if (udev_enumerate_add_match_subsystem(enumerate.get(), kSerialSubsystem)) { |
| 55 LOG(ERROR) << "Serial device enumeration failed."; | 55 LOG(ERROR) << "Serial device enumeration failed."; |
| 56 return devices.Pass(); | 56 return devices.Pass(); |
| 57 } | 57 } |
| 58 if (udev_enumerate_scan_devices(enumerate.get())) { | 58 if (udev_enumerate_scan_devices(enumerate.get())) { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 return devices.Pass(); | 100 return devices.Pass(); |
| 101 } | 101 } |
| 102 | 102 |
| 103 void SerialDeviceEnumeratorLinux::UdevDeleter::operator()(udev* handle) { | 103 void SerialDeviceEnumeratorLinux::UdevDeleter::operator()(udev* handle) { |
| 104 udev_unref(handle); | 104 udev_unref(handle); |
| 105 } | 105 } |
| 106 | 106 |
| 107 } // namespace device | 107 } // namespace device |
| OLD | NEW |