OLD | NEW |
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 "ppapi/proxy/ppb_instance_proxy.h" | 5 #include "ppapi/proxy/ppb_instance_proxy.h" |
6 | 6 |
7 #include "ppapi/c/dev/ppb_fullscreen_dev.h" | 7 #include "ppapi/c/dev/ppb_fullscreen_dev.h" |
8 #include "ppapi/c/dev/ppb_mouse_lock_dev.h" | 8 #include "ppapi/c/dev/ppb_mouse_lock_dev.h" |
9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
10 #include "ppapi/c/pp_var.h" | 10 #include "ppapi/c/pp_var.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 using ppapi::thunk::EnterFunctionNoLock; | 26 using ppapi::thunk::EnterFunctionNoLock; |
27 using ppapi::thunk::EnterResourceNoLock; | 27 using ppapi::thunk::EnterResourceNoLock; |
28 using ppapi::thunk::PPB_Instance_FunctionAPI; | 28 using ppapi::thunk::PPB_Instance_FunctionAPI; |
29 | 29 |
30 namespace ppapi { | 30 namespace ppapi { |
31 namespace proxy { | 31 namespace proxy { |
32 | 32 |
33 namespace { | 33 namespace { |
34 | 34 |
35 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher, | 35 typedef EnterFunctionNoLock<PPB_Instance_FunctionAPI> EnterInstanceNoLock; |
36 const void* target_interface) { | 36 |
37 return new PPB_Instance_Proxy(dispatcher, target_interface); | 37 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) { |
| 38 return new PPB_Instance_Proxy(dispatcher); |
38 } | 39 } |
39 | 40 |
40 } // namespace | 41 } // namespace |
41 | 42 |
42 PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher, | 43 PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher) |
43 const void* target_interface) | 44 : InterfaceProxy(dispatcher) { |
44 : InterfaceProxy(dispatcher, target_interface) { | |
45 } | 45 } |
46 | 46 |
47 PPB_Instance_Proxy::~PPB_Instance_Proxy() { | 47 PPB_Instance_Proxy::~PPB_Instance_Proxy() { |
48 } | 48 } |
49 | 49 |
50 // static | 50 // static |
51 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfo0_5() { | |
52 static const Info info = { | |
53 ppapi::thunk::GetPPB_Instance_1_0_Thunk(), | |
54 PPB_INSTANCE_INTERFACE_0_5, | |
55 INTERFACE_ID_NONE, // 1_0 is the canonical one. | |
56 false, | |
57 &CreateInstanceProxy, | |
58 }; | |
59 return &info; | |
60 } | |
61 | |
62 // static | |
63 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfo1_0() { | |
64 static const Info info = { | |
65 ppapi::thunk::GetPPB_Instance_1_0_Thunk(), | |
66 PPB_INSTANCE_INTERFACE_1_0, | |
67 INTERFACE_ID_PPB_INSTANCE, | |
68 false, | |
69 &CreateInstanceProxy, | |
70 }; | |
71 return &info; | |
72 } | |
73 | |
74 // static | |
75 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoMessaging() { | |
76 static const Info info = { | |
77 ppapi::thunk::GetPPB_Messaging_Thunk(), | |
78 PPB_MESSAGING_INTERFACE, | |
79 INTERFACE_ID_NONE, // 1_0 is the canonical one. | |
80 false, | |
81 &CreateInstanceProxy, | |
82 }; | |
83 return &info; | |
84 } | |
85 | |
86 // static | |
87 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoMouseLock() { | |
88 static const Info info = { | |
89 ppapi::thunk::GetPPB_MouseLock_Thunk(), | |
90 PPB_MOUSELOCK_DEV_INTERFACE, | |
91 INTERFACE_ID_NONE, // 1_0 is the canonical one. | |
92 false, | |
93 &CreateInstanceProxy, | |
94 }; | |
95 return &info; | |
96 } | |
97 | |
98 // static | |
99 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoPrivate() { | 51 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoPrivate() { |
100 static const Info info = { | 52 static const Info info = { |
101 ppapi::thunk::GetPPB_Instance_Private_Thunk(), | 53 ppapi::thunk::GetPPB_Instance_Private_Thunk(), |
102 PPB_INSTANCE_PRIVATE_INTERFACE, | 54 PPB_INSTANCE_PRIVATE_INTERFACE, |
103 INTERFACE_ID_NONE, // 1_0 is the canonical one. | 55 INTERFACE_ID_NONE, // 1_0 is the canonical one. |
104 false, | 56 false, |
105 &CreateInstanceProxy, | 57 &CreateInstanceProxy, |
106 }; | 58 }; |
107 return &info; | 59 return &info; |
108 } | 60 } |
(...skipping 22 matching lines...) Expand all Loading... |
131 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject, | 83 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject, |
132 OnMsgGetWindowObject) | 84 OnMsgGetWindowObject) |
133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetOwnerElementObject, | 85 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetOwnerElementObject, |
134 OnMsgGetOwnerElementObject) | 86 OnMsgGetOwnerElementObject) |
135 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_BindGraphics, | 87 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_BindGraphics, |
136 OnMsgBindGraphics) | 88 OnMsgBindGraphics) |
137 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_IsFullFrame, | 89 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_IsFullFrame, |
138 OnMsgIsFullFrame) | 90 OnMsgIsFullFrame) |
139 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript, | 91 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript, |
140 OnMsgExecuteScript) | 92 OnMsgExecuteScript) |
| 93 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_Log, |
| 94 OnMsgLog) |
| 95 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_LogWithSource, |
| 96 OnMsgLogWithSource) |
141 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PostMessage, | 97 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PostMessage, |
142 OnMsgPostMessage) | 98 OnMsgPostMessage) |
143 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetFullscreen, | 99 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetFullscreen, |
144 OnMsgSetFullscreen) | 100 OnMsgSetFullscreen) |
145 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetScreenSize, | 101 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetScreenSize, |
146 OnMsgGetScreenSize) | 102 OnMsgGetScreenSize) |
147 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_RequestInputEvents, | 103 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_RequestInputEvents, |
148 OnMsgRequestInputEvents) | 104 OnMsgRequestInputEvents) |
149 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ClearInputEvents, | 105 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ClearInputEvents, |
150 OnMsgClearInputEvents) | 106 OnMsgClearInputEvents) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 if (se.IsThrown()) | 158 if (se.IsThrown()) |
203 return PP_MakeUndefined(); | 159 return PP_MakeUndefined(); |
204 | 160 |
205 ReceiveSerializedVarReturnValue result; | 161 ReceiveSerializedVarReturnValue result; |
206 dispatcher()->Send(new PpapiHostMsg_PPBInstance_ExecuteScript( | 162 dispatcher()->Send(new PpapiHostMsg_PPBInstance_ExecuteScript( |
207 INTERFACE_ID_PPB_INSTANCE, instance, | 163 INTERFACE_ID_PPB_INSTANCE, instance, |
208 SerializedVarSendInput(dispatcher(), script), &se, &result)); | 164 SerializedVarSendInput(dispatcher(), script), &se, &result)); |
209 return result.Return(dispatcher()); | 165 return result.Return(dispatcher()); |
210 } | 166 } |
211 | 167 |
| 168 void PPB_Instance_Proxy::Log(PP_Instance instance, |
| 169 int log_level, |
| 170 PP_Var value) { |
| 171 dispatcher()->Send(new PpapiHostMsg_PPBInstance_Log( |
| 172 INTERFACE_ID_PPB_INSTANCE, instance, static_cast<int>(log_level), |
| 173 SerializedVarSendInput(dispatcher(), value))); |
| 174 } |
| 175 |
| 176 void PPB_Instance_Proxy::LogWithSource(PP_Instance instance, |
| 177 int log_level, |
| 178 PP_Var source, |
| 179 PP_Var value) { |
| 180 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LogWithSource( |
| 181 INTERFACE_ID_PPB_INSTANCE, instance, static_cast<int>(log_level), |
| 182 SerializedVarSendInput(dispatcher(), source), |
| 183 SerializedVarSendInput(dispatcher(), value))); |
| 184 } |
| 185 |
212 PP_Bool PPB_Instance_Proxy::IsFullscreen(PP_Instance instance) { | 186 PP_Bool PPB_Instance_Proxy::IsFullscreen(PP_Instance instance) { |
213 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 187 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
214 GetInstanceData(instance); | 188 GetInstanceData(instance); |
215 if (!data) | 189 if (!data) |
216 return PP_FALSE; | 190 return PP_FALSE; |
217 return data->fullscreen; | 191 return data->fullscreen; |
218 } | 192 } |
219 | 193 |
220 PP_Bool PPB_Instance_Proxy::SetFullscreen(PP_Instance instance, | 194 PP_Bool PPB_Instance_Proxy::SetFullscreen(PP_Instance instance, |
221 PP_Bool fullscreen) { | 195 PP_Bool fullscreen) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 } | 272 } |
299 | 273 |
300 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { | 274 void PPB_Instance_Proxy::UnlockMouse(PP_Instance instance) { |
301 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse( | 275 dispatcher()->Send(new PpapiHostMsg_PPBInstance_UnlockMouse( |
302 INTERFACE_ID_PPB_INSTANCE, instance)); | 276 INTERFACE_ID_PPB_INSTANCE, instance)); |
303 } | 277 } |
304 | 278 |
305 void PPB_Instance_Proxy::OnMsgGetWindowObject( | 279 void PPB_Instance_Proxy::OnMsgGetWindowObject( |
306 PP_Instance instance, | 280 PP_Instance instance, |
307 SerializedVarReturnValue result) { | 281 SerializedVarReturnValue result) { |
308 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 282 EnterInstanceNoLock enter(instance, false); |
309 if (enter.succeeded()) | 283 if (enter.succeeded()) |
310 result.Return(dispatcher(), enter.functions()->GetWindowObject(instance)); | 284 result.Return(dispatcher(), enter.functions()->GetWindowObject(instance)); |
311 } | 285 } |
312 | 286 |
313 void PPB_Instance_Proxy::OnMsgGetOwnerElementObject( | 287 void PPB_Instance_Proxy::OnMsgGetOwnerElementObject( |
314 PP_Instance instance, | 288 PP_Instance instance, |
315 SerializedVarReturnValue result) { | 289 SerializedVarReturnValue result) { |
316 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 290 EnterInstanceNoLock enter(instance, false); |
317 if (enter.succeeded()) { | 291 if (enter.succeeded()) { |
318 result.Return(dispatcher(), | 292 result.Return(dispatcher(), |
319 enter.functions()->GetOwnerElementObject(instance)); | 293 enter.functions()->GetOwnerElementObject(instance)); |
320 } | 294 } |
321 } | 295 } |
322 | 296 |
323 void PPB_Instance_Proxy::OnMsgBindGraphics(PP_Instance instance, | 297 void PPB_Instance_Proxy::OnMsgBindGraphics(PP_Instance instance, |
324 const HostResource& device, | 298 const HostResource& device, |
325 PP_Bool* result) { | 299 PP_Bool* result) { |
326 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 300 EnterInstanceNoLock enter(instance, false); |
327 if (enter.succeeded()) { | 301 if (enter.succeeded()) { |
328 *result = enter.functions()->BindGraphics(instance, | 302 *result = enter.functions()->BindGraphics(instance, |
329 device.host_resource()); | 303 device.host_resource()); |
330 } | 304 } |
331 } | 305 } |
332 | 306 |
333 void PPB_Instance_Proxy::OnMsgIsFullFrame(PP_Instance instance, | 307 void PPB_Instance_Proxy::OnMsgIsFullFrame(PP_Instance instance, |
334 PP_Bool* result) { | 308 PP_Bool* result) { |
335 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 309 EnterInstanceNoLock enter(instance, false); |
336 if (enter.succeeded()) | 310 if (enter.succeeded()) |
337 *result = enter.functions()->IsFullFrame(instance); | 311 *result = enter.functions()->IsFullFrame(instance); |
338 } | 312 } |
339 | 313 |
340 void PPB_Instance_Proxy::OnMsgExecuteScript( | 314 void PPB_Instance_Proxy::OnMsgExecuteScript( |
341 PP_Instance instance, | 315 PP_Instance instance, |
342 SerializedVarReceiveInput script, | 316 SerializedVarReceiveInput script, |
343 SerializedVarOutParam out_exception, | 317 SerializedVarOutParam out_exception, |
344 SerializedVarReturnValue result) { | 318 SerializedVarReturnValue result) { |
345 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 319 EnterInstanceNoLock enter(instance, false); |
346 if (enter.failed()) | 320 if (enter.failed()) |
347 return; | 321 return; |
348 | 322 |
349 if (dispatcher()->IsPlugin()) | 323 if (dispatcher()->IsPlugin()) |
350 NOTREACHED(); | 324 NOTREACHED(); |
351 else | 325 else |
352 static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy(); | 326 static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy(); |
353 | 327 |
354 result.Return(dispatcher(), enter.functions()->ExecuteScript( | 328 result.Return(dispatcher(), enter.functions()->ExecuteScript( |
355 instance, | 329 instance, |
356 script.Get(dispatcher()), | 330 script.Get(dispatcher()), |
357 out_exception.OutParam(dispatcher()))); | 331 out_exception.OutParam(dispatcher()))); |
358 } | 332 } |
359 | 333 |
| 334 void PPB_Instance_Proxy::OnMsgLog(PP_Instance instance, |
| 335 int log_level, |
| 336 SerializedVarReceiveInput value) { |
| 337 EnterInstanceNoLock enter(instance, false); |
| 338 if (enter.succeeded()) |
| 339 enter.functions()->Log(instance, log_level, value.Get(dispatcher())); |
| 340 } |
| 341 |
| 342 void PPB_Instance_Proxy::OnMsgLogWithSource(PP_Instance instance, |
| 343 int log_level, |
| 344 SerializedVarReceiveInput source, |
| 345 SerializedVarReceiveInput value) { |
| 346 EnterInstanceNoLock enter(instance, false); |
| 347 if (enter.succeeded()) { |
| 348 enter.functions()->LogWithSource(instance, log_level, |
| 349 source.Get(dispatcher()), |
| 350 value.Get(dispatcher())); |
| 351 } |
| 352 } |
| 353 |
360 void PPB_Instance_Proxy::OnMsgSetFullscreen(PP_Instance instance, | 354 void PPB_Instance_Proxy::OnMsgSetFullscreen(PP_Instance instance, |
361 PP_Bool fullscreen, | 355 PP_Bool fullscreen, |
362 PP_Bool* result) { | 356 PP_Bool* result) { |
363 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 357 EnterInstanceNoLock enter(instance, false); |
364 if (enter.succeeded()) | 358 if (enter.succeeded()) |
365 *result = enter.functions()->SetFullscreen(instance, fullscreen); | 359 *result = enter.functions()->SetFullscreen(instance, fullscreen); |
366 } | 360 } |
367 | 361 |
368 void PPB_Instance_Proxy::OnMsgGetScreenSize(PP_Instance instance, | 362 void PPB_Instance_Proxy::OnMsgGetScreenSize(PP_Instance instance, |
369 PP_Bool* result, | 363 PP_Bool* result, |
370 PP_Size* size) { | 364 PP_Size* size) { |
371 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 365 EnterInstanceNoLock enter(instance, false); |
372 if (enter.succeeded()) | 366 if (enter.succeeded()) |
373 *result = enter.functions()->GetScreenSize(instance, size); | 367 *result = enter.functions()->GetScreenSize(instance, size); |
374 } | 368 } |
375 | 369 |
376 void PPB_Instance_Proxy::OnMsgRequestInputEvents(PP_Instance instance, | 370 void PPB_Instance_Proxy::OnMsgRequestInputEvents(PP_Instance instance, |
377 bool is_filtering, | 371 bool is_filtering, |
378 uint32_t event_classes) { | 372 uint32_t event_classes) { |
379 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 373 EnterInstanceNoLock enter(instance, false); |
380 if (enter.succeeded()) { | 374 if (enter.succeeded()) { |
381 if (is_filtering) | 375 if (is_filtering) |
382 enter.functions()->RequestFilteringInputEvents(instance, event_classes); | 376 enter.functions()->RequestFilteringInputEvents(instance, event_classes); |
383 else | 377 else |
384 enter.functions()->RequestInputEvents(instance, event_classes); | 378 enter.functions()->RequestInputEvents(instance, event_classes); |
385 } | 379 } |
386 } | 380 } |
387 | 381 |
388 void PPB_Instance_Proxy::OnMsgClearInputEvents(PP_Instance instance, | 382 void PPB_Instance_Proxy::OnMsgClearInputEvents(PP_Instance instance, |
389 uint32_t event_classes) { | 383 uint32_t event_classes) { |
390 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 384 EnterInstanceNoLock enter(instance, false); |
391 if (enter.succeeded()) | 385 if (enter.succeeded()) |
392 enter.functions()->ClearInputEventRequest(instance, event_classes); | 386 enter.functions()->ClearInputEventRequest(instance, event_classes); |
393 } | 387 } |
394 | 388 |
395 void PPB_Instance_Proxy::OnMsgPostMessage(PP_Instance instance, | 389 void PPB_Instance_Proxy::OnMsgPostMessage(PP_Instance instance, |
396 SerializedVarReceiveInput message) { | 390 SerializedVarReceiveInput message) { |
397 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 391 EnterInstanceNoLock enter(instance, false); |
398 if (enter.succeeded()) | 392 if (enter.succeeded()) |
399 enter.functions()->PostMessage(instance, message.Get(dispatcher())); | 393 enter.functions()->PostMessage(instance, message.Get(dispatcher())); |
400 } | 394 } |
401 | 395 |
402 void PPB_Instance_Proxy::OnMsgLockMouse(PP_Instance instance, | 396 void PPB_Instance_Proxy::OnMsgLockMouse(PP_Instance instance, |
403 uint32_t serialized_callback) { | 397 uint32_t serialized_callback) { |
404 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); | 398 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); |
405 if (enter.failed()) | 399 if (enter.failed()) |
406 return; | 400 return; |
407 PP_CompletionCallback callback = ReceiveCallback(serialized_callback); | 401 PP_CompletionCallback callback = ReceiveCallback(serialized_callback); |
408 int32_t result = enter.functions()->LockMouse(instance, callback); | 402 int32_t result = enter.functions()->LockMouse(instance, callback); |
409 if (result != PP_OK_COMPLETIONPENDING) | 403 if (result != PP_OK_COMPLETIONPENDING) |
410 PP_RunCompletionCallback(&callback, result); | 404 PP_RunCompletionCallback(&callback, result); |
411 } | 405 } |
412 | 406 |
413 void PPB_Instance_Proxy::OnMsgUnlockMouse(PP_Instance instance) { | 407 void PPB_Instance_Proxy::OnMsgUnlockMouse(PP_Instance instance) { |
414 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); | 408 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, true); |
415 if (enter.succeeded()) | 409 if (enter.succeeded()) |
416 enter.functions()->UnlockMouse(instance); | 410 enter.functions()->UnlockMouse(instance); |
417 } | 411 } |
418 | 412 |
419 } // namespace proxy | 413 } // namespace proxy |
420 } // namespace ppapi | 414 } // namespace ppapi |
OLD | NEW |