Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / components / usb_service / usb_service.h
blob133cacd7e57374c23a331bcc53ff29b4344b34a1
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 COMPONENTS_USB_SERVICE_USB_SERVICE_H_
6 #define COMPONENTS_USB_SERVICE_USB_SERVICE_H_
8 #include <vector>
10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "components/usb_service/usb_service_export.h"
15 namespace usb_service {
17 class UsbDevice;
19 // The USB service handles creating and managing an event handler thread that is
20 // used to manage and dispatch USB events. It is also responsible for device
21 // discovery on the system, which allows it to re-use device handles to prevent
22 // competition for the same USB device.
23 class USB_SERVICE_EXPORT UsbService : public base::NonThreadSafe {
24 public:
25 // Must be called on FILE thread.
26 // Returns NULL when failed to initialized.
27 static UsbService* GetInstance();
29 static void SetInstanceForTest(UsbService* instance);
31 virtual scoped_refptr<UsbDevice> GetDeviceById(uint32 unique_id) = 0;
33 // Get all of the devices attached to the system, inserting them into
34 // |devices|. Clears |devices| before use. The result will be sorted by id
35 // in increasing order. Must be called on FILE thread.
36 virtual void GetDevices(std::vector<scoped_refptr<UsbDevice> >* devices) = 0;
38 protected:
39 friend struct base::DefaultDeleter<UsbService>;
40 UsbService() {}
41 virtual ~UsbService() {}
42 DISALLOW_COPY_AND_ASSIGN(UsbService);
45 } // namespace usb_service
47 #endif // COMPONENTS_USB_SERVICE_USB_SERVICE_H_