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

Unified Diff: device/hid/hid_connection_win.cc

Issue 240263003: HID : read-only device access fallback when read/write fails (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops Created 6 years, 8 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 | « device/hid/hid_connection_linux.cc ('k') | device/hid/hid_service_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/hid_connection_win.cc
diff --git a/device/hid/hid_connection_win.cc b/device/hid/hid_connection_win.cc
index 44bd8471bc1ca95d803e39e9212ab0a015e44cb8..ca2825102e735c82820f0e431a023dec5578c89d 100644
--- a/device/hid/hid_connection_win.cc
+++ b/device/hid/hid_connection_win.cc
@@ -6,6 +6,7 @@
#include <cstring>
+#include "base/files/file.h"
#include "base/message_loop/message_loop.h"
#include "base/stl_util.h"
#include "base/threading/thread_restrictions.h"
@@ -110,6 +111,17 @@ HidConnectionWin::HidConnectionWin(const HidDeviceInfo& device_info)
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL));
+
+ if (!file_.IsValid() &&
+ GetLastError() == base::File::FILE_ERROR_ACCESS_DENIED) {
+ file_.Set(CreateFileA(device_info.device_id.c_str(),
+ GENERIC_READ,
+ FILE_SHARE_READ,
+ NULL,
+ OPEN_EXISTING,
+ FILE_FLAG_OVERLAPPED,
+ NULL));
+ }
}
bool HidConnectionWin::available() const {
« no previous file with comments | « device/hid/hid_connection_linux.cc ('k') | device/hid/hid_service_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698