Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: device/hid/hid_service.h

Issue 419713002: Support permission_broker for chrome.hid devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add NOTIMPLEMENTED to default GetHidService implementation. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DEVICE_HID_HID_SERVICE_H_ 5 #ifndef DEVICE_HID_HID_SERVICE_H_
6 #define DEVICE_HID_HID_SERVICE_H_ 6 #define DEVICE_HID_HID_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/message_loop/message_loop_proxy.h"
14 #include "base/message_loop/message_loop.h"
15 #include "base/threading/thread_checker.h" 14 #include "base/threading/thread_checker.h"
16 #include "device/hid/hid_device_info.h" 15 #include "device/hid/hid_device_info.h"
17 16
18 namespace device { 17 namespace device {
19 18
20 class HidConnection; 19 class HidConnection;
21 20
22 class HidService : public base::MessageLoop::DestructionObserver { 21 class HidService {
23 public: 22 public:
24 // Must be called on FILE thread. 23 static HidService* Create(
25 static HidService* GetInstance(); 24 scoped_refptr<base::MessageLoopProxy> ui_message_loop);
25
26 virtual ~HidService();
26 27
27 // Enumerates and returns a list of device identifiers. 28 // Enumerates and returns a list of device identifiers.
28 virtual void GetDevices(std::vector<HidDeviceInfo>* devices); 29 virtual void GetDevices(std::vector<HidDeviceInfo>* devices);
29 30
30 // Fills in a DeviceInfo struct with info for the given device_id. 31 // 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 // Returns |true| if successful or |false| if |device_id| is invalid.
32 bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const; 33 bool GetDeviceInfo(const HidDeviceId& device_id, HidDeviceInfo* info) const;
33 34
34 virtual scoped_refptr<HidConnection> Connect( 35 virtual scoped_refptr<HidConnection> Connect(
35 const HidDeviceId& device_id) = 0; 36 const HidDeviceId& device_id) = 0;
36 37
37 // Implements base::MessageLoop::DestructionObserver
38 virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
39
40 protected: 38 protected:
41 friend struct base::DefaultDeleter<HidService>;
42 friend class HidConnectionTest; 39 friend class HidConnectionTest;
43 40
44 typedef std::map<HidDeviceId, HidDeviceInfo> DeviceMap; 41 typedef std::map<HidDeviceId, HidDeviceInfo> DeviceMap;
45 42
46 HidService(); 43 HidService();
47 virtual ~HidService();
48
49 static HidService* CreateInstance();
50 44
51 void AddDevice(const HidDeviceInfo& info); 45 void AddDevice(const HidDeviceInfo& info);
52 void RemoveDevice(const HidDeviceId& device_id); 46 void RemoveDevice(const HidDeviceId& device_id);
53 const DeviceMap& GetDevicesNoEnumerate() const; 47 const DeviceMap& GetDevicesNoEnumerate() const;
54 48
55 base::ThreadChecker thread_checker_; 49 base::ThreadChecker thread_checker_;
56 50
57 private: 51 private:
58 DeviceMap devices_; 52 DeviceMap devices_;
59 53
60 DISALLOW_COPY_AND_ASSIGN(HidService); 54 DISALLOW_COPY_AND_ASSIGN(HidService);
61 }; 55 };
62 56
63 } // namespace device 57 } // namespace device
64 58
65 #endif // DEVICE_HID_HID_SERVICE_H_ 59 #endif // DEVICE_HID_HID_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698