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 |
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" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 Release(); | 95 Release(); |
96 } | 96 } |
97 | 97 |
98 void PendingHidTransfer::WillDestroyCurrentMessageLoop() { | 98 void PendingHidTransfer::WillDestroyCurrentMessageLoop() { |
99 watcher_.StopWatching(); | 99 watcher_.StopWatching(); |
100 connection_->OnTransferCanceled(this); | 100 connection_->OnTransferCanceled(this); |
101 } | 101 } |
102 | 102 |
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()); |
Ken Rockot(use gerrit already)
2014/04/21 20:33:25
nit: Remove extra vertical whitespace.
jracle (use Gerrit)
2014/04/23 07:38:09
sure, sorry. Thought DCHECK(...) was the only line
| |
106 | |
106 file_.Set(CreateFileA(device_info.device_id.c_str(), | 107 file_.Set(CreateFileA(device_info.device_id.c_str(), |
107 GENERIC_WRITE | GENERIC_READ, | 108 GENERIC_WRITE | GENERIC_READ, |
108 FILE_SHARE_READ | FILE_SHARE_WRITE, | 109 FILE_SHARE_READ | FILE_SHARE_WRITE, |
109 NULL, | 110 NULL, |
110 OPEN_EXISTING, | 111 OPEN_EXISTING, |
111 FILE_FLAG_OVERLAPPED, | 112 FILE_FLAG_OVERLAPPED, |
112 NULL)); | 113 NULL)); |
114 | |
115 if (!file_.IsValid() && | |
116 file_.error_details() == base::File::FILE_ERROR_ACCESS_DENIED) { | |
117 file_.Set(CreateFileA(device_info.device_id.c_str(), | |
118 GENERIC_READ, | |
119 FILE_SHARE_READ, | |
120 NULL, | |
121 OPEN_EXISTING, | |
122 FILE_FLAG_OVERLAPPED, | |
123 NULL)); | |
124 } | |
113 } | 125 } |
114 | 126 |
115 bool HidConnectionWin::available() const { | 127 bool HidConnectionWin::available() const { |
116 return file_.IsValid(); | 128 return file_.IsValid(); |
117 } | 129 } |
118 | 130 |
119 HidConnectionWin::~HidConnectionWin() { | 131 HidConnectionWin::~HidConnectionWin() { |
120 DCHECK(thread_checker_.CalledOnValidThread()); | 132 DCHECK(thread_checker_.CalledOnValidThread()); |
121 CancelIo(file_.Get()); | 133 CancelIo(file_.Get()); |
122 } | 134 } |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 } | 291 } |
280 } | 292 } |
281 | 293 |
282 void HidConnectionWin::OnTransferCanceled( | 294 void HidConnectionWin::OnTransferCanceled( |
283 scoped_refptr<PendingHidTransfer> transfer) { | 295 scoped_refptr<PendingHidTransfer> transfer) { |
284 transfers_.erase(transfer); | 296 transfers_.erase(transfer); |
285 transfer->callback_.Run(false, 0); | 297 transfer->callback_.Run(false, 0); |
286 } | 298 } |
287 | 299 |
288 } // namespace device | 300 } // namespace device |
OLD | NEW |