| 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_mac.h" | 5 #include "device/hid/hid_connection_mac.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 CFRetain(device); | 32 CFRetain(device); |
| 33 inbound_buffer_.reset((uint8_t*) malloc(device_info.input_report_size + 1)); | 33 inbound_buffer_.reset((uint8_t*) malloc(device_info.input_report_size + 1)); |
| 34 IOHIDDeviceRegisterInputReportCallback( | 34 IOHIDDeviceRegisterInputReportCallback( |
| 35 device_.get(), | 35 device_.get(), |
| 36 inbound_buffer_.get(), | 36 inbound_buffer_.get(), |
| 37 device_info.input_report_size + 1, | 37 device_info.input_report_size + 1, |
| 38 &HidConnectionMac::InputReportCallback, | 38 &HidConnectionMac::InputReportCallback, |
| 39 this); | 39 this); |
| 40 IOHIDDeviceOpen(device_, kIOHIDOptionsTypeNone); | 40 IOHIDDeviceOpen(device_, kIOHIDOptionsTypeNone); |
| 41 } | 41 } |
| 42 |
| 42 HidConnectionMac::~HidConnectionMac() { | 43 HidConnectionMac::~HidConnectionMac() { |
| 43 DCHECK(thread_checker_.CalledOnValidThread()); | 44 DCHECK(thread_checker_.CalledOnValidThread()); |
| 44 | 45 |
| 45 while (read_queue_.size()) { | 46 while (read_queue_.size()) { |
| 46 read_queue_.front().c.Run(false, 0); | 47 read_queue_.front().c.Run(false, 0); |
| 47 read_queue_.pop(); | 48 read_queue_.pop(); |
| 48 } | 49 } |
| 49 | 50 |
| 50 IOHIDDeviceClose(device_, kIOHIDOptionsTypeNone); | 51 IOHIDDeviceClose(device_, kIOHIDOptionsTypeNone); |
| 51 } | 52 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 0, | 180 0, |
| 180 (uint8_t*) buffer->data(), | 181 (uint8_t*) buffer->data(), |
| 181 &len); | 182 &len); |
| 182 if (res == kIOReturnSuccess) | 183 if (res == kIOReturnSuccess) |
| 183 callback.Run(true, len); | 184 callback.Run(true, len); |
| 184 else | 185 else |
| 185 callback.Run(false, 0); | 186 callback.Run(false, 0); |
| 186 } | 187 } |
| 187 | 188 |
| 188 } // namespace device | 189 } // namespace device |
| OLD | NEW |