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

Unified Diff: device/hid/hid_service_mac.cc

Issue 1025553004: Switch HidDeviceId from IORegistry path to IORegistry entry ID. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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 | « device/hid/hid_device_info.cc ('k') | extensions/browser/api/hid/hid_apitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/hid_service_mac.cc
diff --git a/device/hid/hid_service_mac.cc b/device/hid/hid_service_mac.cc
index dec4e70a1153e0b7e476a0dc7349afc38784aa48..fb12d96eae1d0d54f9b118f8e0d797bd1db4aca2 100644
--- a/device/hid/hid_service_mac.cc
+++ b/device/hid/hid_service_mac.cc
@@ -140,12 +140,13 @@ void HidServiceMac::Connect(const HidDeviceId& device_id,
}
scoped_refptr<HidDeviceInfo> device_info = map_entry->second;
- io_string_t service_path;
- strncpy(service_path, device_id.c_str(), sizeof service_path);
+ base::ScopedCFTypeRef<CFDictionaryRef> matching_dict(
+ IORegistryEntryIDMatching(device_id));
+
base::mac::ScopedIOObject<io_service_t> service(
- IORegistryEntryFromPath(kIOMasterPortDefault, service_path));
+ IOServiceGetMatchingService(kIOMasterPortDefault, matching_dict.get()));
if (!service.get()) {
- HID_LOG(EVENT) << "IOService not found for path: " << device_id;
+ HID_LOG(EVENT) << "IOService not found for ID: " << device_id;
task_runner_->PostTask(FROM_HERE, base::Bind(callback, nullptr));
return;
}
@@ -212,11 +213,10 @@ void HidServiceMac::RemoveDevices() {
io_service_t device;
while ((device = IOIteratorNext(devices_removed_iterator_)) !=
IO_OBJECT_NULL) {
- io_string_t service_path;
- IOReturn result =
- IORegistryEntryGetPath(device, kIOServicePlane, service_path);
+ uint64_t entry_id;
+ IOReturn result = IORegistryEntryGetRegistryEntryID(device, &entry_id);
if (result == kIOReturnSuccess) {
- RemoveDevice(service_path);
+ RemoveDevice(entry_id);
}
// Release reference retained by AddDevices above.
@@ -229,32 +229,30 @@ void HidServiceMac::RemoveDevices() {
// static
scoped_refptr<HidDeviceInfo> HidServiceMac::CreateDeviceInfo(
io_service_t service) {
- io_string_t service_path;
- IOReturn result =
- IORegistryEntryGetPath(service, kIOServicePlane, service_path);
+ uint64_t entry_id;
+ IOReturn result = IORegistryEntryGetRegistryEntryID(service, &entry_id);
if (result != kIOReturnSuccess) {
- HID_LOG(EVENT) << "Failed to get IOService path: " << HexErrorCode(result);
+ HID_LOG(EVENT) << "Failed to get IORegistryEntry ID: "
+ << HexErrorCode(result);
return nullptr;
}
base::ScopedCFTypeRef<IOHIDDeviceRef> hid_device(
IOHIDDeviceCreate(kCFAllocatorDefault, service));
if (!hid_device) {
- HID_LOG(EVENT) << "Unable to create IOHIDDevice object for " << service_path
- << ".";
+ HID_LOG(EVENT) << "Unable to create IOHIDDevice object for new device.";
return nullptr;
}
std::vector<uint8> report_descriptor;
if (!TryGetHidDataProperty(hid_device, CFSTR(kIOHIDReportDescriptorKey),
&report_descriptor)) {
- HID_LOG(EVENT) << "Unable to get report descriptor for " << service_path
- << ".";
+ HID_LOG(EVENT) << "Unable to get report descriptor for new device.";
return nullptr;
}
return new HidDeviceInfo(
- service_path, GetHidIntProperty(hid_device, CFSTR(kIOHIDVendorIDKey)),
+ entry_id, GetHidIntProperty(hid_device, CFSTR(kIOHIDVendorIDKey)),
GetHidIntProperty(hid_device, CFSTR(kIOHIDProductIDKey)),
GetHidStringProperty(hid_device, CFSTR(kIOHIDProductKey)),
GetHidStringProperty(hid_device, CFSTR(kIOHIDSerialNumberKey)),
« no previous file with comments | « device/hid/hid_device_info.cc ('k') | extensions/browser/api/hid/hid_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698