Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: device/hid/hid_connection_mac.cc

Issue 161823002: Clean up HID backend and API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: for reals Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | device/hid/hid_service.h » ('j') | device/hid/hid_service_mac.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | device/hid/hid_service.h » ('j') | device/hid/hid_service_mac.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698