RenderText: Allow setting display offset explicitly
[chromium-blink-merge.git] / device / hid / hid_service.h
blobee0ebb7acbb8fe9d6e004cd685b3495c61c73397
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_H_
6 #define DEVICE_HID_HID_SERVICE_H_
8 #include <map>
9 #include <string>
10 #include <vector>
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/message_loop/message_loop.h"
15 #include "base/threading/thread_checker.h"
16 #include "device/hid/hid_device_info.h"
18 namespace device {
20 class HidConnection;
22 class HidService : public base::MessageLoop::DestructionObserver {
23 public:
24 // Must be called on FILE thread.
25 static HidService* GetInstance();
27 // Enumerates and returns a list of device identifiers.
28 virtual void GetDevices(std::vector<HidDeviceInfo>* devices);
30 // Fills in a DeviceInfo struct with info for the given device_id.
31 // Returns |true| if successful or |false| if |device_id| is invalid.
32 bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const;
34 virtual scoped_refptr<HidConnection> Connect(
35 const HidDeviceId& device_id) = 0;
37 // Implements base::MessageLoop::DestructionObserver
38 virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
40 protected:
41 friend struct base::DefaultDeleter<HidService>;
42 friend class HidConnectionTest;
44 typedef std::map<HidDeviceId, HidDeviceInfo> DeviceMap;
46 HidService();
47 virtual ~HidService();
49 static HidService* CreateInstance();
51 void AddDevice(const HidDeviceInfo& info);
52 void RemoveDevice(const HidDeviceId& device_id);
54 base::ThreadChecker thread_checker_;
56 private:
57 DeviceMap devices_;
59 DISALLOW_COPY_AND_ASSIGN(HidService);
62 } // namespace device
64 #endif // DEVICE_HID_HID_SERVICE_H_