mac: Let IPhotoDataProvider::GetAlbumNames() return albums in a deterministic order.
[chromium-blink-merge.git] / device / hid / hid_service_linux.h
blob45c782d5f95f708b495adc9b2f82c89955d923c7
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);
25 ~HidServiceLinux() override;
27 void Connect(const HidDeviceId& device_id,
28 const ConnectCallback& callback) override;
30 private:
31 struct ConnectParams;
32 class FileThreadHelper;
34 // These functions implement the process of locating, requesting access to and
35 // opening a device. Because this operation crosses multiple threads these
36 // functions are static and the necessary parameters are passed as a single
37 // struct.
38 #if defined(OS_CHROMEOS)
39 static void OnPathOpened(scoped_ptr<ConnectParams> params,
40 dbus::FileDescriptor fd);
41 static void ValidateFdOnBlockingThread(scoped_ptr<ConnectParams> params,
42 dbus::FileDescriptor fd);
43 #else
44 static void OpenOnBlockingThread(scoped_ptr<ConnectParams> params);
45 #endif
46 static void FinishOpen(scoped_ptr<ConnectParams> params);
47 static void CreateConnection(scoped_ptr<ConnectParams> params);
49 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
50 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
52 // The helper lives on the FILE thread and holds a weak reference back to the
53 // service that owns it.
54 FileThreadHelper* helper_;
55 base::WeakPtrFactory<HidServiceLinux> weak_factory_;
57 DISALLOW_COPY_AND_ASSIGN(HidServiceLinux);
60 } // namespace device
62 #endif // DEVICE_HID_HID_SERVICE_LINUX_H_