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 <ApplicationServices/ApplicationServices.h> | 7 #include <ApplicationServices/ApplicationServices.h> |
8 #include <Carbon/Carbon.h> | 8 #include <Carbon/Carbon.h> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 virtual ~EventExecutorMac() {} | 50 virtual ~EventExecutorMac() {} |
51 | 51 |
52 // ClipboardStub interface. | 52 // ClipboardStub interface. |
53 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; | 53 virtual void InjectClipboardEvent(const ClipboardEvent& event) OVERRIDE; |
54 | 54 |
55 // InputStub interface. | 55 // InputStub interface. |
56 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; | 56 virtual void InjectKeyEvent(const KeyEvent& event) OVERRIDE; |
57 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; | 57 virtual void InjectMouseEvent(const MouseEvent& event) OVERRIDE; |
58 | 58 |
59 // EventExecutor interface. | 59 // EventExecutor interface. |
60 virtual void OnSessionStarted( | 60 virtual void Start( |
61 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; | 61 scoped_ptr<protocol::ClipboardStub> client_clipboard) OVERRIDE; |
62 virtual void OnSessionFinished() OVERRIDE; | 62 virtual void StopAndDelete() OVERRIDE; |
63 | 63 |
64 private: | 64 private: |
65 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 65 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
66 SkIPoint mouse_pos_; | 66 SkIPoint mouse_pos_; |
67 uint32 mouse_button_state_; | 67 uint32 mouse_button_state_; |
68 scoped_ptr<Clipboard> clipboard_; | 68 scoped_ptr<Clipboard> clipboard_; |
69 | 69 |
70 DISALLOW_COPY_AND_ASSIGN(EventExecutorMac); | 70 DISALLOW_COPY_AND_ASSIGN(EventExecutorMac); |
71 }; | 71 }; |
72 | 72 |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 #pragma clang diagnostic push | 207 #pragma clang diagnostic push |
208 #pragma clang diagnostic ignored "-Wdeprecated-declarations" | 208 #pragma clang diagnostic ignored "-Wdeprecated-declarations" |
209 error = CGPostScrollWheelEvent(2, dy, dx); | 209 error = CGPostScrollWheelEvent(2, dy, dx); |
210 #pragma clang diagnostic pop | 210 #pragma clang diagnostic pop |
211 if (error != kCGErrorSuccess) { | 211 if (error != kCGErrorSuccess) { |
212 LOG(WARNING) << "CGPostScrollWheelEvent error " << error; | 212 LOG(WARNING) << "CGPostScrollWheelEvent error " << error; |
213 } | 213 } |
214 } | 214 } |
215 } | 215 } |
216 | 216 |
217 void EventExecutorMac::OnSessionStarted( | 217 void EventExecutorMac::Start( |
218 scoped_ptr<protocol::ClipboardStub> client_clipboard) { | 218 scoped_ptr<protocol::ClipboardStub> client_clipboard) { |
219 if (!task_runner_->BelongsToCurrentThread()) { | 219 if (!task_runner_->BelongsToCurrentThread()) { |
220 task_runner_->PostTask( | 220 task_runner_->PostTask( |
221 FROM_HERE, | 221 FROM_HERE, |
222 base::Bind(&EventExecutorMac::OnSessionStarted, | 222 base::Bind(&EventExecutorMac::Start, |
223 base::Unretained(this), | 223 base::Unretained(this), |
224 base::Passed(&client_clipboard))); | 224 base::Passed(&client_clipboard))); |
225 return; | 225 return; |
226 } | 226 } |
227 | 227 |
228 clipboard_->Start(client_clipboard.Pass()); | 228 clipboard_->Start(client_clipboard.Pass()); |
229 } | 229 } |
230 | 230 |
231 void EventExecutorMac::OnSessionFinished() { | 231 void EventExecutorMac::StopAndDelete() { |
232 if (!task_runner_->BelongsToCurrentThread()) { | 232 if (!task_runner_->BelongsToCurrentThread()) { |
233 task_runner_->PostTask( | 233 task_runner_->PostTask( |
234 FROM_HERE, | 234 FROM_HERE, |
235 base::Bind(&EventExecutorMac::OnSessionFinished, | 235 base::Bind(&EventExecutorMac::StopAndDelete, |
236 base::Unretained(this))); | 236 base::Unretained(this))); |
237 return; | 237 return; |
238 } | 238 } |
239 | 239 |
240 clipboard_->Stop(); | 240 clipboard_->Stop(); |
| 241 delete this; |
241 } | 242 } |
242 | 243 |
243 } // namespace | 244 } // namespace |
244 | 245 |
245 scoped_ptr<EventExecutor> EventExecutor::Create( | 246 scoped_ptr<EventExecutor> EventExecutor::Create( |
246 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, | 247 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
247 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { | 248 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { |
248 return scoped_ptr<EventExecutor>(new EventExecutorMac(main_task_runner)); | 249 return scoped_ptr<EventExecutor>(new EventExecutorMac(main_task_runner)); |
249 } | 250 } |
250 | 251 |
251 } // namespace remoting | 252 } // namespace remoting |
OLD | NEW |