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

Unified Diff: device/usb/usb_device.h

Issue 980023002: Move device/usb classes from the FILE thread to UI thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: device/usb/usb_device.h
diff --git a/device/usb/usb_device.h b/device/usb/usb_device.h
index adbd49546caf05df3936ee2f06db54d7b391f525..7596b649e346996478543ed017c16127e2868771 100644
--- a/device/usb/usb_device.h
+++ b/device/usb/usb_device.h
@@ -16,14 +16,23 @@ class UsbDeviceHandle;
struct UsbConfigDescriptor;
// A UsbDevice object represents a detected USB device, providing basic
-// information about it. For further manipulation of the device, a
-// UsbDeviceHandle must be created from Open() method.
+// information about it. Methods other than simple property accessors must be
+// called from the thread on which this object was created. For further
+// manipulation of the device, a UsbDeviceHandle must be created from Open()
+// method.
class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> {
public:
+ typedef base::Callback<void(scoped_refptr<UsbDeviceHandle>)> OpenCallback;
Ken Rockot(use gerrit already) 2015/04/07 22:09:43 nit: Please use aliases instead of typedefs
Reilly Grant (use Gerrit) 2015/04/08 21:39:03 Done.
+
// Accessors to basic information.
uint16 vendor_id() const { return vendor_id_; }
uint16 product_id() const { return product_id_; }
uint32 unique_id() const { return unique_id_; }
+ const base::string16& manufacturer_string() const {
+ return manufacturer_string_;
+ }
+ const base::string16& product_string() const { return product_string_; }
+ const base::string16& serial_number() const { return serial_number_; }
#if defined(OS_CHROMEOS)
// On ChromeOS, if an interface of a claimed device is not claimed, the
@@ -36,39 +45,24 @@ class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> {
#endif // OS_CHROMEOS
// Creates a UsbDeviceHandle for further manipulation.
- // Blocking method. Must be called on FILE thread.
- virtual scoped_refptr<UsbDeviceHandle> Open() = 0;
+ virtual void Open(const OpenCallback& callback) = 0;
// Explicitly closes a device handle. This method will be automatically called
// by the destructor of a UsbDeviceHandle as well.
- // Closing a closed handle is a safe
- // Blocking method. Must be called on FILE thread.
virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) = 0;
// Gets the UsbConfigDescriptor for the active device configuration or nullptr
// if the device is unconfigured.
- // Blocking method. Must be called on FILE thread.
virtual const UsbConfigDescriptor* GetConfiguration() = 0;
- // Gets the manufacturer string of the device, or false and an empty
- // string. This is a blocking method and must be called on FILE thread.
- // TODO(reillyg): Make this available from the UI thread. crbug.com/427985
- virtual bool GetManufacturer(base::string16* manufacturer) = 0;
-
- // Gets the product string of the device, or returns false and an empty
- // string. This is a blocking method and must be called on FILE thread.
- // TODO(reillyg): Make this available from the UI thread. crbug.com/427985
- virtual bool GetProduct(base::string16* product) = 0;
-
- // Gets the serial number string of the device, or returns false and an empty
- // string. This is a blocking method and must be called on FILE thread.
- // TODO(reillyg): Make this available from the UI thread. crbug.com/427985
- virtual bool GetSerialNumber(base::string16* serial) = 0;
-
protected:
- UsbDevice(uint16 vendor_id, uint16 product_id, uint32 unique_id)
- : vendor_id_(vendor_id), product_id_(product_id), unique_id_(unique_id) {}
- virtual ~UsbDevice() {}
+ UsbDevice(uint16 vendor_id,
+ uint16 product_id,
+ uint32 unique_id,
+ const base::string16& manufacturer_string,
+ const base::string16& product_string,
+ const base::string16& serial_number);
+ virtual ~UsbDevice();
private:
friend class base::RefCountedThreadSafe<UsbDevice>;
@@ -76,6 +70,9 @@ class UsbDevice : public base::RefCountedThreadSafe<UsbDevice> {
const uint16 vendor_id_;
const uint16 product_id_;
const uint32 unique_id_;
+ const base::string16 manufacturer_string_;
+ const base::string16 product_string_;
+ const base::string16 serial_number_;
DISALLOW_COPY_AND_ASSIGN(UsbDevice);
};

Powered by Google App Engine
This is Rietveld 408576698