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

Unified Diff: device/hid/hid_service_win.h

Issue 783773002: Register for HID device notifications on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
Index: device/hid/hid_service_win.h
diff --git a/device/hid/hid_service_win.h b/device/hid/hid_service_win.h
index e9ac9e98c670c1780bbc0e6cb1ed964772c80ff8..50f635315cc67590aa18382db1ac306eb4b7d920 100644
--- a/device/hid/hid_service_win.h
+++ b/device/hid/hid_service_win.h
@@ -5,13 +5,6 @@
#ifndef DEVICE_HID_HID_SERVICE_WIN_H_
#define DEVICE_HID_HID_SERVICE_WIN_H_
-#include <map>
-
-#include "device/hid/hid_device_info.h"
-#include "device/hid/hid_service.h"
-
-#if defined(OS_WIN)
-
#include <windows.h>
#include <hidclass.h>
@@ -20,25 +13,35 @@ extern "C" {
#include <hidpi.h>
}
-#endif // defined(OS_WIN)
+#include "base/memory/scoped_ptr.h"
+#include "base/win/scoped_handle.h"
+#include "device/hid/hid_device_info.h"
+#include "device/hid/hid_service.h"
-namespace device {
+namespace base {
+namespace win {
+class MessageWindow;
+}
+}
-class HidConnection;
+namespace device {
class HidServiceWin : public HidService {
public:
HidServiceWin();
- virtual void GetDevices(std::vector<HidDeviceInfo>* devices) override;
-
virtual void Connect(const HidDeviceId& device_id,
const ConnectCallback& callback) override;
private:
virtual ~HidServiceWin();
- void Enumerate();
+ void RegisterForDeviceNotifications();
+ bool HandleMessage(UINT message,
+ WPARAM wparam,
+ LPARAM lparam,
+ LRESULT* result);
+ void DoInitialEnumeration();
static void CollectInfoFromButtonCaps(PHIDP_PREPARSED_DATA preparsed_data,
HIDP_REPORT_TYPE report_type,
USHORT button_caps_length,
@@ -50,7 +53,12 @@ class HidServiceWin : public HidService {
void PlatformAddDevice(const std::string& device_path);
void PlatformRemoveDevice(const std::string& device_path);
+ // Tries to open the device read-write and falls back to read-only.
+ base::win::ScopedHandle OpenDevice(const std::string& device_path);
+
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
+ scoped_ptr<base::win::MessageWindow> window_;
+ HDEVNOTIFY notify_handle_;
DISALLOW_COPY_AND_ASSIGN(HidServiceWin);
};

Powered by Google App Engine
This is Rietveld 408576698