| 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/pp_var.h" | 8 #include "ppapi/c/pp_var.h" |
| 9 #include "ppapi/c/ppb_instance.h" | 9 #include "ppapi/c/ppb_instance.h" |
| 10 #include "ppapi/c/ppb_messaging.h" | 10 #include "ppapi/c/ppb_messaging.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 using ppapi::thunk::EnterFunctionNoLock; | 24 using ppapi::thunk::EnterFunctionNoLock; |
| 25 using ppapi::thunk::EnterResourceNoLock; | 25 using ppapi::thunk::EnterResourceNoLock; |
| 26 using ppapi::thunk::PPB_Instance_FunctionAPI; | 26 using ppapi::thunk::PPB_Instance_FunctionAPI; |
| 27 | 27 |
| 28 namespace ppapi { | 28 namespace ppapi { |
| 29 namespace proxy { | 29 namespace proxy { |
| 30 | 30 |
| 31 namespace { | 31 namespace { |
| 32 | 32 |
| 33 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher, | 33 typedef EnterFunctionNoLock<PPB_Instance_FunctionAPI> EnterInstanceNoLock; |
| 34 const void* target_interface) { | 34 |
| 35 return new PPB_Instance_Proxy(dispatcher, target_interface); | 35 InterfaceProxy* CreateInstanceProxy(Dispatcher* dispatcher) { |
| 36 return new PPB_Instance_Proxy(dispatcher); |
| 36 } | 37 } |
| 37 | 38 |
| 38 } // namespace | 39 } // namespace |
| 39 | 40 |
| 40 PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher, | 41 PPB_Instance_Proxy::PPB_Instance_Proxy(Dispatcher* dispatcher) |
| 41 const void* target_interface) | 42 : InterfaceProxy(dispatcher) { |
| 42 : InterfaceProxy(dispatcher, target_interface) { | |
| 43 } | 43 } |
| 44 | 44 |
| 45 PPB_Instance_Proxy::~PPB_Instance_Proxy() { | 45 PPB_Instance_Proxy::~PPB_Instance_Proxy() { |
| 46 } | 46 } |
| 47 | 47 |
| 48 // static | 48 // static |
| 49 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfo0_5() { | |
| 50 static const Info info = { | |
| 51 ppapi::thunk::GetPPB_Instance_1_0_Thunk(), | |
| 52 PPB_INSTANCE_INTERFACE_0_5, | |
| 53 INTERFACE_ID_NONE, // 1_0 is the canonical one. | |
| 54 false, | |
| 55 &CreateInstanceProxy, | |
| 56 }; | |
| 57 return &info; | |
| 58 } | |
| 59 | |
| 60 // static | |
| 61 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfo1_0() { | |
| 62 static const Info info = { | |
| 63 ppapi::thunk::GetPPB_Instance_1_0_Thunk(), | |
| 64 PPB_INSTANCE_INTERFACE_1_0, | |
| 65 INTERFACE_ID_PPB_INSTANCE, | |
| 66 false, | |
| 67 &CreateInstanceProxy, | |
| 68 }; | |
| 69 return &info; | |
| 70 } | |
| 71 | |
| 72 // static | |
| 73 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoMessaging() { | |
| 74 static const Info info = { | |
| 75 ppapi::thunk::GetPPB_Messaging_Thunk(), | |
| 76 PPB_MESSAGING_INTERFACE, | |
| 77 INTERFACE_ID_NONE, // 1_0 is the canonical one. | |
| 78 false, | |
| 79 &CreateInstanceProxy, | |
| 80 }; | |
| 81 return &info; | |
| 82 } | |
| 83 | |
| 84 // static | |
| 85 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoPrivate() { | 49 const InterfaceProxy::Info* PPB_Instance_Proxy::GetInfoPrivate() { |
| 86 static const Info info = { | 50 static const Info info = { |
| 87 ppapi::thunk::GetPPB_Instance_Private_Thunk(), | 51 ppapi::thunk::GetPPB_Instance_Private_Thunk(), |
| 88 PPB_INSTANCE_PRIVATE_INTERFACE, | 52 PPB_INSTANCE_PRIVATE_INTERFACE, |
| 89 INTERFACE_ID_NONE, // 1_0 is the canonical one. | 53 INTERFACE_ID_NONE, // 1_0 is the canonical one. |
| 90 false, | 54 false, |
| 91 &CreateInstanceProxy, | 55 &CreateInstanceProxy, |
| 92 }; | 56 }; |
| 93 return &info; | 57 return &info; |
| 94 } | 58 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 117 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject, | 81 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetWindowObject, |
| 118 OnMsgGetWindowObject) | 82 OnMsgGetWindowObject) |
| 119 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetOwnerElementObject, | 83 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetOwnerElementObject, |
| 120 OnMsgGetOwnerElementObject) | 84 OnMsgGetOwnerElementObject) |
| 121 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_BindGraphics, | 85 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_BindGraphics, |
| 122 OnMsgBindGraphics) | 86 OnMsgBindGraphics) |
| 123 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_IsFullFrame, | 87 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_IsFullFrame, |
| 124 OnMsgIsFullFrame) | 88 OnMsgIsFullFrame) |
| 125 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript, | 89 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ExecuteScript, |
| 126 OnMsgExecuteScript) | 90 OnMsgExecuteScript) |
| 91 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_Log, |
| 92 OnMsgLog) |
| 93 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_LogWithSource, |
| 94 OnMsgLogWithSource) |
| 127 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PostMessage, | 95 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_PostMessage, |
| 128 OnMsgPostMessage) | 96 OnMsgPostMessage) |
| 129 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetFullscreen, | 97 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_SetFullscreen, |
| 130 OnMsgSetFullscreen) | 98 OnMsgSetFullscreen) |
| 131 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetScreenSize, | 99 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_GetScreenSize, |
| 132 OnMsgGetScreenSize) | 100 OnMsgGetScreenSize) |
| 133 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_RequestInputEvents, | 101 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_RequestInputEvents, |
| 134 OnMsgRequestInputEvents) | 102 OnMsgRequestInputEvents) |
| 135 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ClearInputEvents, | 103 IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBInstance_ClearInputEvents, |
| 136 OnMsgClearInputEvents) | 104 OnMsgClearInputEvents) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 if (se.IsThrown()) | 152 if (se.IsThrown()) |
| 185 return PP_MakeUndefined(); | 153 return PP_MakeUndefined(); |
| 186 | 154 |
| 187 ReceiveSerializedVarReturnValue result; | 155 ReceiveSerializedVarReturnValue result; |
| 188 dispatcher()->Send(new PpapiHostMsg_PPBInstance_ExecuteScript( | 156 dispatcher()->Send(new PpapiHostMsg_PPBInstance_ExecuteScript( |
| 189 INTERFACE_ID_PPB_INSTANCE, instance, | 157 INTERFACE_ID_PPB_INSTANCE, instance, |
| 190 SerializedVarSendInput(dispatcher(), script), &se, &result)); | 158 SerializedVarSendInput(dispatcher(), script), &se, &result)); |
| 191 return result.Return(dispatcher()); | 159 return result.Return(dispatcher()); |
| 192 } | 160 } |
| 193 | 161 |
| 162 void PPB_Instance_Proxy::Log(PP_Instance instance, |
| 163 int log_level, |
| 164 PP_Var value) { |
| 165 dispatcher()->Send(new PpapiHostMsg_PPBInstance_Log( |
| 166 INTERFACE_ID_PPB_INSTANCE, instance, static_cast<int>(log_level), |
| 167 SerializedVarSendInput(dispatcher(), value))); |
| 168 } |
| 169 |
| 170 void PPB_Instance_Proxy::LogWithSource(PP_Instance instance, |
| 171 int log_level, |
| 172 PP_Var source, |
| 173 PP_Var value) { |
| 174 dispatcher()->Send(new PpapiHostMsg_PPBInstance_LogWithSource( |
| 175 INTERFACE_ID_PPB_INSTANCE, instance, static_cast<int>(log_level), |
| 176 SerializedVarSendInput(dispatcher(), source), |
| 177 SerializedVarSendInput(dispatcher(), value))); |
| 178 } |
| 179 |
| 194 PP_Bool PPB_Instance_Proxy::IsFullscreen(PP_Instance instance) { | 180 PP_Bool PPB_Instance_Proxy::IsFullscreen(PP_Instance instance) { |
| 195 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> | 181 InstanceData* data = static_cast<PluginDispatcher*>(dispatcher())-> |
| 196 GetInstanceData(instance); | 182 GetInstanceData(instance); |
| 197 if (!data) | 183 if (!data) |
| 198 return PP_FALSE; | 184 return PP_FALSE; |
| 199 return data->fullscreen; | 185 return data->fullscreen; |
| 200 } | 186 } |
| 201 | 187 |
| 202 PP_Bool PPB_Instance_Proxy::SetFullscreen(PP_Instance instance, | 188 PP_Bool PPB_Instance_Proxy::SetFullscreen(PP_Instance instance, |
| 203 PP_Bool fullscreen) { | 189 PP_Bool fullscreen) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 void PPB_Instance_Proxy::PostMessage(PP_Instance instance, | 251 void PPB_Instance_Proxy::PostMessage(PP_Instance instance, |
| 266 PP_Var message) { | 252 PP_Var message) { |
| 267 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PostMessage( | 253 dispatcher()->Send(new PpapiHostMsg_PPBInstance_PostMessage( |
| 268 INTERFACE_ID_PPB_INSTANCE, | 254 INTERFACE_ID_PPB_INSTANCE, |
| 269 instance, SerializedVarSendInput(dispatcher(), message))); | 255 instance, SerializedVarSendInput(dispatcher(), message))); |
| 270 } | 256 } |
| 271 | 257 |
| 272 void PPB_Instance_Proxy::OnMsgGetWindowObject( | 258 void PPB_Instance_Proxy::OnMsgGetWindowObject( |
| 273 PP_Instance instance, | 259 PP_Instance instance, |
| 274 SerializedVarReturnValue result) { | 260 SerializedVarReturnValue result) { |
| 275 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 261 EnterInstanceNoLock enter(instance, false); |
| 276 if (enter.succeeded()) | 262 if (enter.succeeded()) |
| 277 result.Return(dispatcher(), enter.functions()->GetWindowObject(instance)); | 263 result.Return(dispatcher(), enter.functions()->GetWindowObject(instance)); |
| 278 } | 264 } |
| 279 | 265 |
| 280 void PPB_Instance_Proxy::OnMsgGetOwnerElementObject( | 266 void PPB_Instance_Proxy::OnMsgGetOwnerElementObject( |
| 281 PP_Instance instance, | 267 PP_Instance instance, |
| 282 SerializedVarReturnValue result) { | 268 SerializedVarReturnValue result) { |
| 283 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 269 EnterInstanceNoLock enter(instance, false); |
| 284 if (enter.succeeded()) { | 270 if (enter.succeeded()) { |
| 285 result.Return(dispatcher(), | 271 result.Return(dispatcher(), |
| 286 enter.functions()->GetOwnerElementObject(instance)); | 272 enter.functions()->GetOwnerElementObject(instance)); |
| 287 } | 273 } |
| 288 } | 274 } |
| 289 | 275 |
| 290 void PPB_Instance_Proxy::OnMsgBindGraphics(PP_Instance instance, | 276 void PPB_Instance_Proxy::OnMsgBindGraphics(PP_Instance instance, |
| 291 const HostResource& device, | 277 const HostResource& device, |
| 292 PP_Bool* result) { | 278 PP_Bool* result) { |
| 293 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 279 EnterInstanceNoLock enter(instance, false); |
| 294 if (enter.succeeded()) { | 280 if (enter.succeeded()) { |
| 295 *result = enter.functions()->BindGraphics(instance, | 281 *result = enter.functions()->BindGraphics(instance, |
| 296 device.host_resource()); | 282 device.host_resource()); |
| 297 } | 283 } |
| 298 } | 284 } |
| 299 | 285 |
| 300 void PPB_Instance_Proxy::OnMsgIsFullFrame(PP_Instance instance, | 286 void PPB_Instance_Proxy::OnMsgIsFullFrame(PP_Instance instance, |
| 301 PP_Bool* result) { | 287 PP_Bool* result) { |
| 302 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 288 EnterInstanceNoLock enter(instance, false); |
| 303 if (enter.succeeded()) | 289 if (enter.succeeded()) |
| 304 *result = enter.functions()->IsFullFrame(instance); | 290 *result = enter.functions()->IsFullFrame(instance); |
| 305 } | 291 } |
| 306 | 292 |
| 307 void PPB_Instance_Proxy::OnMsgExecuteScript( | 293 void PPB_Instance_Proxy::OnMsgExecuteScript( |
| 308 PP_Instance instance, | 294 PP_Instance instance, |
| 309 SerializedVarReceiveInput script, | 295 SerializedVarReceiveInput script, |
| 310 SerializedVarOutParam out_exception, | 296 SerializedVarOutParam out_exception, |
| 311 SerializedVarReturnValue result) { | 297 SerializedVarReturnValue result) { |
| 312 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 298 EnterInstanceNoLock enter(instance, false); |
| 313 if (enter.failed()) | 299 if (enter.failed()) |
| 314 return; | 300 return; |
| 315 | 301 |
| 316 if (dispatcher()->IsPlugin()) | 302 if (dispatcher()->IsPlugin()) |
| 317 NOTREACHED(); | 303 NOTREACHED(); |
| 318 else | 304 else |
| 319 static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy(); | 305 static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy(); |
| 320 | 306 |
| 321 result.Return(dispatcher(), enter.functions()->ExecuteScript( | 307 result.Return(dispatcher(), enter.functions()->ExecuteScript( |
| 322 instance, | 308 instance, |
| 323 script.Get(dispatcher()), | 309 script.Get(dispatcher()), |
| 324 out_exception.OutParam(dispatcher()))); | 310 out_exception.OutParam(dispatcher()))); |
| 325 } | 311 } |
| 326 | 312 |
| 313 void PPB_Instance_Proxy::OnMsgLog(PP_Instance instance, |
| 314 int log_level, |
| 315 SerializedVarReceiveInput value) { |
| 316 EnterInstanceNoLock enter(instance, false); |
| 317 if (enter.succeeded()) |
| 318 enter.functions()->Log(instance, log_level, value.Get(dispatcher())); |
| 319 } |
| 320 |
| 321 void PPB_Instance_Proxy::OnMsgLogWithSource(PP_Instance instance, |
| 322 int log_level, |
| 323 SerializedVarReceiveInput source, |
| 324 SerializedVarReceiveInput value) { |
| 325 EnterInstanceNoLock enter(instance, false); |
| 326 if (enter.succeeded()) { |
| 327 enter.functions()->LogWithSource(instance, log_level, |
| 328 source.Get(dispatcher()), |
| 329 value.Get(dispatcher())); |
| 330 } |
| 331 } |
| 332 |
| 327 void PPB_Instance_Proxy::OnMsgSetFullscreen(PP_Instance instance, | 333 void PPB_Instance_Proxy::OnMsgSetFullscreen(PP_Instance instance, |
| 328 PP_Bool fullscreen, | 334 PP_Bool fullscreen, |
| 329 PP_Bool* result) { | 335 PP_Bool* result) { |
| 330 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 336 EnterInstanceNoLock enter(instance, false); |
| 331 if (enter.succeeded()) | 337 if (enter.succeeded()) |
| 332 *result = enter.functions()->SetFullscreen(instance, fullscreen); | 338 *result = enter.functions()->SetFullscreen(instance, fullscreen); |
| 333 } | 339 } |
| 334 | 340 |
| 335 void PPB_Instance_Proxy::OnMsgGetScreenSize(PP_Instance instance, | 341 void PPB_Instance_Proxy::OnMsgGetScreenSize(PP_Instance instance, |
| 336 PP_Bool* result, | 342 PP_Bool* result, |
| 337 PP_Size* size) { | 343 PP_Size* size) { |
| 338 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 344 EnterInstanceNoLock enter(instance, false); |
| 339 if (enter.succeeded()) | 345 if (enter.succeeded()) |
| 340 *result = enter.functions()->GetScreenSize(instance, size); | 346 *result = enter.functions()->GetScreenSize(instance, size); |
| 341 } | 347 } |
| 342 | 348 |
| 343 void PPB_Instance_Proxy::OnMsgRequestInputEvents(PP_Instance instance, | 349 void PPB_Instance_Proxy::OnMsgRequestInputEvents(PP_Instance instance, |
| 344 bool is_filtering, | 350 bool is_filtering, |
| 345 uint32_t event_classes) { | 351 uint32_t event_classes) { |
| 346 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 352 EnterInstanceNoLock enter(instance, false); |
| 347 if (enter.succeeded()) { | 353 if (enter.succeeded()) { |
| 348 if (is_filtering) | 354 if (is_filtering) |
| 349 enter.functions()->RequestFilteringInputEvents(instance, event_classes); | 355 enter.functions()->RequestFilteringInputEvents(instance, event_classes); |
| 350 else | 356 else |
| 351 enter.functions()->RequestInputEvents(instance, event_classes); | 357 enter.functions()->RequestInputEvents(instance, event_classes); |
| 352 } | 358 } |
| 353 } | 359 } |
| 354 | 360 |
| 355 void PPB_Instance_Proxy::OnMsgClearInputEvents(PP_Instance instance, | 361 void PPB_Instance_Proxy::OnMsgClearInputEvents(PP_Instance instance, |
| 356 uint32_t event_classes) { | 362 uint32_t event_classes) { |
| 357 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 363 EnterInstanceNoLock enter(instance, false); |
| 358 if (enter.succeeded()) | 364 if (enter.succeeded()) |
| 359 enter.functions()->ClearInputEventRequest(instance, event_classes); | 365 enter.functions()->ClearInputEventRequest(instance, event_classes); |
| 360 } | 366 } |
| 361 | 367 |
| 362 void PPB_Instance_Proxy::OnMsgPostMessage(PP_Instance instance, | 368 void PPB_Instance_Proxy::OnMsgPostMessage(PP_Instance instance, |
| 363 SerializedVarReceiveInput message) { | 369 SerializedVarReceiveInput message) { |
| 364 EnterFunctionNoLock<PPB_Instance_FunctionAPI> enter(instance, false); | 370 EnterInstanceNoLock enter(instance, false); |
| 365 if (enter.succeeded()) | 371 if (enter.succeeded()) |
| 366 enter.functions()->PostMessage(instance, message.Get(dispatcher())); | 372 enter.functions()->PostMessage(instance, message.Get(dispatcher())); |
| 367 } | 373 } |
| 368 | 374 |
| 369 } // namespace proxy | 375 } // namespace proxy |
| 370 } // namespace ppapi | 376 } // namespace ppapi |
| OLD | NEW |