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

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

Issue 666653002: Cleanup: Merge device/udev_linux/udev.{cc,h} into device/udev_linux/scoped_udev.h. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 1 month 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
« no previous file with comments | « device/serial/serial_device_enumerator_linux.h ('k') | device/udev_linux/BUILD.gn » ('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 {
11 11
12 namespace { 12 namespace {
13 13
14 const char kSerialSubsystem[] = "tty"; 14 const char kSerialSubsystem[] = "tty";
15 15
16 const char kHostPathKey[] = "DEVNAME"; 16 const char kHostPathKey[] = "DEVNAME";
17 const char kHostBusKey[] = "ID_BUS"; 17 const char kHostBusKey[] = "ID_BUS";
18 const char kVendorIDKey[] = "ID_VENDOR_ID"; 18 const char kVendorIDKey[] = "ID_VENDOR_ID";
19 const char kProductIDKey[] = "ID_MODEL_ID"; 19 const char kProductIDKey[] = "ID_MODEL_ID";
20 const char kProductNameKey[] = "ID_MODEL"; 20 const char kProductNameKey[] = "ID_MODEL";
21 21
22 struct UdevEnumerateDeleter { 22 } // namespace
23 void operator()(udev_enumerate* enumerate) {
24 udev_enumerate_unref(enumerate);
25 }
26 };
27
28 struct UdevDeviceDeleter {
29 void operator()(udev_device* device) { udev_device_unref(device); }
30 };
31
32 typedef scoped_ptr<udev_enumerate, UdevEnumerateDeleter> ScopedUdevEnumeratePtr;
33 typedef scoped_ptr<udev_device, UdevDeviceDeleter> ScopedUdevDevicePtr;
34 }
35 23
36 // static 24 // static
37 scoped_ptr<SerialDeviceEnumerator> SerialDeviceEnumerator::Create() { 25 scoped_ptr<SerialDeviceEnumerator> SerialDeviceEnumerator::Create() {
38 return scoped_ptr<SerialDeviceEnumerator>(new SerialDeviceEnumeratorLinux()); 26 return scoped_ptr<SerialDeviceEnumerator>(new SerialDeviceEnumeratorLinux());
39 } 27 }
40 28
41 SerialDeviceEnumeratorLinux::SerialDeviceEnumeratorLinux() { 29 SerialDeviceEnumeratorLinux::SerialDeviceEnumeratorLinux() {
42 udev_.reset(udev_new()); 30 udev_.reset(udev_new());
43 } 31 }
44 32
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 info->has_product_id = true; 81 info->has_product_id = true;
94 } 82 }
95 if (product_name) 83 if (product_name)
96 info->display_name = product_name; 84 info->display_name = product_name;
97 devices.push_back(info.Pass()); 85 devices.push_back(info.Pass());
98 } 86 }
99 } 87 }
100 return devices.Pass(); 88 return devices.Pass();
101 } 89 }
102 90
103 void SerialDeviceEnumeratorLinux::UdevDeleter::operator()(udev* handle) {
104 udev_unref(handle);
105 }
106
107 } // namespace device 91 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/serial_device_enumerator_linux.h ('k') | device/udev_linux/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698