| 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> |
| 11 #include <stddef.h> | 11 #include <stddef.h> |
| 12 #include <winioctl.h> | 12 #include <winioctl.h> |
| 13 | 13 |
| 14 #include <utility> | 14 #include <utility> |
| 15 | 15 |
| 16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/files/file.h" | 17 #include "base/files/file.h" |
| 18 #include "base/location.h" | 18 #include "base/location.h" |
| 19 #include "base/memory/free_deleter.h" | 19 #include "base/memory/free_deleter.h" |
| 20 #include "base/single_thread_task_runner.h" | 20 #include "base/single_thread_task_runner.h" |
| 21 #include "base/strings/string_util.h" | 21 #include "base/strings/string_util.h" |
| 22 #include "base/strings/sys_string_conversions.h" | 22 #include "base/strings/sys_string_conversions.h" |
| 23 #include "base/thread_task_runner_handle.h" | 23 #include "base/thread_task_runner_handle.h" |
| 24 #include "base/threading/thread_restrictions.h" | 24 #include "base/threading/thread_restrictions.h" |
| 25 #include "components/device_event_log/device_event_log.h" | 25 #include "components/device_event_log/device_event_log.h" |
| 26 #include "device/hid/hid_connection_win.h" | 26 #include "device/hid/hid_connection_win.h" |
| 27 #include "device/hid/hid_device_info.h" | 27 #include "device/hid/hid_device_info.h" |
| 28 #include "net/base/io_buffer.h" | 28 #include "net/base/io_buffer.h" |
| 29 | 29 |
| 30 // Setup API is required to enumerate HID devices. | |
| 31 #pragma comment(lib, "setupapi.lib") | |
| 32 #pragma comment(lib, "hid.lib") | |
| 33 | |
| 34 namespace device { | 30 namespace device { |
| 35 | 31 |
| 36 HidServiceWin::HidServiceWin( | 32 HidServiceWin::HidServiceWin( |
| 37 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) | 33 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner) |
| 38 : file_task_runner_(file_task_runner), | 34 : file_task_runner_(file_task_runner), |
| 39 device_observer_(this), | 35 device_observer_(this), |
| 40 weak_factory_(this) { | 36 weak_factory_(this) { |
| 41 task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 37 task_runner_ = base::ThreadTaskRunnerHandle::Get(); |
| 42 DCHECK(task_runner_.get()); | 38 DCHECK(task_runner_.get()); |
| 43 DeviceMonitorWin* device_monitor = | 39 DeviceMonitorWin* device_monitor = |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, | 292 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, |
| 297 FILE_FLAG_OVERLAPPED, NULL)); | 293 FILE_FLAG_OVERLAPPED, NULL)); |
| 298 if (!file.IsValid() && GetLastError() == ERROR_ACCESS_DENIED) { | 294 if (!file.IsValid() && GetLastError() == ERROR_ACCESS_DENIED) { |
| 299 file.Set(CreateFileA(device_path.c_str(), GENERIC_READ, FILE_SHARE_READ, | 295 file.Set(CreateFileA(device_path.c_str(), GENERIC_READ, FILE_SHARE_READ, |
| 300 NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL)); | 296 NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL)); |
| 301 } | 297 } |
| 302 return file; | 298 return file; |
| 303 } | 299 } |
| 304 | 300 |
| 305 } // namespace device | 301 } // namespace device |
| OLD | NEW |