OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef DEVICE_HID_HID_SERVICE_WIN_H_ | 5 #ifndef DEVICE_HID_HID_SERVICE_WIN_H_ |
6 #define DEVICE_HID_HID_SERVICE_WIN_H_ | 6 #define DEVICE_HID_HID_SERVICE_WIN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <hidclass.h> | 9 #include <hidclass.h> |
10 | 10 |
11 extern "C" { | 11 extern "C" { |
12 #include <hidsdi.h> | 12 #include <hidsdi.h> |
13 #include <hidpi.h> | 13 #include <hidpi.h> |
14 } | 14 } |
15 | 15 |
16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
17 #include "base/memory/weak_ptr.h" | |
17 #include "base/scoped_observer.h" | 18 #include "base/scoped_observer.h" |
18 #include "base/win/scoped_handle.h" | 19 #include "base/win/scoped_handle.h" |
19 #include "device/core/device_monitor_win.h" | 20 #include "device/core/device_monitor_win.h" |
20 #include "device/hid/hid_device_info.h" | 21 #include "device/hid/hid_device_info.h" |
21 #include "device/hid/hid_service.h" | 22 #include "device/hid/hid_service.h" |
22 | 23 |
23 namespace base { | 24 namespace base { |
24 namespace win { | 25 namespace win { |
25 class MessageWindow; | 26 class MessageWindow; |
26 } | 27 } |
27 } | 28 } |
28 | 29 |
29 namespace device { | 30 namespace device { |
30 | 31 |
31 class HidServiceWin : public HidService, public DeviceMonitorWin::Observer { | 32 class HidServiceWin : public HidService, public DeviceMonitorWin::Observer { |
32 public: | 33 public: |
33 HidServiceWin(); | 34 HidServiceWin(scoped_refptr<base::SingleThreadTaskRunner> file_task_runner); |
34 | 35 |
35 virtual void Connect(const HidDeviceId& device_id, | 36 virtual void Connect(const HidDeviceId& device_id, |
36 const ConnectCallback& callback) override; | 37 const ConnectCallback& callback) override; |
37 | 38 |
38 private: | 39 private: |
39 virtual ~HidServiceWin(); | 40 virtual ~HidServiceWin(); |
40 | 41 |
41 void DoInitialEnumeration(); | 42 static void InitialEnumerationFileThread( |
Ken Rockot(use gerrit already)
2015/02/18 20:40:23
nit: Judging from its ubiquity across the codebase
| |
43 base::WeakPtr<HidServiceWin> service, | |
44 scoped_refptr<base::SingleThreadTaskRunner> task_runner); | |
42 static void CollectInfoFromButtonCaps(PHIDP_PREPARSED_DATA preparsed_data, | 45 static void CollectInfoFromButtonCaps(PHIDP_PREPARSED_DATA preparsed_data, |
43 HIDP_REPORT_TYPE report_type, | 46 HIDP_REPORT_TYPE report_type, |
44 USHORT button_caps_length, | 47 USHORT button_caps_length, |
45 HidCollectionInfo* collection_info); | 48 HidCollectionInfo* collection_info); |
46 static void CollectInfoFromValueCaps(PHIDP_PREPARSED_DATA preparsed_data, | 49 static void CollectInfoFromValueCaps(PHIDP_PREPARSED_DATA preparsed_data, |
47 HIDP_REPORT_TYPE report_type, | 50 HIDP_REPORT_TYPE report_type, |
48 USHORT value_caps_length, | 51 USHORT value_caps_length, |
49 HidCollectionInfo* collection_info); | 52 HidCollectionInfo* collection_info); |
53 static void AddDeviceFileThread( | |
54 base::WeakPtr<HidServiceWin> service, | |
55 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | |
56 const std::string& device_path); | |
50 | 57 |
51 // DeviceMonitorWin::Observer implementation: | 58 // DeviceMonitorWin::Observer implementation: |
52 void OnDeviceAdded(const std::string& device_path) override; | 59 void OnDeviceAdded(const std::string& device_path) override; |
53 void OnDeviceRemoved(const std::string& device_path) override; | 60 void OnDeviceRemoved(const std::string& device_path) override; |
54 | 61 |
55 // Tries to open the device read-write and falls back to read-only. | 62 // Tries to open the device read-write and falls back to read-only. |
56 base::win::ScopedHandle OpenDevice(const std::string& device_path); | 63 static base::win::ScopedHandle OpenDevice(const std::string& device_path); |
57 | 64 |
58 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 65 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
66 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; | |
59 ScopedObserver<DeviceMonitorWin, DeviceMonitorWin::Observer> device_observer_; | 67 ScopedObserver<DeviceMonitorWin, DeviceMonitorWin::Observer> device_observer_; |
68 base::WeakPtrFactory<HidServiceWin> weak_factory_; | |
60 | 69 |
61 DISALLOW_COPY_AND_ASSIGN(HidServiceWin); | 70 DISALLOW_COPY_AND_ASSIGN(HidServiceWin); |
62 }; | 71 }; |
63 | 72 |
64 } // namespace device | 73 } // namespace device |
65 | 74 |
66 #endif // DEVICE_HID_HID_SERVICE_WIN_H_ | 75 #endif // DEVICE_HID_HID_SERVICE_WIN_H_ |
OLD | NEW |