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

Side by Side Diff: device/hid/hid_service_mac.h

Issue 2780393006: Open IOHIDDevices on the FILE thread (Closed)
Patch Set: Created 3 years, 8 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
« no previous file with comments | « device/hid/hid_connection_mac.cc ('k') | device/hid/hid_service_mac.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 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 #ifndef DEVICE_HID_HID_SERVICE_MAC_H_ 5 #ifndef DEVICE_HID_HID_SERVICE_MAC_H_
6 #define DEVICE_HID_HID_SERVICE_MAC_H_ 6 #define DEVICE_HID_HID_SERVICE_MAC_H_
7 7
8 #include <CoreFoundation/CoreFoundation.h> 8 #include <CoreFoundation/CoreFoundation.h>
9 #include <IOKit/IOKitLib.h> 9 #include <IOKit/IOKitLib.h>
10 #include <IOKit/hid/IOHIDDevice.h>
10 11
11 #include <string> 12 #include <string>
12 13
13 #include "base/mac/foundation_util.h" 14 #include "base/mac/foundation_util.h"
14 #include "base/mac/scoped_ionotificationportref.h" 15 #include "base/mac/scoped_ionotificationportref.h"
15 #include "base/mac/scoped_ioobject.h" 16 #include "base/mac/scoped_ioobject.h"
16 #include "base/macros.h" 17 #include "base/macros.h"
17 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/memory/weak_ptr.h"
18 #include "device/hid/hid_service.h" 20 #include "device/hid/hid_service.h"
19 21
20 namespace base { 22 namespace base {
21 class SingleThreadTaskRunner; 23 class SingleThreadTaskRunner;
22 } 24 }
23 25
24 namespace device { 26 namespace device {
25 27
26 class HidServiceMac : public HidService { 28 class HidServiceMac : public HidService {
27 public: 29 public:
28 HidServiceMac(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); 30 HidServiceMac(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
29 ~HidServiceMac() override; 31 ~HidServiceMac() override;
30 32
31 void Connect(const HidDeviceId& device_id, 33 void Connect(const HidDeviceId& device_id,
32 const ConnectCallback& connect) override; 34 const ConnectCallback& connect) override;
33 35
34 private: 36 private:
37 static void OpenOnBlockingThread(
38 scoped_refptr<HidDeviceInfo> device_info,
39 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
40 base::WeakPtr<HidServiceMac> hid_service,
41 const ConnectCallback& callback);
42 void DeviceOpened(scoped_refptr<HidDeviceInfo> device_info,
43 base::ScopedCFTypeRef<IOHIDDeviceRef> hid_device,
44 const ConnectCallback& callback);
45
35 // IOService matching callbacks. 46 // IOService matching callbacks.
36 static void FirstMatchCallback(void* context, io_iterator_t iterator); 47 static void FirstMatchCallback(void* context, io_iterator_t iterator);
37 static void TerminatedCallback(void* context, io_iterator_t iterator); 48 static void TerminatedCallback(void* context, io_iterator_t iterator);
38 49
39 void AddDevices(); 50 void AddDevices();
40 void RemoveDevices(); 51 void RemoveDevices();
41 52
42 static scoped_refptr<device::HidDeviceInfo> CreateDeviceInfo( 53 static scoped_refptr<device::HidDeviceInfo> CreateDeviceInfo(
43 io_service_t device); 54 io_service_t device);
44 55
45 // Platform notification port. 56 // Platform notification port.
46 base::mac::ScopedIONotificationPortRef notify_port_; 57 base::mac::ScopedIONotificationPortRef notify_port_;
47 base::mac::ScopedIOObject<io_iterator_t> devices_added_iterator_; 58 base::mac::ScopedIOObject<io_iterator_t> devices_added_iterator_;
48 base::mac::ScopedIOObject<io_iterator_t> devices_removed_iterator_; 59 base::mac::ScopedIOObject<io_iterator_t> devices_removed_iterator_;
49 60
50 // The task runner for the thread on which this service was created. 61 // The task runner for the thread on which this service was created.
51 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 62 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
52 63
53 // The task runner for the FILE thread of the application using this service 64 // The task runner for the FILE thread of the application using this service
54 // on which slow running I/O operations can be performed. 65 // on which slow running I/O operations can be performed.
55 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 66 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
56 67
68 base::WeakPtrFactory<HidServiceMac> weak_factory_;
69
57 DISALLOW_COPY_AND_ASSIGN(HidServiceMac); 70 DISALLOW_COPY_AND_ASSIGN(HidServiceMac);
58 }; 71 };
59 72
60 } // namespace device 73 } // namespace device
61 74
62 #endif // DEVICE_HID_HID_SERVICE_MAC_H_ 75 #endif // DEVICE_HID_HID_SERVICE_MAC_H_
OLDNEW
« no previous file with comments | « device/hid/hid_connection_mac.cc ('k') | device/hid/hid_service_mac.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698