Add ICU message format support
[chromium-blink-merge.git] / device / hid / hid_service_linux.h
blob66cfbd3a4412a8982c4cff06666b2f35f09e4800
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
3 // found in the LICENSE file.
5 #ifndef DEVICE_HID_HID_SERVICE_LINUX_H_
6 #define DEVICE_HID_HID_SERVICE_LINUX_H_
8 #include "base/compiler_specific.h"
9 #include "base/macros.h"
10 #include "base/memory/weak_ptr.h"
11 #include "device/hid/hid_device_info.h"
12 #include "device/hid/hid_service.h"
14 namespace dbus {
15 class FileDescriptor;
18 namespace device {
20 class HidConnection;
22 class HidServiceLinux : public HidService {
23 public:
24 HidServiceLinux(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
26 void Connect(const HidDeviceId& device_id,
27 const ConnectCallback& callback) override;
29 private:
30 struct ConnectParams;
31 class FileThreadHelper;
33 ~HidServiceLinux() override;
35 // Constructs this services helper object that lives on the FILE thread.
36 static void StartHelper(
37 base::WeakPtr<HidServiceLinux> weak_ptr,
38 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
40 // These functions implement the process of locating, requesting access to and
41 // opening a device. Because this operation crosses multiple threads these
42 // functions are static and the necessary parameters are passed as a single
43 // struct.
44 #if defined(OS_CHROMEOS)
45 static void OnPathOpened(scoped_ptr<ConnectParams> params,
46 dbus::FileDescriptor fd);
47 static void ValidateFdOnBlockingThread(scoped_ptr<ConnectParams> params,
48 dbus::FileDescriptor fd);
49 #else
50 static void OpenOnBlockingThread(scoped_ptr<ConnectParams> params);
51 #endif
52 static void FinishOpen(scoped_ptr<ConnectParams> params);
53 static void CreateConnection(scoped_ptr<ConnectParams> params);
55 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
56 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
58 // The helper lives on the FILE thread and holds a weak reference back to the
59 // service that owns it.
60 scoped_ptr<FileThreadHelper> helper_;
61 base::WeakPtrFactory<HidServiceLinux> weak_factory_;
63 DISALLOW_COPY_AND_ASSIGN(HidServiceLinux);
66 } // namespace device
68 #endif // DEVICE_HID_HID_SERVICE_LINUX_H_