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 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/files/file.h" | 11 #include "base/files/file.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
13 #include "base/numerics/safe_conversions.h" | 14 #include "base/numerics/safe_conversions.h" |
14 #include "base/win/object_watcher.h" | 15 #include "base/win/object_watcher.h" |
15 #include "components/device_event_log/device_event_log.h" | 16 #include "components/device_event_log/device_event_log.h" |
16 | 17 |
17 #define INITGUID | 18 #define INITGUID |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 96 } |
96 | 97 |
97 void PendingHidTransfer::WillDestroyCurrentMessageLoop() { | 98 void PendingHidTransfer::WillDestroyCurrentMessageLoop() { |
98 watcher_.StopWatching(); | 99 watcher_.StopWatching(); |
99 callback_.Run(this, false); | 100 callback_.Run(this, false); |
100 } | 101 } |
101 | 102 |
102 HidConnectionWin::HidConnectionWin(scoped_refptr<HidDeviceInfo> device_info, | 103 HidConnectionWin::HidConnectionWin(scoped_refptr<HidDeviceInfo> device_info, |
103 base::win::ScopedHandle file) | 104 base::win::ScopedHandle file) |
104 : HidConnection(device_info) { | 105 : HidConnection(device_info) { |
105 file_ = file.Pass(); | 106 file_ = std::move(file); |
106 } | 107 } |
107 | 108 |
108 HidConnectionWin::~HidConnectionWin() { | 109 HidConnectionWin::~HidConnectionWin() { |
109 } | 110 } |
110 | 111 |
111 void HidConnectionWin::PlatformClose() { | 112 void HidConnectionWin::PlatformClose() { |
112 CancelIo(file_.Get()); | 113 CancelIo(file_.Get()); |
113 } | 114 } |
114 | 115 |
115 void HidConnectionWin::PlatformRead( | 116 void HidConnectionWin::PlatformRead( |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 if (GetOverlappedResult( | 250 if (GetOverlappedResult( |
250 file_.Get(), transfer->GetOverlapped(), &bytes_transferred, FALSE)) { | 251 file_.Get(), transfer->GetOverlapped(), &bytes_transferred, FALSE)) { |
251 callback.Run(true); | 252 callback.Run(true); |
252 } else { | 253 } else { |
253 HID_PLOG(EVENT) << "HID write failed"; | 254 HID_PLOG(EVENT) << "HID write failed"; |
254 callback.Run(false); | 255 callback.Run(false); |
255 } | 256 } |
256 } | 257 } |
257 | 258 |
258 } // namespace device | 259 } // namespace device |
OLD | NEW |