 Chromium Code Reviews
 Chromium Code Reviews Issue 143883005:
  HID backend  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@hid-impl-base
    
  
    Issue 143883005:
  HID backend  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@hid-impl-base| OLD | NEW | 
|---|---|
| (Empty) | |
| 1 // Copyright (c) 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. | |
| 4 | |
| 5 #ifndef DEVICE_HID_HID_SERVICE_H_ | |
| 6 #define DEVICE_HID_HID_SERVICE_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/basictypes.h" | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/memory/scoped_ptr.h" | |
| 15 #include "base/message_loop/message_loop.h" | |
| 16 #include "base/strings/string16.h" | |
| 17 #include "base/threading/thread_checker.h" | |
| 18 #include "build/build_config.h" | |
| 19 #include "device/hid/hid_device_info.h" | |
| 20 | |
| 21 namespace device { | |
| 22 | |
| 23 namespace { | |
| 24 | |
| 25 class HidServiceContainer; | |
| 26 | |
| 27 } // namespace | |
| 28 | |
| 29 class HidConnection; | |
| 30 class HidService; | |
| 31 | |
| 32 class HidService : public base::MessageLoop::DestructionObserver { | |
| 33 public: | |
| 34 // Must be called on FILE thread. | |
| 35 static HidService* GetInstance(); | |
| 36 | |
| 37 // Enumerates and returns a list of device identifiers. | |
| 38 virtual void GetDevices(std::vector<HidDeviceInfo>* devices); | |
| 39 | |
| 40 virtual scoped_refptr<HidConnection> Connect(std::string device_id) = 0; | |
| 41 | |
| 42 // Implements base::MessageLoop::DestructionObserver | |
| 43 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | |
| 44 | |
| 45 // Gets whether the HidService have been successfully initialized. | |
| 46 bool initialized() const { return initialized_; } | |
| 47 | |
| 48 protected: | |
| 49 friend class HidServiceContainer; | |
| 50 friend struct base::DefaultDeleter<HidService>; | |
| 51 | |
| 52 HidService(); | |
| 53 virtual ~HidService(); | |
| 54 | |
| 55 static HidService* CreateInstance(); | |
| 56 | |
| 57 virtual void DeviceAdd(HidDeviceInfo info); | |
| 
Ken Rockot(use gerrit already)
2014/01/21 23:03:39
nit: I think verb-noun naming would be preferable:
 
Bei Zhang
2014/01/24 12:48:47
Right...
This name was inherited from the good ol
 | |
| 58 virtual void DeviceRemove(std::string device_id); | |
| 59 | |
| 60 typedef std::map<std::string, HidDeviceInfo> DeviceMap; | |
| 61 DeviceMap devices_; | |
| 62 | |
| 63 bool initialized_; | |
| 64 | |
| 65 base::ThreadChecker thread_checker_; | |
| 66 | |
| 67 DISALLOW_COPY_AND_ASSIGN(HidService); | |
| 68 }; | |
| 69 | |
| 70 } // namespace device | |
| 71 | |
| 72 #endif // DEVICE_HID_HID_SERVICE_H_ | |
| OLD | NEW |