GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / device / hid / hid_service_linux.h
blob3cb75c5696389726c033bb21c9579d5252e73be8
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 device {
16 class HidConnection;
18 class HidServiceLinux : public HidService {
19 public:
20 HidServiceLinux(scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner);
22 void Connect(const HidDeviceId& device_id,
23 const ConnectCallback& callback) override;
25 private:
26 struct ConnectParams;
27 class FileThreadHelper;
29 ~HidServiceLinux() override;
31 // Constructs this services helper object that lives on the FILE thread.
32 static void StartHelper(
33 base::WeakPtr<HidServiceLinux> weak_ptr,
34 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
36 // These functions implement the process of locating, requesting access to and
37 // opening a device. Because this operation crosses multiple threads these
38 // functions are static and the necessary parameters are passed as a single
39 // struct.
40 #if defined(OS_CHROMEOS)
41 static void OnRequestPathAccessComplete(scoped_ptr<ConnectParams> params,
42 bool success);
43 #endif // defined(OS_CHROMEOS)
44 static void OpenDevice(scoped_ptr<ConnectParams> params);
45 static void ConnectImpl(scoped_ptr<ConnectParams> params);
47 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
48 scoped_refptr<base::SingleThreadTaskRunner> file_task_runner_;
50 // The helper lives on the FILE thread and holds a weak reference back to the
51 // service that owns it.
52 scoped_ptr<FileThreadHelper> helper_;
53 base::WeakPtrFactory<HidServiceLinux> weak_factory_;
55 DISALLOW_COPY_AND_ASSIGN(HidServiceLinux);
58 } // namespace device
60 #endif // DEVICE_HID_HID_SERVICE_LINUX_H_