Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: device/serial/serial_device_enumerator_linux.cc

Issue 363853003: Add a basic Mojo SerialService that implements GetDevices(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « device/serial/serial.mojom ('k') | device/serial/serial_device_enumerator_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « device/serial/serial.mojom ('k') | device/serial/serial_device_enumerator_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698