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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/files/file.h" | 10 #include "base/files/file.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/numerics/safe_conversions.h" | 12 #include "base/numerics/safe_conversions.h" |
13 #include "base/profiler/scoped_profile.h" | 13 #include "base/profiler/scoped_tracker.h" |
14 #include "base/win/object_watcher.h" | 14 #include "base/win/object_watcher.h" |
15 | 15 |
16 #define INITGUID | 16 #define INITGUID |
17 | 17 |
18 #include <windows.h> | 18 #include <windows.h> |
19 #include <hidclass.h> | 19 #include <hidclass.h> |
20 | 20 |
21 extern "C" { | 21 extern "C" { |
22 #include <hidsdi.h> | 22 #include <hidsdi.h> |
23 } | 23 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 base::MessageLoop::current()->AddDestructionObserver(this); | 82 base::MessageLoop::current()->AddDestructionObserver(this); |
83 AddRef(); | 83 AddRef(); |
84 watcher_.StartWatching(event_.Get(), this); | 84 watcher_.StartWatching(event_.Get(), this); |
85 } else { | 85 } else { |
86 VPLOG(1) << "HID transfer failed"; | 86 VPLOG(1) << "HID transfer failed"; |
87 callback_.Run(this, false); | 87 callback_.Run(this, false); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 void PendingHidTransfer::OnObjectSignaled(HANDLE event_handle) { | 91 void PendingHidTransfer::OnObjectSignaled(HANDLE event_handle) { |
92 // TODO(vadimt): Remove ScopedProfile below once crbug.com/418183 is fixed. | 92 // TODO(vadimt): Remove ScopedTracker below once crbug.com/418183 is fixed. |
93 tracked_objects::ScopedProfile tracking_profile( | 93 tracked_objects::ScopedTracker tracking_profile( |
94 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 94 FROM_HERE_WITH_EXPLICIT_FUNCTION("PendingHidTransfer_OnObjectSignaled")); |
95 "PendingHidTransfer_OnObjectSignaled")); | |
96 | 95 |
97 callback_.Run(this, true); | 96 callback_.Run(this, true); |
98 Release(); | 97 Release(); |
99 } | 98 } |
100 | 99 |
101 void PendingHidTransfer::WillDestroyCurrentMessageLoop() { | 100 void PendingHidTransfer::WillDestroyCurrentMessageLoop() { |
102 watcher_.StopWatching(); | 101 watcher_.StopWatching(); |
103 callback_.Run(this, false); | 102 callback_.Run(this, false); |
104 } | 103 } |
105 | 104 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 if (GetOverlappedResult( | 257 if (GetOverlappedResult( |
259 file_.Get(), transfer->GetOverlapped(), &bytes_transferred, FALSE)) { | 258 file_.Get(), transfer->GetOverlapped(), &bytes_transferred, FALSE)) { |
260 callback.Run(true); | 259 callback.Run(true); |
261 } else { | 260 } else { |
262 VPLOG(1) << "HID write failed"; | 261 VPLOG(1) << "HID write failed"; |
263 callback.Run(false); | 262 callback.Run(false); |
264 } | 263 } |
265 } | 264 } |
266 | 265 |
267 } // namespace device | 266 } // namespace device |
OLD | NEW |