Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: remoting/host/event_executor_win.cc

Issue 10911152: [Chromoting] Refactoring DesktopEnvironment and moving screen/audio recorders to ClientSession. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed ClientSessionTest.ClampMouseEvents and crash in JingleSessionManager::Close(). Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 HKL GetForegroundKeyboardLayout(); 52 HKL GetForegroundKeyboardLayout();
53 void HandleKey(const KeyEvent& event); 53 void HandleKey(const KeyEvent& event);
54 void HandleMouse(const MouseEvent& event); 54 void HandleMouse(const MouseEvent& event);
55 55
56 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; 56 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
57 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; 57 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
58 scoped_ptr<Clipboard> clipboard_; 58 scoped_ptr<Clipboard> clipboard_;
59 59
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 main_task_runner_->PostTask( 98 main_task_runner_->PostTask(
99 FROM_HERE, 99 FROM_HERE,
100 base::Bind(&EventExecutorWin::InjectMouseEvent, base::Unretained(this), 100 base::Bind(&EventExecutorWin::InjectMouseEvent, base::Unretained(this),
101 event)); 101 event));
102 return; 102 return;
103 } 103 }
104 104
105 HandleMouse(event); 105 HandleMouse(event);
106 } 106 }
107 107
108 void EventExecutorWin::OnSessionStarted( 108 void EventExecutorWin::Start(
109 scoped_ptr<protocol::ClipboardStub> client_clipboard) { 109 scoped_ptr<protocol::ClipboardStub> client_clipboard) {
110 if (!ui_task_runner_->BelongsToCurrentThread()) { 110 if (!ui_task_runner_->BelongsToCurrentThread()) {
111 ui_task_runner_->PostTask( 111 ui_task_runner_->PostTask(
112 FROM_HERE, 112 FROM_HERE,
113 base::Bind(&EventExecutorWin::OnSessionStarted, 113 base::Bind(&EventExecutorWin::Start,
114 base::Unretained(this), 114 base::Unretained(this),
115 base::Passed(&client_clipboard))); 115 base::Passed(&client_clipboard)));
116 return; 116 return;
117 } 117 }
118 118
119 clipboard_->Start(client_clipboard.Pass()); 119 clipboard_->Start(client_clipboard.Pass());
120 } 120 }
121 121
122 void EventExecutorWin::OnSessionFinished() { 122 void EventExecutorWin::StopAndDelete() {
123 if (!ui_task_runner_->BelongsToCurrentThread()) { 123 if (!ui_task_runner_->BelongsToCurrentThread()) {
124 ui_task_runner_->PostTask( 124 ui_task_runner_->PostTask(
125 FROM_HERE, 125 FROM_HERE,
126 base::Bind(&EventExecutorWin::OnSessionFinished, 126 base::Bind(&EventExecutorWin::StopAndDelete,
127 base::Unretained(this))); 127 base::Unretained(this)));
128 return; 128 return;
129 } 129 }
130 130
131 clipboard_->Stop(); 131 clipboard_->Stop();
132 delete this;
132 } 133 }
133 134
134 HKL EventExecutorWin::GetForegroundKeyboardLayout() { 135 HKL EventExecutorWin::GetForegroundKeyboardLayout() {
135 HKL layout = 0; 136 HKL layout = 0;
136 137
137 // Can return NULL if a window is losing focus. 138 // Can return NULL if a window is losing focus.
138 HWND foreground = GetForegroundWindow(); 139 HWND foreground = GetForegroundWindow();
139 if (foreground) { 140 if (foreground) {
140 // Can return 0 if the window no longer exists. 141 // Can return 0 if the window no longer exists.
141 DWORD thread_id = GetWindowThreadProcessId(foreground, 0); 142 DWORD thread_id = GetWindowThreadProcessId(foreground, 0);
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } // namespace 291 } // namespace
291 292
292 scoped_ptr<EventExecutor> EventExecutor::Create( 293 scoped_ptr<EventExecutor> EventExecutor::Create(
293 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, 294 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
294 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) { 295 scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner) {
295 return scoped_ptr<EventExecutor>( 296 return scoped_ptr<EventExecutor>(
296 new EventExecutorWin(main_task_runner, ui_task_runner)); 297 new EventExecutorWin(main_task_runner, ui_task_runner));
297 } 298 }
298 299
299 } // namespace remoting 300 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698