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

Side by Side Diff: chrome/browser/usb/usb_service.h

Issue 22914023: Introducing chrome.usb.getDevices/openDevice API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@usb-interface
Patch Set: Fix comments Created 7 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 CHROME_BROWSER_USB_USB_SERVICE_H_ 5 #ifndef CHROME_BROWSER_USB_USB_SERVICE_H_
6 #define CHROME_BROWSER_USB_USB_SERVICE_H_ 6 #define CHROME_BROWSER_USB_USB_SERVICE_H_
7 7
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 27 matching lines...) Expand all
38 // |vendor_id| and |product_id|, inserting them into |devices|. Clears 38 // |vendor_id| and |product_id|, inserting them into |devices|. Clears
39 // |devices| before use. Calls |callback| once |devices| is populated. 39 // |devices| before use. Calls |callback| once |devices| is populated.
40 // The result will be sorted by id in increasing order. Must be called on 40 // The result will be sorted by id in increasing order. Must be called on
41 // FILE thread. 41 // FILE thread.
42 void FindDevices( 42 void FindDevices(
43 const uint16 vendor_id, 43 const uint16 vendor_id,
44 const uint16 product_id, 44 const uint16 product_id,
45 int interface_id, 45 int interface_id,
46 const base::Callback<void(ScopedDeviceVector vector)>& callback); 46 const base::Callback<void(ScopedDeviceVector vector)>& callback);
47 47
48
49 scoped_refptr<UsbDevice> GetDeviceById(uint32 unique_id);
50
48 // Get all of the devices attached to the system, inserting them into 51 // Get all of the devices attached to the system, inserting them into
49 // |devices|. Clears |devices| before use. The result will be sorted by id 52 // |devices|. Clears |devices| before use. The result will be sorted by id
50 // in increasing order. Must be called on FILE thread. 53 // in increasing order. Must be called on FILE thread.
51 void GetDevices(std::vector<scoped_refptr<UsbDevice> >* devices); 54 void GetDevices(std::vector<scoped_refptr<UsbDevice> >* devices);
52 55
53 private: 56 private:
54 friend struct DefaultSingletonTraits<UsbService>; 57 friend struct DefaultSingletonTraits<UsbService>;
55 friend class base::DeleteHelper<UsbService>; 58 friend class base::DeleteHelper<UsbService>;
56 59
57 UsbService(); 60 UsbService();
(...skipping 21 matching lines...) Expand all
79 const uint16 vendor_id, 82 const uint16 vendor_id,
80 const uint16 product_id, 83 const uint16 product_id,
81 const base::Callback<void(ScopedDeviceVector vector)>& callback, 84 const base::Callback<void(ScopedDeviceVector vector)>& callback,
82 bool success); 85 bool success);
83 86
84 // Enumerate USB devices from OS and Update devices_ map. 87 // Enumerate USB devices from OS and Update devices_ map.
85 void RefreshDevices(); 88 void RefreshDevices();
86 89
87 scoped_refptr<UsbContext> context_; 90 scoped_refptr<UsbContext> context_;
88 91
92 uint32 next_unique_id_;
93
89 // The map from PlatformUsbDevices to UsbDevices. 94 // The map from PlatformUsbDevices to UsbDevices.
90 typedef std::map<PlatformUsbDevice, scoped_refptr<UsbDevice> > DeviceMap; 95 typedef std::map<PlatformUsbDevice, scoped_refptr<UsbDevice> > DeviceMap;
91 DeviceMap devices_; 96 DeviceMap devices_;
92 97
93 DISALLOW_COPY_AND_ASSIGN(UsbService); 98 DISALLOW_COPY_AND_ASSIGN(UsbService);
94 }; 99 };
95 100
96 #endif // CHROME_BROWSER_USB_USB_SERVICE_H_ 101 #endif // CHROME_BROWSER_USB_USB_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698