Chromium Code Reviews| Index: device/hid/hid_utils_mac.cc |
| diff --git a/device/hid/hid_utils_mac.cc b/device/hid/hid_utils_mac.cc |
| index 588041a3ccb2b3c614b29c413236302d2af731fb..3750db95d47f0af67594d7539a3f55d978f77420 100644 |
| --- a/device/hid/hid_utils_mac.cc |
| +++ b/device/hid/hid_utils_mac.cc |
| @@ -16,17 +16,30 @@ |
| namespace device { |
| -bool GetHidIntProperty(IOHIDDeviceRef device, |
| - CFStringRef key, |
| - int32_t* result) { |
| +int32_t GetHidIntProperty(IOHIDDeviceRef device, CFStringRef key) { |
| + int32_t value; |
| + if (TryGetHidIntProperty(device, key, &value)) |
| + return value; |
| + return 0; |
| +} |
| + |
| +std::string GetHidStringProperty(IOHIDDeviceRef device, CFStringRef key) { |
| + std::string value; |
| + TryGetHidStringProperty(device, key, &value); |
| + return value; |
| +} |
| + |
| +bool TryGetHidIntProperty(IOHIDDeviceRef device, |
| + CFStringRef key, |
| + int32_t* result) { |
| CFNumberRef ref = base::mac::CFCast<CFNumberRef>( |
|
Mark Mentovai
2014/02/13 22:37:51
You might think this is crazy-paranoid (and we can
Ken Rockot(use gerrit already)
2014/02/18 19:43:09
I would be happy to add this, but it does look lik
|
| IOHIDDeviceGetProperty(device, key)); |
| return ref && CFNumberGetValue(ref, kCFNumberSInt32Type, result); |
| } |
| -bool GetHidStringProperty(IOHIDDeviceRef device, |
| - CFStringRef key, |
| - std::string* result) { |
| +bool TryGetHidStringProperty(IOHIDDeviceRef device, |
| + CFStringRef key, |
| + std::string* result) { |
| CFStringRef ref = base::mac::CFCast<CFStringRef>( |
| IOHIDDeviceGetProperty(device, key)); |
| if (!ref) { |