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

Side by Side Diff: components/usb_service/usb_device.h

Issue 497363004: Merge components/usb_service into device/usb. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 6 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
(Empty)
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.
4
5 #ifndef COMPONENTS_USB_SERVICE_USB_DEVICE_H_
6 #define COMPONENTS_USB_SERVICE_USB_DEVICE_H_
7
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/memory/ref_counted.h"
11 #include "components/usb_service/usb_service_export.h"
12
13 namespace usb_service {
14
15 class UsbDeviceHandle;
16 class UsbConfigDescriptor;
17
18 // A UsbDevice object represents a detected USB device, providing basic
19 // information about it. For further manipulation of the device, a
20 // UsbDeviceHandle must be created from Open() method.
21 class USB_SERVICE_EXPORT UsbDevice
22 : public base::RefCountedThreadSafe<UsbDevice> {
23 public:
24 // Accessors to basic information.
25 uint16 vendor_id() const { return vendor_id_; }
26 uint16 product_id() const { return product_id_; }
27 uint32 unique_id() const { return unique_id_; }
28
29 #if defined(OS_CHROMEOS)
30 // On ChromeOS, if an interface of a claimed device is not claimed, the
31 // permission broker can change the owner of the device so that the unclaimed
32 // interfaces can be used. If this argument is missing, permission broker will
33 // not be used and this method fails if the device is claimed.
34 virtual void RequestUsbAccess(
35 int interface_id,
36 const base::Callback<void(bool success)>& callback) = 0;
37 #endif // OS_CHROMEOS
38
39 // Creates a UsbDeviceHandle for further manipulation.
40 // Blocking method. Must be called on FILE thread.
41 virtual scoped_refptr<UsbDeviceHandle> Open() = 0;
42
43 // Explicitly closes a device handle. This method will be automatically called
44 // by the destructor of a UsbDeviceHandle as well.
45 // Closing a closed handle is a safe
46 // Blocking method. Must be called on FILE thread.
47 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) = 0;
48
49 // Lists the interfaces provided by the device and fills the given
50 // UsbConfigDescriptor.
51 // Blocking method. Must be called on FILE thread.
52 virtual scoped_refptr<UsbConfigDescriptor> ListInterfaces() = 0;
53
54 protected:
55 UsbDevice(uint16 vendor_id, uint16 product_id, uint32 unique_id)
56 : vendor_id_(vendor_id), product_id_(product_id), unique_id_(unique_id) {}
57
58 virtual ~UsbDevice() {}
59
60 private:
61 friend class base::RefCountedThreadSafe<UsbDevice>;
62
63 const uint16 vendor_id_;
64 const uint16 product_id_;
65 const uint32 unique_id_;
66
67 DISALLOW_COPY_AND_ASSIGN(UsbDevice);
68 };
69
70 } // namespace usb_service
71
72 #endif // COMPONENTS_USB_SERVICE_USB_DEVICE_H_
OLDNEW
« no previous file with comments | « components/usb_service/usb_context_unittest.cc ('k') | components/usb_service/usb_device_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698