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

Unified Diff: device/usb/usb_service.h

Issue 809743006: Add an Observer interface to UsbService for device add/remove. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarify comment. Created 5 years, 11 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 | « device/usb/usb_device_impl.cc ('k') | device/usb/usb_service_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_service.h
diff --git a/device/usb/usb_service.h b/device/usb/usb_service.h
index 0d49c2f421d52b8a48fcb8062db714103b67ee81..ed05ac0d31d650c0ea6a4cac07ce8e0ac7da9913 100644
--- a/device/usb/usb_service.h
+++ b/device/usb/usb_service.h
@@ -9,6 +9,7 @@
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
+#include "base/observer_list.h"
#include "base/threading/non_thread_safe.h"
namespace base {
@@ -25,6 +26,12 @@ class UsbDevice;
// competition for the same USB device.
class UsbService : public base::NonThreadSafe {
public:
+ class Observer {
+ public:
+ virtual void OnDeviceAdded(scoped_refptr<UsbDevice> device);
+ virtual void OnDeviceRemoved(scoped_refptr<UsbDevice> device);
+ };
+
// Must be called on a thread with a MessageLoopForIO (for example
// BrowserThread::FILE). The UI task runner reference is used to talk to the
// PermissionBrokerClient on ChromeOS (UI thread). Returns NULL when
@@ -41,10 +48,20 @@ class UsbService : public base::NonThreadSafe {
// in increasing order. Must be called on FILE thread.
virtual void GetDevices(std::vector<scoped_refptr<UsbDevice> >* devices) = 0;
+ void AddObserver(Observer* observer);
+ void RemoveObserver(Observer* observer);
+
protected:
friend struct base::DefaultDeleter<UsbService>;
- UsbService() {}
- virtual ~UsbService() {}
+
+ UsbService();
+ virtual ~UsbService();
+
+ void NotifyDeviceAdded(scoped_refptr<UsbDevice> device);
+ void NotifyDeviceRemoved(scoped_refptr<UsbDevice> device);
+
+ ObserverList<Observer, true> observer_list_;
+
DISALLOW_COPY_AND_ASSIGN(UsbService);
};
« no previous file with comments | « device/usb/usb_device_impl.cc ('k') | device/usb/usb_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698