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 #include "device/hid/hid_service_win.h" | 5 #include "device/hid/hid_service_win.h" |
6 | 6 |
7 #define INITGUID | 7 #define INITGUID |
8 | 8 |
9 #include <dbt.h> | 9 #include <dbt.h> |
10 #include <setupapi.h> | 10 #include <setupapi.h> |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 namespace { | 32 namespace { |
33 | 33 |
34 void Noop() { | 34 void Noop() { |
35 // This function does nothing. | 35 // This function does nothing. |
36 } | 36 } |
37 } | 37 } |
38 | 38 |
39 HidServiceWin::HidServiceWin( | 39 HidServiceWin::HidServiceWin( |
40 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) | 40 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) |
41 : device_observer_(this), | 41 : file_task_runner_(file_task_runner), |
42 file_task_runner_(file_task_runner), | 42 device_observer_(this), |
43 weak_factory_(this) { | 43 weak_factory_(this) { |
44 task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 44 task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
45 DCHECK(task_runner_.get()); | 45 DCHECK(task_runner_.get()); |
46 DeviceMonitorWin* device_monitor = | 46 DeviceMonitorWin* device_monitor = |
47 DeviceMonitorWin::GetForDeviceInterface(GUID_DEVINTERFACE_HID); | 47 DeviceMonitorWin::GetForDeviceInterface(GUID_DEVINTERFACE_HID); |
48 if (device_monitor) { | 48 if (device_monitor) { |
49 device_observer_.Add(device_monitor); | 49 device_observer_.Add(device_monitor); |
50 } | 50 } |
51 file_task_runner_->PostTask( | 51 file_task_runner_->PostTask( |
52 FROM_HERE, base::Bind(&HidServiceWin::EnumerateOnFileThread, | 52 FROM_HERE, base::Bind(&HidServiceWin::EnumerateOnFileThread, |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 FILE_FLAG_OVERLAPPED, NULL)); | 300 FILE_FLAG_OVERLAPPED, NULL)); |
301 if (!file.IsValid() && | 301 if (!file.IsValid() && |
302 GetLastError() == base::File::FILE_ERROR_ACCESS_DENIED) { | 302 GetLastError() == base::File::FILE_ERROR_ACCESS_DENIED) { |
303 file.Set(CreateFileA(device_path.c_str(), GENERIC_READ, FILE_SHARE_READ, | 303 file.Set(CreateFileA(device_path.c_str(), GENERIC_READ, FILE_SHARE_READ, |
304 NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL)); | 304 NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL)); |
305 } | 305 } |
306 return file.Pass(); | 306 return file.Pass(); |
307 } | 307 } |
308 | 308 |
309 } // namespace device | 309 } // namespace device |
OLD | NEW |