| 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" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 PendingHidTransfer::~PendingHidTransfer() { | 74 PendingHidTransfer::~PendingHidTransfer() { |
| 75 base::MessageLoop::current()->RemoveDestructionObserver(this); | 75 base::MessageLoop::current()->RemoveDestructionObserver(this); |
| 76 } | 76 } |
| 77 | 77 |
| 78 void PendingHidTransfer::TakeResultFromWindowsAPI(BOOL result) { | 78 void PendingHidTransfer::TakeResultFromWindowsAPI(BOOL result) { |
| 79 if (result) { | 79 if (result) { |
| 80 callback_.Run(this, true); | 80 callback_.Run(this, true); |
| 81 } else if (GetLastError() == ERROR_IO_PENDING) { | 81 } else if (GetLastError() == ERROR_IO_PENDING) { |
| 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, false); |
| 85 } else { | 85 } else { |
| 86 HID_PLOG(EVENT) << "HID transfer failed"; | 86 HID_PLOG(EVENT) << "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 callback_.Run(this, true); | 92 callback_.Run(this, true); |
| 93 Release(); | 93 Release(); |
| 94 } | 94 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 if (GetOverlappedResult( | 248 if (GetOverlappedResult( |
| 249 file_.Get(), transfer->GetOverlapped(), &bytes_transferred, FALSE)) { | 249 file_.Get(), transfer->GetOverlapped(), &bytes_transferred, FALSE)) { |
| 250 callback.Run(true); | 250 callback.Run(true); |
| 251 } else { | 251 } else { |
| 252 HID_PLOG(EVENT) << "HID write failed"; | 252 HID_PLOG(EVENT) << "HID write failed"; |
| 253 callback.Run(false); | 253 callback.Run(false); |
| 254 } | 254 } |
| 255 } | 255 } |
| 256 | 256 |
| 257 } // namespace device | 257 } // namespace device |
| OLD | NEW |