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

Side by Side Diff: remoting/client/plugin/chromoting_instance.cc

Issue 7466008: Reland http://codereview.chromium.org/7452002/ again (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/client/plugin/chromoting_instance.h" 5 #include "remoting/client/plugin/chromoting_instance.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/stringprintf.h" 13 #include "base/stringprintf.h"
14 #include "base/synchronization/waitable_event.h" 14 #include "base/synchronization/waitable_event.h"
15 #include "base/task.h" 15 #include "base/task.h"
16 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
17 // TODO(sergeyu): We should not depend on renderer here. Instead P2P 17 // TODO(sergeyu): We should not depend on renderer here. Instead P2P
18 // Pepper API should be used. Remove this dependency. 18 // Pepper API should be used. Remove this dependency.
19 // crbug.com/74951 19 // crbug.com/74951
20 #include "content/renderer/p2p/ipc_network_manager.h" 20 #include "content/renderer/p2p/ipc_network_manager.h"
21 #include "content/renderer/p2p/ipc_socket_factory.h" 21 #include "content/renderer/p2p/ipc_socket_factory.h"
22 #include "ppapi/c/pp_input_event.h"
23 #include "ppapi/cpp/completion_callback.h" 22 #include "ppapi/cpp/completion_callback.h"
23 #include "ppapi/cpp/input_event.h"
24 #include "ppapi/cpp/rect.h" 24 #include "ppapi/cpp/rect.h"
25 // TODO(wez): Remove this when crbug.com/86353 is complete. 25 // TODO(wez): Remove this when crbug.com/86353 is complete.
26 #include "ppapi/cpp/private/var_private.h" 26 #include "ppapi/cpp/private/var_private.h"
27 #include "remoting/client/client_config.h" 27 #include "remoting/client/client_config.h"
28 #include "remoting/client/chromoting_client.h" 28 #include "remoting/client/chromoting_client.h"
29 #include "remoting/client/rectangle_update_decoder.h" 29 #include "remoting/client/rectangle_update_decoder.h"
30 #include "remoting/client/plugin/chromoting_scriptable_object.h" 30 #include "remoting/client/plugin/chromoting_scriptable_object.h"
31 #include "remoting/client/plugin/pepper_client_logger.h" 31 #include "remoting/client/plugin/pepper_client_logger.h"
32 #include "remoting/client/plugin/pepper_input_handler.h" 32 #include "remoting/client/plugin/pepper_input_handler.h"
33 #include "remoting/client/plugin/pepper_port_allocator_session.h" 33 #include "remoting/client/plugin/pepper_port_allocator_session.h"
(...skipping 14 matching lines...) Expand all
48 #include "webkit/plugins/ppapi/resource_tracker.h" 48 #include "webkit/plugins/ppapi/resource_tracker.h"
49 49
50 namespace remoting { 50 namespace remoting {
51 51
52 const char* ChromotingInstance::kMimeType = "pepper-application/x-chromoting"; 52 const char* ChromotingInstance::kMimeType = "pepper-application/x-chromoting";
53 53
54 ChromotingInstance::ChromotingInstance(PP_Instance pp_instance) 54 ChromotingInstance::ChromotingInstance(PP_Instance pp_instance)
55 : pp::InstancePrivate(pp_instance), 55 : pp::InstancePrivate(pp_instance),
56 initialized_(false), 56 initialized_(false),
57 logger_(this) { 57 logger_(this) {
58 RequestInputEvents(PP_INPUTEVENT_CLASS_MOUSE);
59 RequestFilteringInputEvents(PP_INPUTEVENT_CLASS_KEYBOARD);
58 } 60 }
59 61
60 ChromotingInstance::~ChromotingInstance() { 62 ChromotingInstance::~ChromotingInstance() {
61 DCHECK(CurrentlyOnPluginThread()); 63 DCHECK(CurrentlyOnPluginThread());
62 64
63 if (client_.get()) { 65 if (client_.get()) {
64 base::WaitableEvent done_event(true, false); 66 base::WaitableEvent done_event(true, false);
65 client_->Stop(base::Bind(&base::WaitableEvent::Signal, 67 client_->Stop(base::Bind(&base::WaitableEvent::Signal,
66 base::Unretained(&done_event))); 68 base::Unretained(&done_event)));
67 done_event.Wait(); 69 done_event.Wait();
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 164
163 void ChromotingInstance::DidChangeView(const pp::Rect& position, 165 void ChromotingInstance::DidChangeView(const pp::Rect& position,
164 const pp::Rect& clip) { 166 const pp::Rect& clip) {
165 // This lets |view_| implement scale-to-fit. But it only specifies a 167 // This lets |view_| implement scale-to-fit. But it only specifies a
166 // sub-rectangle of the plugin window as the rectangle on which the host 168 // sub-rectangle of the plugin window as the rectangle on which the host
167 // screen can be displayed, so |view_| has to make sure the plugin window 169 // screen can be displayed, so |view_| has to make sure the plugin window
168 // is large. 170 // is large.
169 view_->SetScreenSize(clip.width(), clip.height()); 171 view_->SetScreenSize(clip.width(), clip.height());
170 } 172 }
171 173
172 bool ChromotingInstance::HandleInputEvent(const PP_InputEvent& event) { 174 bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) {
173 DCHECK(CurrentlyOnPluginThread()); 175 DCHECK(CurrentlyOnPluginThread());
174 176
175 PepperInputHandler* pih 177 PepperInputHandler* pih
176 = static_cast<PepperInputHandler*>(input_handler_.get()); 178 = static_cast<PepperInputHandler*>(input_handler_.get());
177 179
178 switch (event.type) { 180 switch (event.GetType()) {
179 case PP_INPUTEVENT_TYPE_MOUSEDOWN: 181 case PP_INPUTEVENT_TYPE_MOUSEDOWN: {
180 pih->HandleMouseButtonEvent(true, event.u.mouse); 182 pih->HandleMouseButtonEvent(true, pp::MouseInputEvent(event));
181 return true; 183 return true;
184 }
182 185
183 case PP_INPUTEVENT_TYPE_MOUSEUP: 186 case PP_INPUTEVENT_TYPE_MOUSEUP: {
184 pih->HandleMouseButtonEvent(false, event.u.mouse); 187 pih->HandleMouseButtonEvent(false, pp::MouseInputEvent(event));
185 return true; 188 return true;
189 }
186 190
187 case PP_INPUTEVENT_TYPE_MOUSEMOVE: 191 case PP_INPUTEVENT_TYPE_MOUSEMOVE:
188 case PP_INPUTEVENT_TYPE_MOUSEENTER: 192 case PP_INPUTEVENT_TYPE_MOUSEENTER:
189 case PP_INPUTEVENT_TYPE_MOUSELEAVE: 193 case PP_INPUTEVENT_TYPE_MOUSELEAVE: {
190 pih->HandleMouseMoveEvent(event.u.mouse); 194 pih->HandleMouseMoveEvent(pp::MouseInputEvent(event));
191 return true; 195 return true;
196 }
192 197
193 case PP_INPUTEVENT_TYPE_CONTEXTMENU: 198 case PP_INPUTEVENT_TYPE_CONTEXTMENU: {
194 // We need to return true here or else we'll get a local (plugin) context 199 // We need to return true here or else we'll get a local (plugin) context
195 // menu instead of the mouseup event for the right click. 200 // menu instead of the mouseup event for the right click.
196 return true; 201 return true;
202 }
197 203
198 case PP_INPUTEVENT_TYPE_KEYDOWN: 204 case PP_INPUTEVENT_TYPE_KEYDOWN:
199 case PP_INPUTEVENT_TYPE_KEYUP: 205 case PP_INPUTEVENT_TYPE_KEYUP: {
206 pp::KeyboardInputEvent key_event(event);
200 logger_.VLog(3, "PP_INPUTEVENT_TYPE_KEY%s key=%d", 207 logger_.VLog(3, "PP_INPUTEVENT_TYPE_KEY%s key=%d",
201 (event.type==PP_INPUTEVENT_TYPE_KEYDOWN ? "DOWN" : "UP"), 208 (event.GetType()==PP_INPUTEVENT_TYPE_KEYDOWN ? "DOWN" : "UP"),
202 event.u.key.key_code); 209 key_event.GetKeyCode());
203 pih->HandleKeyEvent(event.type == PP_INPUTEVENT_TYPE_KEYDOWN, 210 pih->HandleKeyEvent(event.GetType() == PP_INPUTEVENT_TYPE_KEYDOWN,
204 event.u.key); 211 key_event);
205 return true; 212 return true;
213 }
206 214
207 case PP_INPUTEVENT_TYPE_CHAR: 215 case PP_INPUTEVENT_TYPE_CHAR: {
208 pih->HandleCharacterEvent(event.u.character); 216 pih->HandleCharacterEvent(pp::KeyboardInputEvent(event));
209 return true; 217 return true;
218 }
210 219
211 default: 220 default:
212 break; 221 break;
213 } 222 }
214 223
215 return false; 224 return false;
216 } 225 }
217 226
218 ChromotingScriptableObject* ChromotingInstance::GetScriptableObject() { 227 ChromotingScriptableObject* ChromotingInstance::GetScriptableObject() {
219 pp::VarPrivate object = GetInstanceObject(); 228 pp::VarPrivate object = GetInstanceObject();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 if (!client_.get()) 290 if (!client_.get())
282 return NULL; 291 return NULL;
283 return client_->GetStats(); 292 return client_->GetStats();
284 } 293 }
285 294
286 void ChromotingInstance::ReleaseAllKeys() { 295 void ChromotingInstance::ReleaseAllKeys() {
287 input_handler_->ReleaseAllKeys(); 296 input_handler_->ReleaseAllKeys();
288 } 297 }
289 298
290 } // namespace remoting 299 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/plugin/chromoting_instance.h ('k') | remoting/client/plugin/pepper_input_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698