summaryrefslogtreecommitdiffstats
path: root/device/hid/hid_connection_linux.cc
Commit message (Collapse)AuthorAgeFilesLines
* Log device/hid messages to chrome://device-log.reillyg2015-02-241-8/+9
| | | | | | | | | | | | | Log events and debugging information related to HID devices through the device event log component so that these errors are visible at chrome://device-log. A DEVICE_PLOG macro has been added which includes the last reported system error in the log message. BUG=448901 Review URL: https://codereview.chromium.org/947663002 Cr-Commit-Position: refs/heads/master@{#317722}
* Rename HidServiceLinux and HidConnectionLinux helper classes.reillyg2015-01-121-10/+13
| | | | | | | | | | | | This change documents that these helper classes live on the FILE thread by naming them HidServiceLinux::FileThreadHelper and HidConnectionLinux::FileThreadHelper. BUG= Review URL: https://codereview.chromium.org/851543002 Cr-Commit-Position: refs/heads/master@{#311120}
* Convert HidDeviceInfo from a struct to a refcounted class.reillyg2015-01-091-6/+6
| | | | | | | | | | | | | | | | | | | The HidDeviceInfo object for a device is passed around a lot, including being copied every time enumeration of a device is requested. Since this data is constant once a device is enumerated it is better to keep one copy around for the device for as long as it is connected. This will make it similar to the device::UsbDevice class. I consider this a pre-requisite for storing more information in HidDeviceInfo such as the raw report descriptor. Later patches will revisit how this object is constructed and possibly reduce the number of friend classes. BUG=442818 Review URL: https://codereview.chromium.org/825523003 Cr-Commit-Position: refs/heads/master@{#310692}
* Standardize usage of virtual/override/final specifiers in device/.dcheng2014-12-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Google C++ style guide states: Explicitly annotate overrides of virtual functions or virtual destructors with an override or (less frequently) final specifier. Older (pre-C++11) code will use the virtual keyword as an inferior alternative annotation. For clarity, use exactly one of override, final, or virtual when declaring an override. To better conform to these guidelines, the following constructs have been rewritten: - if a base class has a virtual destructor, then: virtual ~Foo(); -> ~Foo() override; - virtual void Foo() override; -> void Foo() override; - virtual void Foo() override final; -> void Foo() final; This patch was automatically generated. The clang plugin can generate fixit hints, which are suggested edits when it is 100% sure it knows how to fix a problem. The hints from the clang plugin were applied to the source tree using the tool in https://codereview.chromium.org/598073004. Several formatting edits by clang-format were manually reverted, due to mangling of some of the more complicate IPC macros. BUG=417463 Review URL: https://codereview.chromium.org/818093003 Cr-Commit-Position: refs/heads/master@{#309481}
* Catch HID read errors on Linux and stop listening.reillyg2014-12-181-3/+8
| | | | | | | | | | | | | | When a HID connection is broken read(2) will start returning errors. If the app that opened the device does not notice that it is disconnected then the file thread will spin on trying (and failing) to read more data from the device. This change stops the FileDescriptorWatcher when a read error is encountered. BUG= Review URL: https://codereview.chromium.org/809253002 Cr-Commit-Position: refs/heads/master@{#309103}
* Fix a race in the creation of HidConnectionLinux::Helper.reillyg2014-12-111-21/+22
| | | | | | | | | | | | | | | | | | | The creation of this object on the FILE thread races with the possible destruction of the object on the UI thread. The scoped_ptr<> that owns the pointer may try to destroy the object on the UI thread if the connection is closed before the helper is started. Generally, updating the helper_ pointer from the FILE thread is a bad idea. This patch moves creation of the helper to the UI thread, it is then detached from that thread when it is started. The HidConnectionLinux no longer uses a scoped_ptr<> to hold it and instead must always free it explicitly with DeleteSoon. BUG= Review URL: https://codereview.chromium.org/786343003 Cr-Commit-Position: refs/heads/master@{#307850}
* Drop unused base/tuple.h inclusiontzik2014-12-091-1/+0
| | | | | | | | | | TEST=compile BUG=None TBR=jam@chromium.org Review URL: https://codereview.chromium.org/790623002 Cr-Commit-Position: refs/heads/master@{#307457}
* Migrate HidServiceLinux and HidConnectionLinux to BrowserThread::UI.reillyg2014-12-041-100/+174
| | | | | | | | | | | | | | | This patch is a follow-up to https://crrev.com/e8fa00efd0965a7eb5816a that moves the HidService and HidConnection implementations on Linux from the browser's FILE thread to the UI thread. This is being done because the HID APIs on platforms other than Linux are more natural to use on the UI thread. The users of these objects are also usually on the UI thread. (For example, the extension API bindings.) BUG=422540 Review URL: https://codereview.chromium.org/771393002 Cr-Commit-Position: refs/heads/master@{#306729}
* Linux: Dynamically load libudev.thestig2014-11-221-1/+0
| | | | | | | | | | Funnel all libudev access through a wrapper for the udev library loader. BUG=415212 Review URL: https://codereview.chromium.org/674703002 Cr-Commit-Position: refs/heads/master@{#305348}
* Fix type truncation warnings in HID code.pkasting2014-10-181-1/+1
| | | | | | | | | | | | | | | | GetShortData() and IOHIDElementGetUsage() both return uint32s, so raise the size of various containing types to uint32. I tried to look in the USB HID spec to see if any of the affected fields here were limited to e.g. <2^16, meaning that it'd be safe to just cast down to the existing uint16s instead, but I couldn't find any limits. BUG=81439 TEST=none Review URL: https://codereview.chromium.org/656583003 Cr-Commit-Position: refs/heads/master@{#300201}
* Add HidConnection::Close and register OS X callbacks on the UI thread.reillyg2014-10-071-0/+3
| | | | | | | | | | | | | | | | | | | | | The platform implementation of a HID connection may need to cancel I/O operations when the connection is closed. If this is done during the object destructor then any pointers held by those pending operations are immediately invalid. A separate Close method allows the cleanup to happen while the object is still available to handle asynchronous cancellation events. The OS X implementation will take advantage of this immediately to register and unregister its input report callback from the UI thread to avoid a race between event delivery and object cleanup. I've added comments explaining why not all operations on the IOHIDDevice object could be moved to the UI thread. BUG=418207 Review URL: https://codereview.chromium.org/615633008 Cr-Commit-Position: refs/heads/master@{#298384}
* hid: Don't interpret the report ID from incoming feature reports.reillyg2014-10-041-1/+9
| | | | | | | | | | | | | | | | | | | | | The USB HID GET_REPORT(Feature) request includes the report ID that the host is requesting in the SETUP packet. When the report ID is not zero the device will send this back to the host as the first byte of the report. Unlike input and output reports we want to preserve this part of the report because the device may in fact by sending a value other than the report ID as the first byte of the response. To achieve this, on Windows this patch stops stripping the report ID from the buffer received from the OS. On OS X this was already the behavior. On Linux this was the behavior if the report ID was non-zero, otherwise it would artificially prepend a zero to the buffer which must be removed. BUG=420112 Review URL: https://codereview.chromium.org/623963003 Cr-Commit-Position: refs/heads/master@{#298135}
* Don't pass buffers to HidConnection::Read because it knows the size.reillyg2014-08-261-72/+55
| | | | | | | | | | | | | | | | | | The HidConnection knows the appropriate read buffer size and the platform-specific implementation may already have a buffer that it is waiting to return to the next caller. Passing a buffer in is therefore unnecessary, one can be provided in the callback. By standardizing on a buffer format which always includes the report ID as the first byte (even when it is zero) most of the buffer copying can be removed except in the case of OS X's persistent read buffer and getting feature reports on Windows. BUG= Review URL: https://codereview.chromium.org/499713002 Cr-Commit-Position: refs/heads/master@{#291954}
* Fix HID input report sizes on Windows for devices without report IDs.reillyg@chromium.org2014-08-181-1/+1
| | | | | | | | | | | | | | | | | | | | | Unlike Linux and OS X, Windows always writes a report ID into the buffer passed to ReadFile. If the device does not use report IDs the first byte of the buffer will always be zero. Because of this, and contrary to the MSDN documentation, the maximum report size reported in the HIDP_CAPS structure always includes a byte for the report ID. This patch fixes the interpretation of the values in HIDP_CAPS and the size of the buffer passed to ReadFile. To prevent uninitialized bytes from being passed back to an app when a shorter report is read the true number of bytes read is provided to the completion callback on all platforms. BUG=404253 Review URL: https://codereview.chromium.org/474273004 Cr-Commit-Position: refs/heads/master@{#290337} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290337 0039d316-1c4b-4281-b951-d872f2087c98
* Support permission_broker for chrome.hid devices.rockot@chromium.org2014-07-261-0/+1
| | | | | | | | | | | | | | | | | | This enables the Chrome to query permission_broker for access to hidraw device paths when running on Chrome OS. HidService has been refactored so that it is owned by the extensions API embedder, rather than being a singleton. Because hid has just moved to //extensions as well, this also establishes a new ShellExtensionsAPIClient to create a HidService for app_shell. BUG=367145 TEST=manual test on ChromeOS dev build TBR=derat@chromium.org for mechanical app_shell changes Review URL: https://codereview.chromium.org/419713002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285774 0039d316-1c4b-4281-b951-d872f2087c98
* hid: Linux expects the report ID in the output report buffer.reillyg@chromium.org2014-07-231-5/+8
| | | | | | | | | | | | | The Linux hidraw interface expects the buffer written to the device to always have the report ID as the first byte. Remove the conditional that only added this data when the report ID was non-zero. BUG= R=rockot@chromium.org Review URL: https://codereview.chromium.org/411463005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285041 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 281282 "Revert 281133 "chrome.hid: enrich model with repo..."csharp@chromium.org2014-07-031-55/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Tests still failed, undoing revert. > Revert 281133 "chrome.hid: enrich model with report IDs" > > Speculative revert to try and fix Win browser tests. > > > chrome.hid: enrich model with report IDs > > > > - add report IDs and max report size > > - don't expose sensitive usages > > > > BUG=364423 > > R=rockot@chromium.org > > TESTS=run device_unittests (HidReportDescriptorTest) > > > > Review URL: https://codereview.chromium.org/317783010 > > TBR=jracle@logitech.com > > Review URL: https://codereview.chromium.org/369923002 TBR=csharp@chromium.org Review URL: https://codereview.chromium.org/364213005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281300 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 281133 "chrome.hid: enrich model with report IDs"csharp@chromium.org2014-07-031-69/+55
| | | | | | | | | | | | | | | | | | | | | Speculative revert to try and fix Win browser tests. > chrome.hid: enrich model with report IDs > > - add report IDs and max report size > - don't expose sensitive usages > > BUG=364423 > R=rockot@chromium.org > TESTS=run device_unittests (HidReportDescriptorTest) > > Review URL: https://codereview.chromium.org/317783010 TBR=jracle@logitech.com Review URL: https://codereview.chromium.org/369923002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281282 0039d316-1c4b-4281-b951-d872f2087c98
* chrome.hid: enrich model with report IDsjracle@logitech.com2014-07-031-55/+69
| | | | | | | | | | | | | - add report IDs and max report size - don't expose sensitive usages BUG=364423 R=rockot@chromium.org TESTS=run device_unittests (HidReportDescriptorTest) Review URL: https://codereview.chromium.org/317783010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@281133 0039d316-1c4b-4281-b951-d872f2087c98
* Log errors in Linux HID from read, write and ioctl calls.reillyg@chromium.org2014-06-211-5/+11
| | | | | | | | | | | Log human readable descriptions of the errors generated by system calls executed on Linux against HID devices. BUG= Review URL: https://codereview.chromium.org/348733002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278899 0039d316-1c4b-4281-b951-d872f2087c98
* Descriptive log for HID device open failure on Linux.reillyg@chromium.org2014-06-201-8/+9
| | | | | | | | | | | Log a human readable message describing the reason why Chromium failed to open a HID device node on Linux instead of the base::File error code. BUG= Review URL: https://codereview.chromium.org/339503007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@278684 0039d316-1c4b-4281-b951-d872f2087c98
* Disable compiling Udev HID implementations when use_udev==0dnicoara@chromium.org2014-06-051-1/+0
| | | | | | | | | | | Disabled compiling of classes and unittests that require Udev. BUG=none TESTS=Ran device_unittests with use_udev=0 and use_udev=1 Review URL: https://codereview.chromium.org/316953002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275161 0039d316-1c4b-4281-b951-d872f2087c98
* HID: Support top-level collection usages in device info.rockot@chromium.org2014-04-251-50/+1
| | | | | | | | | | | | | | | This CL exists as an effort to actually land https://codereview.chromium.org/225513005/. This applies a small fix to the hid_service_win.cc module. BUG=359560 TBR=rpaquay TBR=jracle@logitech.com Review URL: https://codereview.chromium.org/256673002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266066 0039d316-1c4b-4281-b951-d872f2087c98
* HID : read-only device access fallback when read/write failsjracle@logitech.com2014-04-241-2/+14
| | | | | | | | | | | | | - for Windows and Linux - open device with read access when read/write fails BUG=364438 R=rockot@chromium.org Review URL: https://codereview.chromium.org/240263003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266022 0039d316-1c4b-4281-b951-d872f2087c98
* HID connection matches wrong hidraw devnode to HID device when a bus driver ↵jracle@logitech.com2014-04-031-2/+6
| | | | | | | | | | | | | | | is present on Linux Fix : HidConnectionLinux::FindHidrawDevNode should look for presence of "hidraw" string immediately after matching parent udev path, so that we do not match devnodes created by bus enumerator driver BUG=358666 TBR=rockot@chromium.org Review URL: https://codereview.chromium.org/223803002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261502 0039d316-1c4b-4281-b951-d872f2087c98
* HID device connection now shared on Linuxjracle@logitech.com2014-04-021-3/+1
| | | | | | | | | | | | | | Remove exclusive flags so that 2 apps can communicate with same device. This is coherent with Windows and Mac implementation. Note that a non-chrome app (e.g. desktop app on Windows) can open same device. BUG=358631 TBR=rockot@chromium.org Review URL: https://codereview.chromium.org/213743009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@261019 0039d316-1c4b-4281-b951-d872f2087c98
* Fix IWYU in base/files/file.htnagel@chromium.org2014-03-091-0/+1
| | | | | | | | | | | | | | | The other changes follow from that. BUG=82098 TBR=haruki@chromium.org (for chrome/browser/chromeos/drive/drive_file_system_util.h) TBR=hidehiko@chromium.org (for chrome/browser/chromeos/drive/webkit_file_stream_writer_impl.h) TBR=noamsml@chromium.org (for chrome/browser/local_discovery/storage/privet_filesystem_attribute_cache_unittest.cc) TBR=rvargas@chromium.org (for device/hid/hid_connection_linux.cc) TBR=clamy@chromium.org (for net/disk_cache/simple/simple_test_util.cc) Review URL: https://codereview.chromium.org/184583008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@255841 0039d316-1c4b-4281-b951-d872f2087c98
* Clean up HID backend and API.rockot@chromium.org2014-02-271-78/+98
| | | | | | | | | | | | | | | | | | The Mac backend no longer creates its own thread and instead simply enforces single-threaded usage on any thread which supports I/O. Ref management has also been sanitized. The Linux backend now implements feature report support. The backend interface no longer expects implicit report IDs in buffers passed to Write or SetFeatureReport. Instead these interfaces (as well as GetFeatureReport) take explicit report ID arguments. The API interface has been updated to reflect the improved report ID treatment. Finally, the API also now exposes opaque device identifiers on enumeration, rather than exposing raw system paths or other information that could be potentially sensitive. BUG=347294 Review URL: https://codereview.chromium.org/161823002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253853 0039d316-1c4b-4281-b951-d872f2087c98
* Remove PlatformFile from device/hidrvargas@chromium.org2014-02-211-24/+17
| | | | | | | | | BUG=322664 R=rockot@chromium.org Review URL: https://codereview.chromium.org/173003002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252479 0039d316-1c4b-4281-b951-d872f2087c98
* HID backend.rockot@chromium.org2014-01-311-0/+231
| | | | | | | | | | | | This is a continuation of https://codereview.chromium.org/143883005. [ps#1 here is (post-revert) ps#12 there.] BUG=290428 TBR=miket@chromium.org Review URL: https://codereview.chromium.org/150773004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@248250 0039d316-1c4b-4281-b951-d872f2087c98
* Revert 247926 "HID backend"nkostylev@chromium.org2014-01-301-231/+0
| | | | | | | | | | | | | | | | | | | | Breaks CrOS buildbots http://build.chromium.org/p/chromium.chromiumos/buildstatus?builder=ChromiumOS%20%28daisy%29&number=16073 http://build.chromium.org/p/chromium.chromiumos/buildstatus?builder=ChromiumOS%20%28amd64%29&number=13917 http://build.chromium.org/p/chromium.memory/buildstatus?builder=Chromium%20OS%20%28x86%29%20ASAN&number=8064 > HID backend > > BUG=290428 > > Review URL: https://codereview.chromium.org/143883005 TBR=ikarienator@chromium.org Review URL: https://codereview.chromium.org/148183015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247934 0039d316-1c4b-4281-b951-d872f2087c98
* HID backendikarienator@chromium.org2014-01-301-0/+231
BUG=290428 Review URL: https://codereview.chromium.org/143883005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@247926 0039d316-1c4b-4281-b951-d872f2087c98