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

Issue 143883005: HID backend (Closed)

Created:
6 years, 11 months ago by Bei Zhang
Modified:
6 years, 10 months ago
CC:
chromium-reviews, chromium-apps-reviews_chromium.org, extensions-reviews_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@hid-impl-base
Visibility:
Public.

Description

Patch Set 1 #

Total comments: 18

Patch Set 2 : Fix nits and change windows part to use IOHandler #

Patch Set 3 : Fix nits and revert IOHandler #

Patch Set 4 : Bug fixes #

Total comments: 7

Patch Set 5 : update OWNERS #

Patch Set 6 : include order #

Patch Set 7 : nit #

Patch Set 8 : doh - revert include order change. #

Patch Set 9 : fix vs2012 64bit #

Patch Set 10 : Disable device tests on ChromeOS for lack of hardware #

Patch Set 11 : allow tests to pass with no devices connected #

Patch Set 12 : Really fix tests for lack of testing hardware; adapt to ancient libudev in the cros distro #

Total comments: 50
Unified diffs Side-by-side diffs Delta from patch set Stats (+2428 lines, --1 lines) Patch
M chrome/chrome_browser_extensions.gypi View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -0 lines 0 comments Download
M device/OWNERS View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download
M device/device_tests.gyp View 2 chunks +3 lines, -0 lines 0 comments Download
A + device/hid/DEPS View 1 2 3 4 5 6 7 8 9 10 11 0 chunks +-1 lines, --1 lines 0 comments Download
A device/hid/hid.gyp View 1 chunk +47 lines, -0 lines 0 comments Download
A device/hid/hid_connection.h View 1 1 chunk +54 lines, -0 lines 0 comments Download
A device/hid/hid_connection.cc View 1 1 chunk +18 lines, -0 lines 0 comments Download
A device/hid/hid_connection_linux.h View 1 1 chunk +69 lines, -0 lines 0 comments Download
A device/hid/hid_connection_linux.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +231 lines, -0 lines 0 comments Download
A device/hid/hid_connection_mac.h View 1 1 chunk +77 lines, -0 lines 0 comments Download
A device/hid/hid_connection_mac.cc View 1 1 chunk +188 lines, -0 lines 0 comments Download
A device/hid/hid_connection_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +131 lines, -0 lines 0 comments Download
A device/hid/hid_connection_win.h View 1 2 1 chunk +96 lines, -0 lines 0 comments Download
A device/hid/hid_connection_win.cc View 1 2 3 4 5 6 7 8 1 chunk +279 lines, -0 lines 0 comments Download
A device/hid/hid_device_info.h View 1 1 chunk +43 lines, -0 lines 0 comments Download
A device/hid/hid_device_info.cc View 1 1 chunk +22 lines, -0 lines 0 comments Download
A device/hid/hid_service.h View 1 1 chunk +79 lines, -0 lines 0 comments Download
A device/hid/hid_service.cc View 1 2 1 chunk +106 lines, -0 lines 0 comments Download
A device/hid/hid_service_linux.h View 1 1 chunk +64 lines, -0 lines 0 comments Download
A device/hid/hid_service_linux.cc View 1 2 3 4 5 6 1 chunk +211 lines, -0 lines 0 comments Download
A device/hid/hid_service_mac.h View 1 1 chunk +81 lines, -0 lines 1 comment Download
A device/hid/hid_service_mac.cc View 1 1 chunk +250 lines, -0 lines 49 comments Download
A device/hid/hid_service_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +33 lines, -0 lines 0 comments Download
A device/hid/hid_service_win.h View 1 1 chunk +42 lines, -0 lines 0 comments Download
A device/hid/hid_service_win.cc View 1 2 3 6 7 1 chunk +240 lines, -0 lines 0 comments Download
A device/hid/hid_utils_mac.h View 1 1 chunk +23 lines, -0 lines 0 comments Download
A device/hid/hid_utils_mac.cc View 1 1 chunk +39 lines, -0 lines 0 comments Download

Messages

Total messages: 20 (0 generated)
Bei Zhang
Hi Ken, Please review. PS: If you think some files are just too horrible to ...
6 years, 11 months ago (2014-01-21 12:43:59 UTC) #1
Ken Rockot(use gerrit already)
Looking pretty good, comments inline https://codereview.chromium.org/143883005/diff/1/device/hid/hid_connection.cc File device/hid/hid_connection.cc (right): https://codereview.chromium.org/143883005/diff/1/device/hid/hid_connection.cc#newcode16 device/hid/hid_connection.cc:16: } nit: vertical whitespace ...
6 years, 11 months ago (2014-01-21 23:03:39 UTC) #2
Ken Rockot(use gerrit already)
Forgot one comment: What about threading restrictions on HIDConnection? Should it guarantee that Read/Write/etc are ...
6 years, 11 months ago (2014-01-21 23:08:18 UTC) #3
Bei Zhang
https://codereview.chromium.org/143883005/diff/1/device/hid/hid_connection.cc File device/hid/hid_connection.cc (right): https://codereview.chromium.org/143883005/diff/1/device/hid/hid_connection.cc#newcode16 device/hid/hid_connection.cc:16: } On 2014/01/21 23:03:39, Ken Rockot wrote: > nit: ...
6 years, 11 months ago (2014-01-24 12:48:47 UTC) #4
Ken Rockot(use gerrit already)
I reviewed this for Bei and everything lgtm now. Need owner.
6 years, 10 months ago (2014-01-28 23:30:50 UTC) #5
miket_OOO
On 2014/01/28 23:30:50, Ken Rockot wrote: > I reviewed this for Bei and everything lgtm ...
6 years, 10 months ago (2014-01-29 20:15:31 UTC) #6
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/ikarienator@chromium.org/143883005/550001
6 years, 10 months ago (2014-01-29 20:48:20 UTC) #7
commit-bot: I haz the power
Failed to trigger a try job on win_rel HTTP Error 400: Bad Request
6 years, 10 months ago (2014-01-29 21:16:13 UTC) #8
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/ikarienator@chromium.org/143883005/570001
6 years, 10 months ago (2014-01-29 21:16:48 UTC) #9
commit-bot: I haz the power
Retried try job too often on win_x64_rel for step(s) base_unittests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=win_x64_rel&number=71283
6 years, 10 months ago (2014-01-29 22:50:32 UTC) #10
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/ikarienator@chromium.org/143883005/590001
6 years, 10 months ago (2014-01-29 23:09:04 UTC) #11
commit-bot: I haz the power
Retried try job too often on linux_chromeos for step(s) device_unittests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=linux_chromeos&number=196133
6 years, 10 months ago (2014-01-30 04:38:29 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/ikarienator@chromium.org/143883005/610001
6 years, 10 months ago (2014-01-30 06:00:43 UTC) #13
commit-bot: I haz the power
Retried try job too often on android_dbg for step(s) slave_steps http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=android_dbg&number=144589
6 years, 10 months ago (2014-01-30 07:47:55 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/ikarienator@chromium.org/143883005/610001
6 years, 10 months ago (2014-01-30 08:33:21 UTC) #15
commit-bot: I haz the power
Change committed as 247926
6 years, 10 months ago (2014-01-30 10:41:09 UTC) #16
miket_OOO
Sorry, pressed wrong button. Please review these suggestions. https://codereview.chromium.org/143883005/diff/450001/device/hid/hid.gyp File device/hid/hid.gyp (right): https://codereview.chromium.org/143883005/diff/450001/device/hid/hid.gyp#newcode1 device/hid/hid.gyp:1: # ...
6 years, 10 months ago (2014-02-03 18:42:18 UTC) #17
Jorge Lucangeli Obes
On 2014/02/03 18:42:18, miket wrote: > Sorry, pressed wrong button. Please review these suggestions. > ...
6 years, 10 months ago (2014-02-05 18:06:57 UTC) #18
Mark Mentovai
I was asked to do a post-commit review of the Mac design and implementation. Here ...
6 years, 10 months ago (2014-02-12 19:35:58 UTC) #19
Ken Rockot(use gerrit already)
6 years, 10 months ago (2014-02-13 00:04:54 UTC) #20
Message was sent while issue was closed.
Thank you for the review, Mark. Leaving replies inline on this CL, but the new
code is over at https://codereview.chromium.org/161823002/

All the small stuff has been addressed, and I've tentatively axed the extra
thread. The device identification question remains open for now.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
File device/hid/hid_service_mac.cc (right):

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:7: #include <map>
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> Unused.

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:8: #include <set>
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> Unused.

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:24: #include <CoreFoundation/CoreFoundation.h>
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> C system headers before C++ system headers. This is in the style guide.

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:32: base::ThreadRestrictions::AssertIOAllowed();
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> Which thread exactly are you expecting this to run on?

FILE thread

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:34:
hid_manager_ref_.reset(IOHIDManagerCreate(kCFAllocatorDefault,
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> It’s normal to write NULL, which has the same meaning as kCFAllocatorDefault.

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:35: kIOHIDOptionsTypeNone));
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> This is an option value for IOHIDManagerOpen, but you are calling
> IOHIDManagerCreate. You want kIOHIDManagerOptionNone.

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:37: CFGetTypeID(hid_manager_ref_) !=
IOHIDManagerGetTypeID()) {
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> Does this ever actually happen, or is it just paranoia?

As far as I can tell, paranoia.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:41: CFRetain(hid_manager_ref_);
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> IOHIDManagerCreate gave you a reference already, why do you need a second one?

Don't. Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:47: &HidServiceMac::AddDeviceCallback,
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> HidServiceMac:: is implied. Same on line 51.

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:54: // Blocking operation to enumerate all the
pre-existing devices.
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> What about Enumerate is blocking?

I think in this case the original concern (which seems questionable to me) was
that IOHIDManagerCopyDevices may perform potentially blocking I/O operations.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:63: // run potentially blocking routines on it.
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> What might block?

In this case I can only imagine the concern was that IOHIDDeviceGetProperty
could block for some reason. Is this not the case?

If not, and if IOHIDManagerCopyDevices is also safe, I'm actually a little
confounded as to why the UI thread wouldn't be suitable for all of this work.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:109: HidServiceMac*
HidServiceMac::InstanceFromContext(void* context) {
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> private + static + no need to access member data = no need to be a (static)
> class member function at all. It can just be a simple anonymous-namespaced
> helper function in this file. Fight interface clutter!

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:116: IOHIDDeviceRef ref) {
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> Everything in the world of CF is a reference. You’ve used the name “ref”
> everywhere. It’s about the least descriptive name possible. This one, along
with
> many others, should be “hid_device”. You should go through your code and make
> sure you don’t have anything named “ref” (or variants like “raw_ref”). In
cases
> where you have names like&nbsp;“hid_manager_ref_”, the _ref is extraneous
noise and
> should be removed.

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:143: IOHIDDeviceRef
HidServiceMac::FindDevice(std::string id) {
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> More thoughts on location ID:
> 
> Enumerating devices in this manner on my laptop shows four “Apple Internal
> Keyboard/Trackpad” devices at the same location ID. If I plug in an external
> keyboard, I get two more “Apple Keyboard” devices at their own location ID.
> 
> Do all of these entries need to be tracked individually?
> 
> What if some of the entries at a single common location, but not all of them,
> wind up getting removed?

Leaving this question open for now.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:150: for (CFIndex i = 0; i < count; i++) {
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> Usually use preincrement. Line 170 also.
>
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml?showone=Preinc...

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:153: &int_property)) {
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> Weird indentation.

Ew.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:166: CFIndex count = CFSetGetCount(devices);
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> This is cumbersome just like line 146, and now you’re doing it a second time.
> Code duplication looks like a good opportunity for refactoring.

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:171: // Takes ownership. Will be released inside
PlatformDeviceAdd.
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> The function is actually named PlatformAddDevice.

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:182: // Auto-release.
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> “Autorelease”&nbsp;has a special meaning in Mac programming. This is not
autorelease.
> Remove the comment, because it should be obvious what the next line does
> (especially after you rename the variables).

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:193: if (GetHidIntProperty(ref,
CFSTR(kIOHIDVendorIDKey), &int_property)) {
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> All of this “if this succeeded then use its value” testing is getting kind of
> cumbersome too. Since none of these calls seem to care about the failure case,
> you don’t actually care about testing success or failure. You need versions of
> GetHidIntProperty and GetHidStringProperty that simply return their value, or
a
> default value (0 or an empty string) if the “get” fails.

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:214: &int_property)) {
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> Weird indentation

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:214: &int_property)) {
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> Weird indentation

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:229: // Auto-release.
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> Nope.

Done.

https://codereview.chromium.org/143883005/diff/650001/device/hid/hid_service_...
device/hid/hid_service_mac.cc:229: // Auto-release.
On 2014/02/12 19:35:59, Mark Mentovai wrote:
> Nope.

Done.

Powered by Google App Engine
This is Rietveld 408576698