| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 | 63 |
| 64 base::win::ScopedHandle file(OpenDevice(device_info->device_id())); | 64 base::win::ScopedHandle file(OpenDevice(device_info->device_id())); |
| 65 if (!file.IsValid()) { | 65 if (!file.IsValid()) { |
| 66 HID_PLOG(EVENT) << "Failed to open device"; | 66 HID_PLOG(EVENT) << "Failed to open device"; |
| 67 task_runner_->PostTask(FROM_HERE, base::Bind(callback, nullptr)); | 67 task_runner_->PostTask(FROM_HERE, base::Bind(callback, nullptr)); |
| 68 return; | 68 return; |
| 69 } | 69 } |
| 70 | 70 |
| 71 task_runner_->PostTask( | 71 task_runner_->PostTask( |
| 72 FROM_HERE, | 72 FROM_HERE, |
| 73 base::Bind(callback, new HidConnectionWin(device_info, std::move(file)))); | 73 base::Bind(callback, make_scoped_refptr( |
| 74 new HidConnectionWin(device_info, std::move(file))))); |
| 74 } | 75 } |
| 75 | 76 |
| 76 // static | 77 // static |
| 77 void HidServiceWin::EnumerateOnFileThread( | 78 void HidServiceWin::EnumerateOnFileThread( |
| 78 base::WeakPtr<HidServiceWin> service, | 79 base::WeakPtr<HidServiceWin> service, |
| 79 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { | 80 scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
| 80 HDEVINFO device_info_set = | 81 HDEVINFO device_info_set = |
| 81 SetupDiGetClassDevs(&GUID_DEVINTERFACE_HID, NULL, NULL, | 82 SetupDiGetClassDevs(&GUID_DEVINTERFACE_HID, NULL, NULL, |
| 82 DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); | 83 DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); |
| 83 | 84 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, | 295 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, |
| 295 FILE_FLAG_OVERLAPPED, NULL)); | 296 FILE_FLAG_OVERLAPPED, NULL)); |
| 296 if (!file.IsValid() && GetLastError() == ERROR_ACCESS_DENIED) { | 297 if (!file.IsValid() && GetLastError() == ERROR_ACCESS_DENIED) { |
| 297 file.Set(CreateFileA(device_path.c_str(), GENERIC_READ, FILE_SHARE_READ, | 298 file.Set(CreateFileA(device_path.c_str(), GENERIC_READ, FILE_SHARE_READ, |
| 298 NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL)); | 299 NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL)); |
| 299 } | 300 } |
| 300 return file; | 301 return file; |
| 301 } | 302 } |
| 302 | 303 |
| 303 } // namespace device | 304 } // namespace device |
| OLD | NEW |