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

Unified Diff: device/hid/hid_service_win.cc

Issue 293113002: chrome.hid (Win): fail to retrieve device info when used concurrently (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CreateFile : shared read/write flags (read fallback) Created 6 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/hid_service_win.cc
diff --git a/device/hid/hid_service_win.cc b/device/hid/hid_service_win.cc
index 42c9a3a86d6d99f1fc0b6767295d666a6939be17..7f41514a557d7d48acd0e4eb437ed0224763632c 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};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698