OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/event_executor.h" | 5 #include "remoting/host/event_executor.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 virtual ~EventExecutorWin() {} | 37 virtual ~EventExecutorWin() {} |
38 | 38 |
39 // ClipboardStub interface. | 39 // ClipboardStub interface. |
40 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; | 40 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; |
41 | 41 |
42 // InputStub interface. | 42 // InputStub interface. |
43 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; | 43 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; |
44 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; | 44 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; |
45 | 45 |
46 // EventExecutor interface. | 46 // EventExecutor interface. |
47 virtual void OnSessionStarted( | 47 virtual void Start( |
48 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; | 48 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; |
49 virtual void OnSessionFinished() OVERRIDE; | 49 virtual void StopAndDelete() OVERRIDE; |
50 | 50 |
51 private: | 51 private: |
52 void HandleKey(const KeyEvent& event); | 52 void HandleKey(const KeyEvent& event); |
53 void HandleMouse(const MouseEvent& event); | 53 void HandleMouse(const MouseEvent& event); |
54 | 54 |
55 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | 55 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
56 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | 56 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; |
57 scoped_ptr<Clipboard> clipboard_; | 57 scoped_ptr<Clipboard> clipboard_; |
58 | 58 |
59 DISALLOW_COPY_AND_ASSIGN(EventExecutorWin); | 59 DISALLOW_COPY_AND_ASSIGN(EventExecutorWin); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 main_task_runner_->PostTask( | 97 main_task_runner_->PostTask( |
98 FROM_HERE, | 98 FROM_HERE, |
99 base::Bind(&EventExecutorWin::InjectMouseEvent, base::Unretained(this), | 99 base::Bind(&EventExecutorWin::InjectMouseEvent, base::Unretained(this), |
100 event)); | 100 event)); |
101 return; | 101 return; |
102 } | 102 } |
103 | 103 |
104 HandleMouse(event); | 104 HandleMouse(event); |
105 } | 105 } |
106 | 106 |
107 void EventExecutorWin::OnSessionStarted( | 107 void EventExecutorWin::Start( |
108 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 108 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
109 if (!ui_task_runner_->BelongsToCurrentThread()) { | 109 if (!ui_task_runner_->BelongsToCurrentThread()) { |
110 ui_task_runner_->PostTask( | 110 ui_task_runner_->PostTask( |
111 FROM_HERE, | 111 FROM_HERE, |
112 base::Bind(&EventExecutorWin::OnSessionStarted, | 112 base::Bind(&EventExecutorWin::Start, |
113 base::Unretained(this), | 113 base::Unretained(this), |
114 base::Passed(&client_clipboard))); | 114 base::Passed(&client_clipboard))); |
115 return; | 115 return; |
116 } | 116 } |
117 | 117 |
118 clipboard_->Start(client_clipboard.Pass()); | 118 clipboard_->Start(client_clipboard.Pass()); |
119 } | 119 } |
120 | 120 |
121 void EventExecutorWin::OnSessionFinished() { | 121 void EventExecutorWin::StopAndDelete() { |
122 if (!ui_task_runner_->BelongsToCurrentThread()) { | 122 if (!ui_task_runner_->BelongsToCurrentThread()) { |
123 ui_task_runner_->PostTask( | 123 ui_task_runner_->PostTask( |
124 FROM_HERE, | 124 FROM_HERE, |
125 base::Bind(&EventExecutorWin::OnSessionFinished, | 125 base::Bind(&EventExecutorWin::StopAndDelete, |
126 base::Unretained(this))); | 126 base::Unretained(this))); |
127 return; | 127 return; |
128 } | 128 } |
129 | 129 |
130 clipboard_->Stop(); | 130 clipboard_->Stop(); |
| 131 delete this; |
131 } | 132 } |
132 | 133 |
133 void EventExecutorWin::HandleKey(const KeyEvent& event) { | 134 void EventExecutorWin::HandleKey(const KeyEvent& event) { |
134 // HostEventDispatcher should filter events missing the pressed field. | 135 // HostEventDispatcher should filter events missing the pressed field. |
135 DCHECK(event.has_pressed()); | 136 DCHECK(event.has_pressed()); |
136 DCHECK(event.has_usb_keycode()); | 137 DCHECK(event.has_usb_keycode()); |
137 | 138 |
138 // Reset the system idle suspend timeout. | 139 // Reset the system idle suspend timeout. |
139 SetThreadExecutionState(ES_SYSTEM_REQUIRED); | 140 SetThreadExecutionState(ES_SYSTEM_REQUIRED); |
140 | 141 |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } // namespace | 254 } // namespace |
254 | 255 |
255 scoped_ptr<EventExecutor> EventExecutor::Create( | 256 scoped_ptr<EventExecutor> EventExecutor::Create( |
256 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 257 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
257 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 258 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
258 return scoped_ptr<EventExecutor>( | 259 return scoped_ptr<EventExecutor>( |
259 new EventExecutorWin(main_task_runner, ui_task_runner)); | 260 new EventExecutorWin(main_task_runner, ui_task_runner)); |
260 } | 261 } |
261 | 262 |
262 } // namespace remoting | 263 } // namespace remoting |
OLD | NEW |