| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 device_path)); | 283 device_path)); |
| 284 } | 284 } |
| 285 | 285 |
| 286 // static | 286 // static |
| 287 base::win::ScopedHandle HidServiceWin::OpenDevice( | 287 base::win::ScopedHandle HidServiceWin::OpenDevice( |
| 288 const std::string& device_path) { | 288 const std::string& device_path) { |
| 289 base::win::ScopedHandle file( | 289 base::win::ScopedHandle file( |
| 290 CreateFileA(device_path.c_str(), GENERIC_WRITE | GENERIC_READ, | 290 CreateFileA(device_path.c_str(), GENERIC_WRITE | GENERIC_READ, |
| 291 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, | 291 FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, |
| 292 FILE_FLAG_OVERLAPPED, NULL)); | 292 FILE_FLAG_OVERLAPPED, NULL)); |
| 293 if (!file.IsValid() && | 293 if (!file.IsValid() && GetLastError() == ERROR_ACCESS_DENIED) { |
| 294 GetLastError() == base::File::FILE_ERROR_ACCESS_DENIED) { | |
| 295 file.Set(CreateFileA(device_path.c_str(), GENERIC_READ, FILE_SHARE_READ, | 294 file.Set(CreateFileA(device_path.c_str(), GENERIC_READ, FILE_SHARE_READ, |
| 296 NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL)); | 295 NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL)); |
| 297 } | 296 } |
| 298 return file.Pass(); | 297 return file.Pass(); |
| 299 } | 298 } |
| 300 | 299 |
| 301 } // namespace device | 300 } // namespace device |
| OLD | NEW |