#ifndef SERVICES_DEVICE_HID_INPUT_SERVICE_LINUX_H_
#define SERVICES_DEVICE_HID_INPUT_SERVICE_LINUX_H_
#include <map>
#include <memory>
#include <string>
#include <vector>
#include "base/compiler_specific.h"
#include "base/threading/thread_checker.h"
#include "mojo/public/cpp/bindings/pending_associated_remote.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/receiver_set.h"
#include "mojo/public/cpp/bindings/remote_set.h"
#include "services/device/public/mojom/input_service.mojom.h"
namespace device {
class InputServiceLinux : public mojom::InputDeviceManager {
public:
using DeviceMap = std::map<std::string, mojom::InputDeviceInfoPtr>;
InputServiceLinux();
InputServiceLinux(const InputServiceLinux&) = delete;
InputServiceLinux& operator=(const InputServiceLinux&) = delete;
~InputServiceLinux() override;
static void BindReceiver(
mojo::PendingReceiver<mojom::InputDeviceManager> receiver);
static InputServiceLinux* GetInstance();
static bool HasInstance();
static void SetForTesting(std::unique_ptr<InputServiceLinux> service);
void AddReceiver(mojo::PendingReceiver<mojom::InputDeviceManager> receiver);
void GetDevicesAndSetClient(
mojo::PendingAssociatedRemote<mojom::InputDeviceManagerClient> client,
GetDevicesCallback callback) override;
void GetDevices(GetDevicesCallback callback) override;
protected:
void AddDevice(mojom::InputDeviceInfoPtr info);
void RemoveDevice(const std::string& id);
bool CalledOnValidThread() const;
DeviceMap devices_;
private:
base::ThreadChecker thread_checker_;
mojo::ReceiverSet<mojom::InputDeviceManager> receivers_;
mojo::AssociatedRemoteSet<mojom::InputDeviceManagerClient> clients_;
};
}
#endif