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

Unified Diff: device/usb/usb_service_win.h

Issue 2690383002: Add device path enumeration to the new Windows USB backend. (Closed)
Patch Set: Fix a comment. Created 3 years, 10 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_service_impl.h ('k') | device/usb/usb_service_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/usb/usb_service_win.h
diff --git a/device/usb/usb_service_win.h b/device/usb/usb_service_win.h
index a6feb81a3e02d4e885cbb4cf48c073423a2ce95d..a91557786ecfc19c9f3d35d57036ea3ab0ca37be 100644
--- a/device/usb/usb_service_win.h
+++ b/device/usb/usb_service_win.h
@@ -4,17 +4,63 @@
#include "device/usb/usb_service.h"
+#include <list>
+#include <unordered_map>
+
#include "base/macros.h"
+#include "base/memory/weak_ptr.h"
+#include "base/scoped_observer.h"
+#include "device/base/device_monitor_win.h"
+#include "device/usb/usb_device_win.h"
+
+namespace base {
+class SequencedTaskRunner;
+}
namespace device {
-class UsbServiceWin : public UsbService {
+class UsbServiceWin : public DeviceMonitorWin::Observer, public UsbService {
public:
explicit UsbServiceWin(
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner);
~UsbServiceWin() override;
private:
+ class BlockingThreadHelper;
+
+ // device::UsbService implementation
+ void GetDevices(const GetDevicesCallback& callback) override;
+
+ // device::DeviceMonitorWin::Observer implementation
+ void OnDeviceAdded(const GUID& class_guid,
+ const std::string& device_path) override;
+ void OnDeviceRemoved(const GUID& class_guid,
+ const std::string& device_path) override;
+
+ // Methods called by BlockingThreadHelper
+ void HelperStarted();
+ void CreateDeviceObject(const std::string& device_path,
+ const std::string& hub_path,
+ int port_number);
+
+ void DeviceReady(scoped_refptr<UsbDeviceWin> device, bool success);
+
+ bool enumeration_ready() {
+ return helper_started_ && first_enumeration_countdown_ == 0;
+ }
+
+ // Enumeration callbacks are queued until an enumeration completes.
+ bool helper_started_ = false;
+ uint32_t first_enumeration_countdown_ = 0;
+ std::list<GetDevicesCallback> enumeration_callbacks_;
+
+ BlockingThreadHelper* helper_;
+ std::unordered_map<std::string, scoped_refptr<UsbDeviceWin>> devices_by_path_;
+
+ ScopedObserver<DeviceMonitorWin, DeviceMonitorWin::Observer> device_observer_;
+
+ base::WeakPtrFactory<UsbServiceWin> weak_factory_;
+
DISALLOW_COPY_AND_ASSIGN(UsbServiceWin);
};
« no previous file with comments | « device/usb/usb_service_impl.h ('k') | device/usb/usb_service_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698