#ifndef DEVICE_HID_HID_SERVICE_H_
#define DEVICE_HID_HID_SERVICE_H_
#include <map>
#include <string>
#include <vector>
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/thread_checker.h"
#include "device/hid/hid_device_info.h"
namespace device {
class HidConnection;
class HidService : public base::MessageLoop::DestructionObserver {
public:
static HidService* GetInstance();
virtual void GetDevices(std::vector<HidDeviceInfo>* devices);
bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const;
virtual scoped_refptr<HidConnection> Connect(
const HidDeviceId& device_id) = 0;
virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
protected:
friend struct base::DefaultDeleter<HidService>;
friend class HidConnectionTest;
typedef std::map<HidDeviceId, HidDeviceInfo> DeviceMap;
HidService();
virtual ~HidService();
static HidService* CreateInstance();
void AddDevice(const HidDeviceInfo& info);
void RemoveDevice(const HidDeviceId& device_id);
base::ThreadChecker thread_checker_;
private:
DeviceMap devices_;
DISALLOW_COPY_AND_ASSIGN(HidService);
};
}
#endif