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

Unified Diff: content/browser/gamepad/gamepad_platform_data_fetcher_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, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/DEPS ('k') | content/browser/udev_linux.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc
diff --git a/content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc b/content/browser/gamepad/gamepad_platform_data_fetcher_linux.cc
index a211bb67df1444114db0a83b5406b4b977e38cc1..e99a5e15904c1f52e2a188d738fea9b1a4ae87ca 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) {
« no previous file with comments | « content/browser/DEPS ('k') | content/browser/udev_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698