summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/extensions/api/image_writer_private/DEPS3
-rw-r--r--chrome/browser/extensions/api/image_writer_private/removable_storage_provider_linux.cc69
-rw-r--r--components/storage_monitor/storage_monitor_linux.cc2
-rw-r--r--components/storage_monitor/udev_util_linux.cc4
-rw-r--r--components/storage_monitor/udev_util_linux.h6
-rw-r--r--content/browser/DEPS4
-rw-r--r--content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc46
-rw-r--r--content/browser/udev_linux.cc20
-rw-r--r--content/browser/udev_linux.h5
-rw-r--r--device/hid/device_monitor_linux.h2
-rw-r--r--device/hid/hid_service_linux.cc4
-rw-r--r--device/serial/serial_device_enumerator_linux.cc18
-rw-r--r--device/serial/serial_device_enumerator_linux.h10
-rw-r--r--device/udev_linux/BUILD.gn3
-rw-r--r--device/udev_linux/scoped_udev.h (renamed from device/udev_linux/udev.h)22
-rw-r--r--device/udev_linux/udev.cc27
-rw-r--r--device/udev_linux/udev.gyp3
-rw-r--r--device/usb/usb_device_impl.cc2
-rw-r--r--ui/events/ozone/device/udev/device_manager_udev.h2
19 files changed, 102 insertions, 150 deletions
diff --git a/chrome/browser/extensions/api/image_writer_private/DEPS b/chrome/browser/extensions/api/image_writer_private/DEPS
new file mode 100644
index 0000000..911cdbe
--- /dev/null
+++ b/chrome/browser/extensions/api/image_writer_private/DEPS
@@ -0,0 +1,3 @@
+include_rules = [
+ "+device/udev_linux",
+]
diff --git a/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_linux.cc b/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_linux.cc
index 787fbdc..cd218b8 100644
--- a/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_linux.cc
+++ b/chrome/browser/extensions/api/image_writer_private/removable_storage_provider_linux.cc
@@ -8,13 +8,14 @@
#include "base/strings/string_number_conversions.h"
#include "chrome/browser/extensions/api/image_writer_private/removable_storage_provider.h"
#include "content/public/browser/browser_thread.h"
+#include "device/udev_linux/scoped_udev.h"
namespace extensions {
// TODO(haven): Udev code may be duplicated in the Chrome codebase.
// https://code.google.com/p/chromium/issues/detail?id=284898
// Returns the integer contained in |attr|. Returns 0 on error.
-static uint64 get_int_attr(const char* attr){
+static uint64 get_int_attr(const char* attr) {
uint64 result = 0;
// In error cases, StringToInt will set result to 0
base::StringToUint64(attr, &result);
@@ -26,8 +27,8 @@ static int get_device_blk_size(const std::string& path) {
std::string device = file_path.BaseName().value();
base::FilePath info_file_path = base::FilePath("/sys/block")
- .Append(device)
- .Append("queue/logical_block_size");
+ .Append(device)
+ .Append("queue/logical_block_size");
std::string file_contents;
int blk_size;
@@ -43,35 +44,34 @@ static int get_device_blk_size(const std::string& path) {
bool RemovableStorageProvider::PopulateDeviceList(
scoped_refptr<StorageDeviceList> device_list) {
- struct udev* udev;
- struct udev_enumerate* enumerate;
- struct udev_list_entry* devices, *dev_list_entry;
- struct udev_device* dev, *parent;
-
- udev = udev_new();
+ device::ScopedUdevPtr udev(udev_new());
if (!udev) {
DLOG(ERROR) << "Can't create udev";
return false;
}
/* Create a list of the devices in the 'block' subsystem. */
- enumerate = udev_enumerate_new(udev);
+ device::ScopedUdevEnumeratePtr enumerate(udev_enumerate_new(udev.get()));
- udev_enumerate_add_match_subsystem(enumerate, "block");
- udev_enumerate_scan_devices(enumerate);
- devices = udev_enumerate_get_list_entry(enumerate);
+ udev_enumerate_add_match_subsystem(enumerate.get(), "block");
+ udev_enumerate_scan_devices(enumerate.get());
+ udev_list_entry* devices = udev_enumerate_get_list_entry(enumerate.get());
+ udev_list_entry* dev_list_entry;
udev_list_entry_foreach(dev_list_entry, devices) {
const char* path = udev_list_entry_get_name(dev_list_entry);
- dev = udev_device_new_from_syspath(udev, path);
+ device::ScopedUdevDevicePtr cur_device(
+ udev_device_new_from_syspath(udev.get(), path));
- const char* partition = udev_device_get_sysattr_value(dev, "partition");
- if (partition && get_int_attr(partition)){
+ const char* partition =
+ udev_device_get_sysattr_value(cur_device.get(), "partition");
+ if (partition && get_int_attr(partition)) {
// This is a partition of a device, not the device itself
continue;
}
- const char* removable = udev_device_get_sysattr_value(dev, "removable");
+ const char* removable =
+ udev_device_get_sysattr_value(cur_device.get(), "removable");
if (!removable || !get_int_attr(removable)) {
// This is not a removable storage device.
continue;
@@ -80,34 +80,29 @@ bool RemovableStorageProvider::PopulateDeviceList(
/* Get the parent SCSI device that contains the model
and manufacturer. You can look at the hierarchy with
udevadm info -a -n /dev/<device> */
- parent = udev_device_get_parent_with_subsystem_devtype(
- dev,
- "scsi",
- NULL);
- if (!parent) {
+ udev_device* parent_device = udev_device_get_parent_with_subsystem_devtype(
+ cur_device.get(), "scsi", NULL);
+ if (!parent_device) {
// this is not a usb device
continue;
}
- linked_ptr<api::image_writer_private::RemovableStorageDevice> device(
- new api::image_writer_private::RemovableStorageDevice());
- device->vendor = udev_device_get_sysattr_value(parent, "vendor");
- device->model = udev_device_get_sysattr_value(parent, "model");
+ linked_ptr<api::image_writer_private::RemovableStorageDevice> device_item(
+ new api::image_writer_private::RemovableStorageDevice());
+ device_item->vendor =
+ udev_device_get_sysattr_value(parent_device, "vendor");
+ device_item->model = udev_device_get_sysattr_value(parent_device, "model");
// TODO (smaskell): Don't expose raw device path
- device->storage_unit_id = udev_device_get_devnode(dev);
- device->capacity = get_int_attr(udev_device_get_sysattr_value(dev, "size"))
- * get_device_blk_size(device->storage_unit_id);
- device->removable = removable;
-
- device_list->data.push_back(device);
+ device_item->storage_unit_id = udev_device_get_devnode(cur_device.get());
+ device_item->capacity =
+ get_int_attr(udev_device_get_sysattr_value(cur_device.get(), "size")) *
+ get_device_blk_size(device_item->storage_unit_id);
+ device_item->removable = removable;
- udev_device_unref(dev);
+ device_list->data.push_back(device_item);
}
- /* Free the enumerator object */
- udev_enumerate_unref(enumerate);
- udev_unref(udev);
return true;
}
-} // namespace extensions
+} // namespace extensions
diff --git a/components/storage_monitor/storage_monitor_linux.cc b/components/storage_monitor/storage_monitor_linux.cc
index 254fd5d..6b57f5c 100644
--- a/components/storage_monitor/storage_monitor_linux.cc
+++ b/components/storage_monitor/storage_monitor_linux.cc
@@ -26,7 +26,7 @@
#include "components/storage_monitor/storage_info.h"
#include "components/storage_monitor/udev_util_linux.h"
#include "device/media_transfer_protocol/media_transfer_protocol_manager.h"
-#include "device/udev_linux/udev.h"
+#include "device/udev_linux/scoped_udev.h"
using content::BrowserThread;
diff --git a/components/storage_monitor/udev_util_linux.cc b/components/storage_monitor/udev_util_linux.cc
index 5a3a117..154f11c 100644
--- a/components/storage_monitor/udev_util_linux.cc
+++ b/components/storage_monitor/udev_util_linux.cc
@@ -5,11 +5,11 @@
#include "components/storage_monitor/udev_util_linux.h"
#include "base/files/file_path.h"
-#include "device/udev_linux/udev.h"
+#include "device/udev_linux/scoped_udev.h"
namespace storage_monitor {
-std::string GetUdevDevicePropertyValue(struct udev_device* udev_device,
+std::string GetUdevDevicePropertyValue(udev_device* udev_device,
const char* key) {
const char* value = udev_device_get_property_value(udev_device, key);
return value ? value : std::string();
diff --git a/components/storage_monitor/udev_util_linux.h b/components/storage_monitor/udev_util_linux.h
index f00048b..76b59ad 100644
--- a/components/storage_monitor/udev_util_linux.h
+++ b/components/storage_monitor/udev_util_linux.h
@@ -5,12 +5,12 @@
#ifndef COMPONENTS_STORAGE_MONITOR_UDEV_UTIL_LINUX_H_
#define COMPONENTS_STORAGE_MONITOR_UDEV_UTIL_LINUX_H_
-#include <libudev.h>
-
#include <string>
#include "base/memory/scoped_ptr.h"
+struct udev_device;
+
namespace base {
class FilePath;
}
@@ -19,7 +19,7 @@ namespace storage_monitor {
// Wrapper function for udev_device_get_property_value() that also checks for
// valid but empty values.
-std::string GetUdevDevicePropertyValue(struct udev_device* udev_device,
+std::string GetUdevDevicePropertyValue(udev_device* udev_device,
const char* key);
// Helper for udev_device_new_from_syspath()/udev_device_get_property_value()
diff --git a/content/browser/DEPS b/content/browser/DEPS
index 715e0d3..742d204 100644
--- a/content/browser/DEPS
+++ b/content/browser/DEPS
@@ -15,6 +15,10 @@ include_rules = [
# above.
"+components/tracing",
+ # In general, //content shouldn't depend on //device.
+ # This is the an exception.
+ "+device/udev_linux", # For udev utility and wrapper library.
+
# Other libraries.
"+third_party/iaccessible2",
"+third_party/isimpledom",
diff --git a/content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc b/content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc
index a211bb6..e99a5e1 100644
--- a/content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc
+++ b/content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc
@@ -20,6 +20,7 @@
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "content/browser/udev_linux.h"
+#include "device/udev_linux/scoped_udev.h"
namespace {
@@ -126,9 +127,7 @@ void GamepadPlatformDataFetcherLinux::RefreshDevice(udev_device* dev) {
// hardware, get the parent device that is also in the "input" subsystem.
// This function should just walk up the tree one level.
dev = udev_device_get_parent_with_subsystem_devtype(
- dev,
- kInputSubsystem,
- NULL);
+ dev, kInputSubsystem, NULL);
if (!dev) {
// Unable to get device information, don't use this device.
device_fd = -1;
@@ -156,10 +155,8 @@ void GamepadPlatformDataFetcherLinux::RefreshDevice(udev_device* dev) {
// as good as the information that the device bus has, walk up further
// to the subsystem/device type "usb"/"usb_device" and if this device
// has the same vendor/product id, prefer the description from that.
- struct udev_device *usb_dev = udev_device_get_parent_with_subsystem_devtype(
- dev,
- kUsbSubsystem,
- kUsbDeviceType);
+ struct udev_device* usb_dev = udev_device_get_parent_with_subsystem_devtype(
+ dev, kUsbSubsystem, kUsbDeviceType);
if (usb_dev) {
const char* usb_vendor_id =
udev_device_get_sysattr_value(usb_dev, "idVendor");
@@ -181,11 +178,11 @@ void GamepadPlatformDataFetcherLinux::RefreshDevice(udev_device* dev) {
// Append the vendor and product information then convert the utf-8
// id string to WebUChar.
- std::string id = name_string + base::StringPrintf(
- " (%sVendor: %s Product: %s)",
- mapper ? "STANDARD GAMEPAD " : "",
- vendor_id,
- product_id);
+ std::string id =
+ name_string + base::StringPrintf(" (%sVendor: %s Product: %s)",
+ mapper ? "STANDARD GAMEPAD " : "",
+ vendor_id,
+ product_id);
base::TruncateUTF8ToByteSize(id, WebGamepad::idLengthCap - 1, &id);
base::string16 tmp16 = base::UTF8ToUTF16(id);
memset(pad.id, 0, sizeof(pad.id));
@@ -193,8 +190,8 @@ void GamepadPlatformDataFetcherLinux::RefreshDevice(udev_device* dev) {
if (mapper) {
std::string mapping = "standard";
- base::TruncateUTF8ToByteSize(mapping, WebGamepad::mappingLengthCap - 1,
- &mapping);
+ base::TruncateUTF8ToByteSize(
+ mapping, WebGamepad::mappingLengthCap - 1, &mapping);
tmp16 = base::UTF8ToUTF16(mapping);
memset(pad.mapping, 0, sizeof(pad.mapping));
tmp16.copy(pad.mapping, arraysize(pad.mapping) - 1);
@@ -207,31 +204,30 @@ void GamepadPlatformDataFetcherLinux::RefreshDevice(udev_device* dev) {
}
void GamepadPlatformDataFetcherLinux::EnumerateDevices() {
- udev_enumerate* enumerate = udev_enumerate_new(udev_->udev_handle());
+ device::ScopedUdevEnumeratePtr enumerate(
+ udev_enumerate_new(udev_->udev_handle()));
if (!enumerate)
return;
- int ret = udev_enumerate_add_match_subsystem(enumerate, kInputSubsystem);
+ int ret =
+ udev_enumerate_add_match_subsystem(enumerate.get(), kInputSubsystem);
if (ret != 0)
return;
- ret = udev_enumerate_scan_devices(enumerate);
+ ret = udev_enumerate_scan_devices(enumerate.get());
if (ret != 0)
return;
- udev_list_entry* devices = udev_enumerate_get_list_entry(enumerate);
- for (udev_list_entry* dev_list_entry = devices;
- dev_list_entry != NULL;
+ udev_list_entry* devices = udev_enumerate_get_list_entry(enumerate.get());
+ for (udev_list_entry* dev_list_entry = devices; dev_list_entry != NULL;
dev_list_entry = udev_list_entry_get_next(dev_list_entry)) {
// Get the filename of the /sys entry for the device and create a
// udev_device object (dev) representing it
const char* path = udev_list_entry_get_name(dev_list_entry);
- udev_device* dev = udev_device_new_from_syspath(udev_->udev_handle(), path);
+ device::ScopedUdevDevicePtr dev(
+ udev_device_new_from_syspath(udev_->udev_handle(), path));
if (!dev)
continue;
- RefreshDevice(dev);
- udev_device_unref(dev);
+ RefreshDevice(dev.get());
}
- // Free the enumerator object
- udev_enumerate_unref(enumerate);
}
void GamepadPlatformDataFetcherLinux::ReadDeviceData(size_t index) {
diff --git a/content/browser/udev_linux.cc b/content/browser/udev_linux.cc
index f6f9443..80c929b 100644
--- a/content/browser/udev_linux.cc
+++ b/content/browser/udev_linux.cc
@@ -13,23 +13,21 @@ namespace content {
UdevLinux::UdevLinux(const std::vector<UdevMonitorFilter>& filters,
const UdevNotificationCallback& callback)
: udev_(udev_new()),
- monitor_(NULL),
+ monitor_(udev_monitor_new_from_netlink(udev_.get(), "udev")),
monitor_fd_(-1),
callback_(callback) {
CHECK(udev_);
-
- monitor_ = udev_monitor_new_from_netlink(udev_, "udev");
CHECK(monitor_);
for (size_t i = 0; i < filters.size(); ++i) {
int ret = udev_monitor_filter_add_match_subsystem_devtype(
- monitor_, filters[i].subsystem, filters[i].devtype);
+ monitor_.get(), filters[i].subsystem, filters[i].devtype);
CHECK_EQ(0, ret);
}
- int ret = udev_monitor_enable_receiving(monitor_);
+ int ret = udev_monitor_enable_receiving(monitor_.get());
CHECK_EQ(0, ret);
- monitor_fd_ = udev_monitor_get_fd(monitor_);
+ monitor_fd_ = udev_monitor_get_fd(monitor_.get());
CHECK_GE(monitor_fd_, 0);
bool success = base::MessageLoopForIO::current()->WatchFileDescriptor(
@@ -43,12 +41,10 @@ UdevLinux::UdevLinux(const std::vector<UdevMonitorFilter>& filters,
UdevLinux::~UdevLinux() {
monitor_watcher_.StopWatchingFileDescriptor();
- udev_monitor_unref(monitor_);
- udev_unref(udev_);
}
udev* UdevLinux::udev_handle() {
- return udev_;
+ return udev_.get();
}
void UdevLinux::OnFileCanReadWithoutBlocking(int fd) {
@@ -56,12 +52,12 @@ void UdevLinux::OnFileCanReadWithoutBlocking(int fd) {
// change state. udev_monitor_receive_device() will return a device object
// representing the device which changed and what type of change occured.
DCHECK_EQ(monitor_fd_, fd);
- udev_device* dev = udev_monitor_receive_device(monitor_);
+ device::ScopedUdevDevicePtr dev(
+ udev_monitor_receive_device(monitor_.get()));
if (!dev)
return;
- callback_.Run(dev);
- udev_device_unref(dev);
+ callback_.Run(dev.get());
}
void UdevLinux::OnFileCanWriteWithoutBlocking(int fd) {
diff --git a/content/browser/udev_linux.h b/content/browser/udev_linux.h
index e62d439..5ced8ce 100644
--- a/content/browser/udev_linux.h
+++ b/content/browser/udev_linux.h
@@ -42,6 +42,7 @@
#include "base/callback.h"
#include "base/compiler_specific.h"
#include "base/message_loop/message_pump_libevent.h"
+#include "device/udev_linux/scoped_udev.h"
extern "C" {
struct udev;
@@ -83,8 +84,8 @@ class UdevLinux : public base::MessagePumpLibevent::Watcher {
// libudev-related items, the main context, and the monitoring context to be
// notified about changes to device states.
- udev* udev_;
- udev_monitor* monitor_;
+ device::ScopedUdevPtr udev_;
+ device::ScopedUdevMonitorPtr monitor_;
int monitor_fd_;
base::MessagePumpLibevent::FileDescriptorWatcher monitor_watcher_;
UdevNotificationCallback callback_;
diff --git a/device/hid/device_monitor_linux.h b/device/hid/device_monitor_linux.h
index 7f5d242..bbf1e52 100644
--- a/device/hid/device_monitor_linux.h
+++ b/device/hid/device_monitor_linux.h
@@ -14,7 +14,7 @@
#include "base/message_loop/message_pump_libevent.h"
#include "base/observer_list.h"
#include "base/threading/thread_checker.h"
-#include "device/udev_linux/udev.h"
+#include "device/udev_linux/scoped_udev.h"
struct udev_device;
diff --git a/device/hid/hid_service_linux.cc b/device/hid/hid_service_linux.cc
index e5fcb52..45688f5 100644
--- a/device/hid/hid_service_linux.cc
+++ b/device/hid/hid_service_linux.cc
@@ -20,7 +20,7 @@
#include "device/hid/hid_connection_linux.h"
#include "device/hid/hid_device_info.h"
#include "device/hid/hid_report_descriptor.h"
-#include "device/udev_linux/udev.h"
+#include "device/udev_linux/scoped_udev.h"
#if defined(OS_CHROMEOS)
#include "base/sys_info.h"
@@ -146,7 +146,7 @@ void HidServiceLinux::OnDeviceAdded(udev_device* device) {
uint32_t int_property = 0;
const char* str_property = NULL;
- udev_device *parent = udev_device_get_parent(device);
+ udev_device* parent = udev_device_get_parent(device);
if (!parent) {
return;
}
diff --git a/device/serial/serial_device_enumerator_linux.cc b/device/serial/serial_device_enumerator_linux.cc
index f2fb9fa..389b8035 100644
--- a/device/serial/serial_device_enumerator_linux.cc
+++ b/device/serial/serial_device_enumerator_linux.cc
@@ -19,19 +19,7 @@ const char kVendorIDKey[] = "ID_VENDOR_ID";
const char kProductIDKey[] = "ID_MODEL_ID";
const char kProductNameKey[] = "ID_MODEL";
-struct UdevEnumerateDeleter {
- void operator()(udev_enumerate* enumerate) {
- udev_enumerate_unref(enumerate);
- }
-};
-
-struct UdevDeviceDeleter {
- void operator()(udev_device* device) { udev_device_unref(device); }
-};
-
-typedef scoped_ptr<udev_enumerate, UdevEnumerateDeleter> ScopedUdevEnumeratePtr;
-typedef scoped_ptr<udev_device, UdevDeviceDeleter> ScopedUdevDevicePtr;
-}
+} // namespace
// static
scoped_ptr<SerialDeviceEnumerator> SerialDeviceEnumerator::Create() {
@@ -100,8 +88,4 @@ mojo::Array<serial::DeviceInfoPtr> SerialDeviceEnumeratorLinux::GetDevices() {
return devices.Pass();
}
-void SerialDeviceEnumeratorLinux::UdevDeleter::operator()(udev* handle) {
- udev_unref(handle);
-}
-
} // namespace device
diff --git a/device/serial/serial_device_enumerator_linux.h b/device/serial/serial_device_enumerator_linux.h
index 71eee69..fe3c3b8 100644
--- a/device/serial/serial_device_enumerator_linux.h
+++ b/device/serial/serial_device_enumerator_linux.h
@@ -5,10 +5,8 @@
#ifndef DEVICE_SERIAL_SERIAL_DEVICE_ENUMERATOR_LINUX_H_
#define DEVICE_SERIAL_SERIAL_DEVICE_ENUMERATOR_LINUX_H_
-#include <libudev.h>
-
-#include "base/memory/scoped_ptr.h"
#include "device/serial/serial_device_enumerator.h"
+#include "device/udev_linux/scoped_udev.h"
namespace device {
@@ -22,11 +20,7 @@ class SerialDeviceEnumeratorLinux : public SerialDeviceEnumerator {
virtual mojo::Array<serial::DeviceInfoPtr> GetDevices() override;
private:
- struct UdevDeleter {
- void operator()(udev* handle);
- };
-
- scoped_ptr<udev, UdevDeleter> udev_;
+ ScopedUdevPtr udev_;
DISALLOW_COPY_AND_ASSIGN(SerialDeviceEnumeratorLinux);
};
diff --git a/device/udev_linux/BUILD.gn b/device/udev_linux/BUILD.gn
index 917a7e5..a32319b 100644
--- a/device/udev_linux/BUILD.gn
+++ b/device/udev_linux/BUILD.gn
@@ -7,8 +7,7 @@ import("//build/config/features.gni")
if (use_udev) {
source_set("udev_linux") {
sources = [
- "udev.cc",
- "udev.h",
+ "scoped_udev.h",
]
deps = [
diff --git a/device/udev_linux/udev.h b/device/udev_linux/scoped_udev.h
index cffb672..54df387 100644
--- a/device/udev_linux/udev.h
+++ b/device/udev_linux/scoped_udev.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef DEVICE_UDEV_LINUX_UDEV_H_
-#define DEVICE_UDEV_LINUX_UDEV_H_
+#ifndef DEVICE_UDEV_LINUX_SCOPED_UDEV_H_
+#define DEVICE_UDEV_LINUX_SCOPED_UDEV_H_
#include <libudev.h>
@@ -16,16 +16,24 @@
namespace device {
struct UdevDeleter {
- void operator()(udev* dev) const;
+ void operator()(udev* dev) const {
+ udev_unref(dev);
+ }
};
struct UdevEnumerateDeleter {
- void operator()(udev_enumerate* enumerate) const;
+ void operator()(udev_enumerate* enumerate) const {
+ udev_enumerate_unref(enumerate);
+ }
};
struct UdevDeviceDeleter {
- void operator()(udev_device* device) const;
+ void operator()(udev_device* device) const {
+ udev_device_unref(device);
+ }
};
struct UdevMonitorDeleter {
- void operator()(udev_monitor* monitor) const;
+ void operator()(udev_monitor* monitor) const {
+ udev_monitor_unref(monitor);
+ }
};
typedef scoped_ptr<udev, UdevDeleter> ScopedUdevPtr;
@@ -35,4 +43,4 @@ typedef scoped_ptr<udev_monitor, UdevMonitorDeleter> ScopedUdevMonitorPtr;
} // namespace device
-#endif // DEVICE_UDEV_LINUX_UDEV_H_
+#endif // DEVICE_UDEV_LINUX_SCOPED_UDEV_H_
diff --git a/device/udev_linux/udev.cc b/device/udev_linux/udev.cc
deleted file mode 100644
index e10074b..0000000
--- a/device/udev_linux/udev.cc
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <libudev.h>
-
-#include "device/udev_linux/udev.h"
-
-namespace device {
-
-void UdevDeleter::operator()(udev* dev) const {
- udev_unref(dev);
-}
-
-void UdevEnumerateDeleter::operator()(udev_enumerate* enumerate) const {
- udev_enumerate_unref(enumerate);
-}
-
-void UdevDeviceDeleter::operator()(udev_device* device) const {
- udev_device_unref(device);
-}
-
-void UdevMonitorDeleter::operator()(udev_monitor* monitor) const {
- udev_monitor_unref(monitor);
-}
-
-} // namespace device
diff --git a/device/udev_linux/udev.gyp b/device/udev_linux/udev.gyp
index 6d142ac..cc43430 100644
--- a/device/udev_linux/udev.gyp
+++ b/device/udev_linux/udev.gyp
@@ -20,8 +20,7 @@
'../..',
],
'sources': [
- 'udev.cc',
- 'udev.h',
+ 'scoped_udev.h',
],
},
],
diff --git a/device/usb/usb_device_impl.cc b/device/usb/usb_device_impl.cc
index 17e9c13..36ddfe7 100644
--- a/device/usb/usb_device_impl.cc
+++ b/device/usb/usb_device_impl.cc
@@ -26,7 +26,7 @@
#endif // defined(OS_CHROMEOS)
#if defined(USE_UDEV)
-#include "device/udev_linux/udev.h"
+#include "device/udev_linux/scoped_udev.h"
#endif // defined(USE_UDEV)
namespace device {
diff --git a/ui/events/ozone/device/udev/device_manager_udev.h b/ui/events/ozone/device/udev/device_manager_udev.h
index 13c76b94..2d01ed8c 100644
--- a/ui/events/ozone/device/udev/device_manager_udev.h
+++ b/ui/events/ozone/device/udev/device_manager_udev.h
@@ -7,7 +7,7 @@
#include "base/message_loop/message_pump_libevent.h"
#include "base/observer_list.h"
-#include "device/udev_linux/udev.h"
+#include "device/udev_linux/scoped_udev.h"
#include "ui/events/ozone/device/device_manager.h"
namespace ui {