| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/base/user_input_monitor.h" | 5 #include "media/base/user_input_monitor.h" |
| 6 | 6 |
| 7 #include <sys/select.h> | 7 #include <sys/select.h> |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 #define XK_MISCELLANY | 9 #define XK_MISCELLANY |
| 10 #include <X11/keysymdef.h> | 10 #include <X11/keysymdef.h> |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 KEYBOARD_EVENT | 45 KEYBOARD_EVENT |
| 46 }; | 46 }; |
| 47 | 47 |
| 48 explicit UserInputMonitorLinuxCore( | 48 explicit UserInputMonitorLinuxCore( |
| 49 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 49 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| 50 const scoped_refptr<UserInputMonitor::MouseListenerList>& | 50 const scoped_refptr<UserInputMonitor::MouseListenerList>& |
| 51 mouse_listeners); | 51 mouse_listeners); |
| 52 virtual ~UserInputMonitorLinuxCore(); | 52 virtual ~UserInputMonitorLinuxCore(); |
| 53 | 53 |
| 54 // DestructionObserver overrides. | 54 // DestructionObserver overrides. |
| 55 virtual void WillDestroyCurrentMessageLoop() OVERRIDE; | 55 virtual void WillDestroyCurrentMessageLoop() override; |
| 56 | 56 |
| 57 size_t GetKeyPressCount() const; | 57 size_t GetKeyPressCount() const; |
| 58 void StartMonitor(EventType type); | 58 void StartMonitor(EventType type); |
| 59 void StopMonitor(EventType type); | 59 void StopMonitor(EventType type); |
| 60 | 60 |
| 61 private: | 61 private: |
| 62 // base::MessagePumpLibevent::Watcher interface. | 62 // base::MessagePumpLibevent::Watcher interface. |
| 63 virtual void OnFileCanReadWithoutBlocking(int fd) OVERRIDE; | 63 virtual void OnFileCanReadWithoutBlocking(int fd) override; |
| 64 virtual void OnFileCanWriteWithoutBlocking(int fd) OVERRIDE; | 64 virtual void OnFileCanWriteWithoutBlocking(int fd) override; |
| 65 | 65 |
| 66 // Processes key and mouse events. | 66 // Processes key and mouse events. |
| 67 void ProcessXEvent(xEvent* event); | 67 void ProcessXEvent(xEvent* event); |
| 68 static void ProcessReply(XPointer self, XRecordInterceptData* data); | 68 static void ProcessReply(XPointer self, XRecordInterceptData* data); |
| 69 | 69 |
| 70 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 70 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 71 scoped_refptr<ObserverListThreadSafe<UserInputMonitor::MouseEventListener> > | 71 scoped_refptr<ObserverListThreadSafe<UserInputMonitor::MouseEventListener> > |
| 72 mouse_listeners_; | 72 mouse_listeners_; |
| 73 | 73 |
| 74 // | 74 // |
| 75 // The following members should only be accessed on the IO thread. | 75 // The following members should only be accessed on the IO thread. |
| 76 // | 76 // |
| 77 base::MessagePumpLibevent::FileDescriptorWatcher controller_; | 77 base::MessagePumpLibevent::FileDescriptorWatcher controller_; |
| 78 Display* x_control_display_; | 78 Display* x_control_display_; |
| 79 Display* x_record_display_; | 79 Display* x_record_display_; |
| 80 XRecordRange* x_record_range_[2]; | 80 XRecordRange* x_record_range_[2]; |
| 81 XRecordContext x_record_context_; | 81 XRecordContext x_record_context_; |
| 82 KeyboardEventCounter counter_; | 82 KeyboardEventCounter counter_; |
| 83 | 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(UserInputMonitorLinuxCore); | 84 DISALLOW_COPY_AND_ASSIGN(UserInputMonitorLinuxCore); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 class UserInputMonitorLinux : public UserInputMonitor { | 87 class UserInputMonitorLinux : public UserInputMonitor { |
| 88 public: | 88 public: |
| 89 explicit UserInputMonitorLinux( | 89 explicit UserInputMonitorLinux( |
| 90 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 90 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
| 91 virtual ~UserInputMonitorLinux(); | 91 virtual ~UserInputMonitorLinux(); |
| 92 | 92 |
| 93 // Public UserInputMonitor overrides. | 93 // Public UserInputMonitor overrides. |
| 94 virtual size_t GetKeyPressCount() const OVERRIDE; | 94 virtual size_t GetKeyPressCount() const override; |
| 95 | 95 |
| 96 private: | 96 private: |
| 97 // Private UserInputMonitor overrides. | 97 // Private UserInputMonitor overrides. |
| 98 virtual void StartKeyboardMonitoring() OVERRIDE; | 98 virtual void StartKeyboardMonitoring() override; |
| 99 virtual void StopKeyboardMonitoring() OVERRIDE; | 99 virtual void StopKeyboardMonitoring() override; |
| 100 virtual void StartMouseMonitoring() OVERRIDE; | 100 virtual void StartMouseMonitoring() override; |
| 101 virtual void StopMouseMonitoring() OVERRIDE; | 101 virtual void StopMouseMonitoring() override; |
| 102 | 102 |
| 103 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; | 103 scoped_refptr<base::SingleThreadTaskRunner> io_task_runner_; |
| 104 UserInputMonitorLinuxCore* core_; | 104 UserInputMonitorLinuxCore* core_; |
| 105 | 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(UserInputMonitorLinux); | 106 DISALLOW_COPY_AND_ASSIGN(UserInputMonitorLinux); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 UserInputMonitorLinuxCore::UserInputMonitorLinuxCore( | 109 UserInputMonitorLinuxCore::UserInputMonitorLinuxCore( |
| 110 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 110 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| 111 const scoped_refptr<UserInputMonitor::MouseListenerList>& mouse_listeners) | 111 const scoped_refptr<UserInputMonitor::MouseListenerList>& mouse_listeners) |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 } // namespace | 374 } // namespace |
| 375 | 375 |
| 376 scoped_ptr<UserInputMonitor> UserInputMonitor::Create( | 376 scoped_ptr<UserInputMonitor> UserInputMonitor::Create( |
| 377 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, | 377 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner, |
| 378 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { | 378 const scoped_refptr<base::SingleThreadTaskRunner>& ui_task_runner) { |
| 379 return scoped_ptr<UserInputMonitor>( | 379 return scoped_ptr<UserInputMonitor>( |
| 380 new UserInputMonitorLinux(io_task_runner)); | 380 new UserInputMonitorLinux(io_task_runner)); |
| 381 } | 381 } |
| 382 | 382 |
| 383 } // namespace media | 383 } // namespace media |
| OLD | NEW |