mouse_shape_pump.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2015 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 REMOTING_HOST_MOUSE_SHAPE_PUMP_H_
  5. #define REMOTING_HOST_MOUSE_SHAPE_PUMP_H_
  6. #include <memory>
  7. #include "base/memory/raw_ptr.h"
  8. #include "base/threading/thread_checker.h"
  9. #include "base/timer/timer.h"
  10. #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
  11. namespace remoting {
  12. namespace protocol {
  13. class CursorShapeStub;
  14. } // namespace
  15. // MouseShapePump is responsible for capturing mouse shape using
  16. // MouseCursorMonitor and sending it to a CursorShapeStub.
  17. class MouseShapePump : public webrtc::MouseCursorMonitor::Callback {
  18. public:
  19. MouseShapePump(
  20. std::unique_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor,
  21. protocol::CursorShapeStub* cursor_shape_stub);
  22. MouseShapePump(const MouseShapePump&) = delete;
  23. MouseShapePump& operator=(const MouseShapePump&) = delete;
  24. ~MouseShapePump() override;
  25. // Sets or unsets the callback to which to delegate MouseCursorMonitor events
  26. // after they have been processed.
  27. void SetMouseCursorMonitorCallback(
  28. webrtc::MouseCursorMonitor::Callback* callback);
  29. private:
  30. void Capture();
  31. // webrtc::MouseCursorMonitor::Callback implementation.
  32. void OnMouseCursor(webrtc::MouseCursor* mouse_cursor) override;
  33. void OnMouseCursorPosition(const webrtc::DesktopVector& position) override;
  34. base::ThreadChecker thread_checker_;
  35. std::unique_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor_;
  36. raw_ptr<protocol::CursorShapeStub> cursor_shape_stub_;
  37. base::RepeatingTimer capture_timer_;
  38. raw_ptr<webrtc::MouseCursorMonitor::Callback> callback_ = nullptr;
  39. };
  40. } // namespace remoting
  41. #endif // REMOTING_HOST_MOUSE_SHAPE_PUMP_H_