[SyncFS] Run RemoteToLocalSyncer as a background task
[chromium-blink-merge.git] / device / usb / usb_device_impl.h
blobe95c8dbc9add72a27033e2a7da9300b4a82d493b
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.
5 #ifndef DEVICE_USB_USB_DEVICE_IMPL_H_
6 #define DEVICE_USB_USB_DEVICE_IMPL_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/threading/thread_checker.h"
13 #include "device/usb/usb_descriptors.h"
14 #include "device/usb/usb_device.h"
16 struct libusb_device;
17 struct libusb_config_descriptor;
19 namespace base {
20 class SingleThreadTaskRunner;
23 namespace device {
25 class UsbDeviceHandleImpl;
26 class UsbContext;
28 typedef libusb_device* PlatformUsbDevice;
29 typedef libusb_config_descriptor* PlatformUsbConfigDescriptor;
31 class UsbDeviceImpl : public UsbDevice {
32 public:
33 // UsbDevice implementation:
34 #if defined(OS_CHROMEOS)
35 virtual void RequestUsbAccess(
36 int interface_id,
37 const base::Callback<void(bool success)>& callback) OVERRIDE;
38 #endif // OS_CHROMEOS
39 virtual scoped_refptr<UsbDeviceHandle> Open() OVERRIDE;
40 virtual bool Close(scoped_refptr<UsbDeviceHandle> handle) OVERRIDE;
41 virtual const UsbConfigDescriptor& GetConfiguration() OVERRIDE;
43 protected:
44 friend class UsbServiceImpl;
46 // Called by UsbServiceImpl only;
47 UsbDeviceImpl(scoped_refptr<UsbContext> context,
48 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
49 PlatformUsbDevice platform_device,
50 uint16 vendor_id,
51 uint16 product_id,
52 uint32 unique_id);
54 virtual ~UsbDeviceImpl();
56 // Called only be UsbService.
57 void OnDisconnect();
59 private:
60 base::ThreadChecker thread_checker_;
61 PlatformUsbDevice platform_device_;
63 // The active configuration descriptor is not read immediately but cached for
64 // later use.
65 bool current_configuration_cached_;
66 UsbConfigDescriptor current_configuration_;
68 // Retain the context so that it will not be released before UsbDevice.
69 scoped_refptr<UsbContext> context_;
71 // Opened handles.
72 typedef std::vector<scoped_refptr<UsbDeviceHandleImpl> > HandlesVector;
73 HandlesVector handles_;
75 // Reference to the UI thread for permission-broker calls.
76 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
78 DISALLOW_COPY_AND_ASSIGN(UsbDeviceImpl);
81 } // namespace device
83 #endif // DEVICE_USB_USB_DEVICE_IMPL_H_