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

Unified Diff: components/usb_service/usb_service.h

Issue 258783002: Extracted UsbService as interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed chromeos issue. Created 6 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
« no previous file with comments | « components/usb_service/usb_interface.cc ('k') | components/usb_service/usb_service.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/usb_service/usb_service.h
diff --git a/components/usb_service/usb_service.h b/components/usb_service/usb_service.h
index 3bf0a40a0bc22d5c4303cd62c47b920725d8b85f..133cacd7e57374c23a331bcc53ff29b4344b34a1 100644
--- a/components/usb_service/usb_service.h
+++ b/components/usb_service/usb_service.h
@@ -5,71 +5,40 @@
#ifndef COMPONENTS_USB_SERVICE_USB_SERVICE_H_
#define COMPONENTS_USB_SERVICE_USB_SERVICE_H_
-#include <map>
-#include <utility>
#include <vector>
-#include "base/basictypes.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
-#include "base/message_loop/message_loop.h"
#include "base/threading/non_thread_safe.h"
#include "components/usb_service/usb_service_export.h"
-struct libusb_device;
-struct libusb_context;
-
namespace usb_service {
-typedef struct libusb_device* PlatformUsbDevice;
-typedef struct libusb_context* PlatformUsbContext;
-
-class UsbContext;
class UsbDevice;
// The USB service handles creating and managing an event handler thread that is
// used to manage and dispatch USB events. It is also responsible for device
// discovery on the system, which allows it to re-use device handles to prevent
// competition for the same USB device.
-class USB_SERVICE_EXPORT UsbService
- : public base::MessageLoop::DestructionObserver,
- public base::NonThreadSafe {
+class USB_SERVICE_EXPORT UsbService : public base::NonThreadSafe {
public:
- typedef scoped_ptr<std::vector<scoped_refptr<UsbDevice> > >
- ScopedDeviceVector;
-
// Must be called on FILE thread.
// Returns NULL when failed to initialized.
static UsbService* GetInstance();
- scoped_refptr<UsbDevice> GetDeviceById(uint32 unique_id);
+ static void SetInstanceForTest(UsbService* instance);
+
+ virtual scoped_refptr<UsbDevice> GetDeviceById(uint32 unique_id) = 0;
// Get all of the devices attached to the system, inserting them into
// |devices|. Clears |devices| before use. The result will be sorted by id
// in increasing order. Must be called on FILE thread.
- void GetDevices(std::vector<scoped_refptr<UsbDevice> >* devices);
-
- // base::MessageLoop::DestructionObserver implementation.
- virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
+ virtual void GetDevices(std::vector<scoped_refptr<UsbDevice> >* devices) = 0;
- private:
+ protected:
friend struct base::DefaultDeleter<UsbService>;
-
- explicit UsbService(PlatformUsbContext context);
- virtual ~UsbService();
-
- // Enumerate USB devices from OS and Update devices_ map.
- void RefreshDevices();
-
- scoped_refptr<UsbContext> context_;
-
- // TODO(ikarienator): Figure out a better solution.
- uint32 next_unique_id_;
-
- // The map from PlatformUsbDevices to UsbDevices.
- typedef std::map<PlatformUsbDevice, scoped_refptr<UsbDevice> > DeviceMap;
- DeviceMap devices_;
-
+ UsbService() {}
+ virtual ~UsbService() {}
DISALLOW_COPY_AND_ASSIGN(UsbService);
};
« no previous file with comments | « components/usb_service/usb_interface.cc ('k') | components/usb_service/usb_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698