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

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

Issue 1312993008: Manage HidService lifetime in DeviceClient implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove_usb_service_get_instance
Patch Set: Created 5 years, 3 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_service.cc ('k') | device/hid/hid_service_linux.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_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/hid_device_info.h" 11 #include "device/hid/hid_device_info.h"
12 #include "device/hid/hid_service.h" 12 #include "device/hid/hid_service.h"
13 13
14 namespace dbus { 14 namespace dbus {
15 class FileDescriptor; 15 class FileDescriptor;
16 } 16 }
17 17
18 namespace device { 18 namespace device {
19 19
20 class HidConnection; 20 class HidConnection;
21 21
22 class HidServiceLinux : public HidService { 22 class HidServiceLinux : public HidService {
23 public: 23 public:
24 HidServiceLinux(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); 24 HidServiceLinux(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
25 ~HidServiceLinux() override;
25 26
26 void Connect(const HidDeviceId& device_id, 27 void Connect(const HidDeviceId& device_id,
27 const ConnectCallback& callback) override; 28 const ConnectCallback& callback) override;
28 29
29 private: 30 private:
30 struct ConnectParams; 31 struct ConnectParams;
31 class FileThreadHelper; 32 class FileThreadHelper;
32 33
33 ~HidServiceLinux() override;
34
35 // These functions implement the process of locating, requesting access to and 34 // These functions implement the process of locating, requesting access to and
36 // opening a device. Because this operation crosses multiple threads these 35 // opening a device. Because this operation crosses multiple threads these
37 // functions are static and the necessary parameters are passed as a single 36 // functions are static and the necessary parameters are passed as a single
38 // struct. 37 // struct.
39 #if defined(OS_CHROMEOS) 38 #if defined(OS_CHROMEOS)
40 static void OnPathOpened(scoped_ptr<ConnectParams> params, 39 static void OnPathOpened(scoped_ptr<ConnectParams> params,
41 dbus::FileDescriptor fd); 40 dbus::FileDescriptor fd);
42 static void ValidateFdOnBlockingThread(scoped_ptr<ConnectParams> params, 41 static void ValidateFdOnBlockingThread(scoped_ptr<ConnectParams> params,
43 dbus::FileDescriptor fd); 42 dbus::FileDescriptor fd);
44 #else 43 #else
45 static void OpenOnBlockingThread(scoped_ptr<ConnectParams> params); 44 static void OpenOnBlockingThread(scoped_ptr<ConnectParams> params);
46 #endif 45 #endif
47 static void FinishOpen(scoped_ptr<ConnectParams> params); 46 static void FinishOpen(scoped_ptr<ConnectParams> params);
48 static void CreateConnection(scoped_ptr<ConnectParams> params); 47 static void CreateConnection(scoped_ptr<ConnectParams> params);
49 48
50 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 49 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
51 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_; 50 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
52 51
53 // The helper lives on the FILE thread and holds a weak reference back to the 52 // The helper lives on the FILE thread and holds a weak reference back to the
54 // service that owns it. 53 // service that owns it.
55 FileThreadHelper* helper_; 54 FileThreadHelper* helper_;
56 base::WeakPtrFactory<HidServiceLinux> weak_factory_; 55 base::WeakPtrFactory<HidServiceLinux> weak_factory_;
57 56
58 DISALLOW_COPY_AND_ASSIGN(HidServiceLinux); 57 DISALLOW_COPY_AND_ASSIGN(HidServiceLinux);
59 }; 58 };
60 59
61 } // namespace device 60 } // namespace device
62 61
63 #endif // DEVICE_HID_HID_SERVICE_LINUX_H_ 62 #endif // DEVICE_HID_HID_SERVICE_LINUX_H_
OLDNEW
« no previous file with comments | « device/hid/hid_service.cc ('k') | device/hid/hid_service_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698