OLD | NEW |
---|---|
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_connection_win.h" | 5 #include "device/hid/hid_connection_win.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
Ken Rockot(use gerrit already)
2014/04/23 23:24:28
Looks like you forgot to include base/files/file.h
jracle (use Gerrit)
2014/04/24 08:30:48
Oops wtf
| |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
11 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
12 #include "base/win/object_watcher.h" | 12 #include "base/win/object_watcher.h" |
13 #include "base/win/scoped_handle.h" | 13 #include "base/win/scoped_handle.h" |
14 #include "device/hid/hid_service.h" | 14 #include "device/hid/hid_service.h" |
15 #include "device/hid/hid_service_win.h" | 15 #include "device/hid/hid_service_win.h" |
16 | 16 |
17 #define INITGUID | 17 #define INITGUID |
18 | 18 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 HidConnectionWin::HidConnectionWin(const HidDeviceInfo& device_info) | 103 HidConnectionWin::HidConnectionWin(const HidDeviceInfo& device_info) |
104 : HidConnection(device_info) { | 104 : HidConnection(device_info) { |
105 DCHECK(thread_checker_.CalledOnValidThread()); | 105 DCHECK(thread_checker_.CalledOnValidThread()); |
106 file_.Set(CreateFileA(device_info.device_id.c_str(), | 106 file_.Set(CreateFileA(device_info.device_id.c_str(), |
107 GENERIC_WRITE | GENERIC_READ, | 107 GENERIC_WRITE | GENERIC_READ, |
108 FILE_SHARE_READ | FILE_SHARE_WRITE, | 108 FILE_SHARE_READ | FILE_SHARE_WRITE, |
109 NULL, | 109 NULL, |
110 OPEN_EXISTING, | 110 OPEN_EXISTING, |
111 FILE_FLAG_OVERLAPPED, | 111 FILE_FLAG_OVERLAPPED, |
112 NULL)); | 112 NULL)); |
113 | |
114 if (!file_.IsValid() && | |
115 file_.error_details() == base::File::FILE_ERROR_ACCESS_DENIED) { | |
116 file_.Set(CreateFileA(device_info.device_id.c_str(), | |
117 GENERIC_READ, | |
118 FILE_SHARE_READ, | |
119 NULL, | |
120 OPEN_EXISTING, | |
121 FILE_FLAG_OVERLAPPED, | |
122 NULL)); | |
123 } | |
113 } | 124 } |
114 | 125 |
115 bool HidConnectionWin::available() const { | 126 bool HidConnectionWin::available() const { |
116 return file_.IsValid(); | 127 return file_.IsValid(); |
117 } | 128 } |
118 | 129 |
119 HidConnectionWin::~HidConnectionWin() { | 130 HidConnectionWin::~HidConnectionWin() { |
120 DCHECK(thread_checker_.CalledOnValidThread()); | 131 DCHECK(thread_checker_.CalledOnValidThread()); |
121 CancelIo(file_.Get()); | 132 CancelIo(file_.Get()); |
122 } | 133 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 } | 290 } |
280 } | 291 } |
281 | 292 |
282 void HidConnectionWin::OnTransferCanceled( | 293 void HidConnectionWin::OnTransferCanceled( |
283 scoped_refptr<PendingHidTransfer> transfer) { | 294 scoped_refptr<PendingHidTransfer> transfer) { |
284 transfers_.erase(transfer); | 295 transfers_.erase(transfer); |
285 transfer->callback_.Run(false, 0); | 296 transfer->callback_.Run(false, 0); |
286 } | 297 } |
287 | 298 |
288 } // namespace device | 299 } // namespace device |
OLD | NEW |