device_monitor_win.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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.
  4. #ifndef DEVICE_BASE_DEVICE_MONITOR_WIN_H_
  5. #define DEVICE_BASE_DEVICE_MONITOR_WIN_H_
  6. #include <string>
  7. #include "base/observer_list.h"
  8. #include "base/win/windows_types.h"
  9. #include "device/base/device_base_export.h"
  10. namespace device {
  11. // Use an instance of this class to observe devices being added and removed
  12. // from the system, matched by device interface GUID.
  13. class DEVICE_BASE_EXPORT DeviceMonitorWin {
  14. public:
  15. class DEVICE_BASE_EXPORT Observer {
  16. public:
  17. virtual void OnDeviceAdded(const GUID& class_guid,
  18. const std::wstring& device_path);
  19. virtual void OnDeviceRemoved(const GUID& class_guid,
  20. const std::wstring& device_path);
  21. };
  22. ~DeviceMonitorWin();
  23. static DeviceMonitorWin* GetForDeviceInterface(const GUID& guid);
  24. static DeviceMonitorWin* GetForAllInterfaces();
  25. void AddObserver(Observer* observer);
  26. void RemoveObserver(Observer* observer);
  27. private:
  28. friend class DeviceMonitorMessageWindow;
  29. DeviceMonitorWin();
  30. void NotifyDeviceAdded(const GUID& class_guid,
  31. const std::wstring& device_path);
  32. void NotifyDeviceRemoved(const GUID& class_guid,
  33. const std::wstring& device_path);
  34. base::ObserverList<Observer>::Unchecked observer_list_;
  35. };
  36. } // namespace device
  37. #endif // DEVICE_BASE_DEVICE_MONITOR_WIN_H_