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

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

Issue 771393002: Migrate HidServiceLinux and HidConnectionLinux to BrowserThread::UI. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix HID receive buffer size. Created 6 years 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
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_LINUX_H_ 5 #ifndef DEVICE_HID_HID_SERVICE_LINUX_H_
6 #define DEVICE_HID_HID_SERVICE_LINUX_H_ 6 #define DEVICE_HID_HID_SERVICE_LINUX_H_
7 7
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h" 10 #include "base/memory/weak_ptr.h"
11 #include "device/hid/device_monitor_linux.h"
12 #include "device/hid/hid_device_info.h" 11 #include "device/hid/hid_device_info.h"
13 #include "device/hid/hid_service.h" 12 #include "device/hid/hid_service.h"
14 13
15 struct udev_device;
16
17 namespace device { 14 namespace device {
18 15
19 class HidConnection; 16 class HidConnection;
20 17
21 class HidServiceLinux : public HidService, 18 class HidServiceLinux : public HidService {
22 public DeviceMonitorLinux::Observer {
23 public: 19 public:
24 HidServiceLinux(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); 20 HidServiceLinux(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
25 21
26 void Connect(const HidDeviceId& device_id, 22 void Connect(const HidDeviceId& device_id,
27 const ConnectCallback& callback) override; 23 const ConnectCallback& callback) override;
28 24
29 // Implements DeviceMonitorLinux::Observer: 25 private:
30 void OnDeviceAdded(udev_device* device) override; 26 struct ConnectParams;
31 void OnDeviceRemoved(udev_device* device) override; 27 class Helper;
28 friend class Helper;
32 29
33 private:
34 ~HidServiceLinux() override; 30 ~HidServiceLinux() override;
35 31
36 void FinishConnect(const HidDeviceId& device_id, 32 // Constructs this services helper object that lives on the FILE thread.
37 const std::string device_node, 33 static void StartHelper(
38 const ConnectCallback& callback, 34 base::WeakPtr<HidServiceLinux> weak_ptr,
39 bool success); 35 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
36
37 // These functions implement the process of locating, requesting access to and
Ken Rockot(use gerrit already) 2014/12/03 22:35:10 nit: I would maybe indent this with the inner clas
Reilly Grant (use Gerrit) 2014/12/03 23:10:28 Done.
38 // opening a device. Because this operation crosses multiple threads these
39 // functions are static and the necessary parameters are passed as a single
40 // struct.
41 #if defined(OS_CHROMEOS)
42 static void OnRequestPathAccessComplete(scoped_ptr<ConnectParams> params,
43 bool success);
44 #endif // defined(OS_CHROMEOS)
45 static void OpenDevice(scoped_ptr<ConnectParams> params);
46 static void ConnectImpl(scoped_ptr<ConnectParams> params);
40 47
41 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 48 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
42 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 49 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
43 50
51 // The helper lives on the FILE thread and holds a weak reference back to the
52 // service that owns it.
44 base::WeakPtrFactory<HidServiceLinux> weak_factory_; 53 base::WeakPtrFactory<HidServiceLinux> weak_factory_;
54 scoped_ptr<Helper> helper_;
45 55
46 DISALLOW_COPY_AND_ASSIGN(HidServiceLinux); 56 DISALLOW_COPY_AND_ASSIGN(HidServiceLinux);
47 }; 57 };
48 58
49 } // namespace device 59 } // namespace device
50 60
51 #endif // DEVICE_HID_HID_SERVICE_LINUX_H_ 61 #endif // DEVICE_HID_HID_SERVICE_LINUX_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698