summaryrefslogtreecommitdiffstats
path: root/device/hid/hid_service_win.cc
diff options
context:
space:
mode:
authorjracle@logitech.com <jracle@logitech.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 18:59:42 +0000
committerjracle@logitech.com <jracle@logitech.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-22 18:59:42 +0000
commitbb7e9ba398e362a859e42532a00114eba98e4708 (patch)
tree8c3394161a9c5e6d941cfa45422c932326b3760f /device/hid/hid_service_win.cc
parentcc00e0878070031e59aa296dcfb08508579a798a (diff)
downloadchromium_src-bb7e9ba398e362a859e42532a00114eba98e4708.zip
chromium_src-bb7e9ba398e362a859e42532a00114eba98e4708.tar.gz
chromium_src-bb7e9ba398e362a859e42532a00114eba98e4708.tar.bz2
chrome.hid (Win): fail to retrieve device info when used concurrently
BUG=376211 TBR=rockot@chromium.org Review URL: https://codereview.chromium.org/293113002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272258 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device/hid/hid_service_win.cc')
-rw-r--r--device/hid/hid_service_win.cc22
1 files changed, 18 insertions, 4 deletions
diff --git a/device/hid/hid_service_win.cc b/device/hid/hid_service_win.cc
index 312bd5b..82477a5 100644
--- a/device/hid/hid_service_win.cc
+++ b/device/hid/hid_service_win.cc
@@ -6,6 +6,7 @@
#include <cstdlib>
+#include "base/files/file.h"
#include "base/stl_util.h"
#include "base/strings/sys_string_conversions.h"
#include "device/hid/hid_connection_win.h"
@@ -147,14 +148,27 @@ void HidServiceWin::PlatformAddDevice(const std::string& device_path) {
// Try to open the device.
base::win::ScopedHandle device_handle(
CreateFileA(device_path.c_str(),
- 0,
- FILE_SHARE_READ,
+ GENERIC_WRITE | GENERIC_READ,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
0));
- if (!device_handle.IsValid())
- return;
+
+ if (!device_handle.IsValid() &&
+ GetLastError() == base::File::FILE_ERROR_ACCESS_DENIED) {
+ base::win::ScopedHandle device_handle(
+ CreateFileA(device_path.c_str(),
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_OVERLAPPED,
+ 0));
+
+ if (!device_handle.IsValid())
+ return;
+ }
// Get VID/PID pair.
HIDD_ATTRIBUTES attrib = {0};