| 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_var_deprecated_proxy.h" | 5 #include "ppapi/proxy/ppb_var_deprecated_proxy.h" |
| 6 | 6 |
| 7 #include <stdlib.h> // For malloc | 7 #include <stdlib.h> // For malloc |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "ppapi/c/dev/ppb_var_deprecated.h" | 10 #include "ppapi/c/dev/ppb_var_deprecated.h" |
| 11 #include "ppapi/c/pp_var.h" | 11 #include "ppapi/c/pp_var.h" |
| 12 #include "ppapi/c/ppb_core.h" | 12 #include "ppapi/c/ppb_core.h" |
| 13 #include "ppapi/proxy/host_dispatcher.h" |
| 13 #include "ppapi/proxy/plugin_dispatcher.h" | 14 #include "ppapi/proxy/plugin_dispatcher.h" |
| 14 #include "ppapi/proxy/plugin_var_tracker.h" | 15 #include "ppapi/proxy/plugin_var_tracker.h" |
| 15 #include "ppapi/proxy/ppapi_messages.h" | 16 #include "ppapi/proxy/ppapi_messages.h" |
| 16 #include "ppapi/proxy/ppp_class_proxy.h" | 17 #include "ppapi/proxy/ppp_class_proxy.h" |
| 17 #include "ppapi/proxy/serialized_var.h" | 18 #include "ppapi/proxy/serialized_var.h" |
| 18 | 19 |
| 19 namespace pp { | 20 namespace pp { |
| 20 namespace proxy { | 21 namespace proxy { |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 IPC_END_MESSAGE_MAP() | 341 IPC_END_MESSAGE_MAP() |
| 341 // TODO(brettw) handle bad messages! | 342 // TODO(brettw) handle bad messages! |
| 342 return handled; | 343 return handled; |
| 343 } | 344 } |
| 344 | 345 |
| 345 void PPB_Var_Deprecated_Proxy::OnMsgHasProperty( | 346 void PPB_Var_Deprecated_Proxy::OnMsgHasProperty( |
| 346 SerializedVarReceiveInput var, | 347 SerializedVarReceiveInput var, |
| 347 SerializedVarReceiveInput name, | 348 SerializedVarReceiveInput name, |
| 348 SerializedVarOutParam exception, | 349 SerializedVarOutParam exception, |
| 349 PP_Bool* result) { | 350 PP_Bool* result) { |
| 351 SetAllowPluginReentrancy(); |
| 350 *result = BoolToPPBool(ppb_var_target()->HasProperty( | 352 *result = BoolToPPBool(ppb_var_target()->HasProperty( |
| 351 var.Get(dispatcher()), | 353 var.Get(dispatcher()), |
| 352 name.Get(dispatcher()), | 354 name.Get(dispatcher()), |
| 353 exception.OutParam(dispatcher()))); | 355 exception.OutParam(dispatcher()))); |
| 354 } | 356 } |
| 355 | 357 |
| 356 void PPB_Var_Deprecated_Proxy::OnMsgHasMethodDeprecated( | 358 void PPB_Var_Deprecated_Proxy::OnMsgHasMethodDeprecated( |
| 357 SerializedVarReceiveInput var, | 359 SerializedVarReceiveInput var, |
| 358 SerializedVarReceiveInput name, | 360 SerializedVarReceiveInput name, |
| 359 SerializedVarOutParam exception, | 361 SerializedVarOutParam exception, |
| 360 PP_Bool* result) { | 362 PP_Bool* result) { |
| 363 SetAllowPluginReentrancy(); |
| 361 *result = BoolToPPBool(ppb_var_target()->HasMethod( | 364 *result = BoolToPPBool(ppb_var_target()->HasMethod( |
| 362 var.Get(dispatcher()), | 365 var.Get(dispatcher()), |
| 363 name.Get(dispatcher()), | 366 name.Get(dispatcher()), |
| 364 exception.OutParam(dispatcher()))); | 367 exception.OutParam(dispatcher()))); |
| 365 } | 368 } |
| 366 | 369 |
| 367 void PPB_Var_Deprecated_Proxy::OnMsgGetProperty( | 370 void PPB_Var_Deprecated_Proxy::OnMsgGetProperty( |
| 368 SerializedVarReceiveInput var, | 371 SerializedVarReceiveInput var, |
| 369 SerializedVarReceiveInput name, | 372 SerializedVarReceiveInput name, |
| 370 SerializedVarOutParam exception, | 373 SerializedVarOutParam exception, |
| 371 SerializedVarReturnValue result) { | 374 SerializedVarReturnValue result) { |
| 375 SetAllowPluginReentrancy(); |
| 372 result.Return(dispatcher(), ppb_var_target()->GetProperty( | 376 result.Return(dispatcher(), ppb_var_target()->GetProperty( |
| 373 var.Get(dispatcher()), name.Get(dispatcher()), | 377 var.Get(dispatcher()), name.Get(dispatcher()), |
| 374 exception.OutParam(dispatcher()))); | 378 exception.OutParam(dispatcher()))); |
| 375 } | 379 } |
| 376 | 380 |
| 377 void PPB_Var_Deprecated_Proxy::OnMsgEnumerateProperties( | 381 void PPB_Var_Deprecated_Proxy::OnMsgEnumerateProperties( |
| 378 SerializedVarReceiveInput var, | 382 SerializedVarReceiveInput var, |
| 379 SerializedVarVectorOutParam props, | 383 SerializedVarVectorOutParam props, |
| 380 SerializedVarOutParam exception) { | 384 SerializedVarOutParam exception) { |
| 385 SetAllowPluginReentrancy(); |
| 381 ppb_var_target()->GetAllPropertyNames(var.Get(dispatcher()), | 386 ppb_var_target()->GetAllPropertyNames(var.Get(dispatcher()), |
| 382 props.CountOutParam(), props.ArrayOutParam(dispatcher()), | 387 props.CountOutParam(), props.ArrayOutParam(dispatcher()), |
| 383 exception.OutParam(dispatcher())); | 388 exception.OutParam(dispatcher())); |
| 384 } | 389 } |
| 385 | 390 |
| 386 void PPB_Var_Deprecated_Proxy::OnMsgSetPropertyDeprecated( | 391 void PPB_Var_Deprecated_Proxy::OnMsgSetPropertyDeprecated( |
| 387 SerializedVarReceiveInput var, | 392 SerializedVarReceiveInput var, |
| 388 SerializedVarReceiveInput name, | 393 SerializedVarReceiveInput name, |
| 389 SerializedVarReceiveInput value, | 394 SerializedVarReceiveInput value, |
| 390 SerializedVarOutParam exception) { | 395 SerializedVarOutParam exception) { |
| 396 SetAllowPluginReentrancy(); |
| 391 ppb_var_target()->SetProperty(var.Get(dispatcher()), | 397 ppb_var_target()->SetProperty(var.Get(dispatcher()), |
| 392 name.Get(dispatcher()), | 398 name.Get(dispatcher()), |
| 393 value.Get(dispatcher()), | 399 value.Get(dispatcher()), |
| 394 exception.OutParam(dispatcher())); | 400 exception.OutParam(dispatcher())); |
| 395 } | 401 } |
| 396 | 402 |
| 397 void PPB_Var_Deprecated_Proxy::OnMsgDeleteProperty( | 403 void PPB_Var_Deprecated_Proxy::OnMsgDeleteProperty( |
| 398 SerializedVarReceiveInput var, | 404 SerializedVarReceiveInput var, |
| 399 SerializedVarReceiveInput name, | 405 SerializedVarReceiveInput name, |
| 400 SerializedVarOutParam exception, | 406 SerializedVarOutParam exception, |
| 401 PP_Bool* result) { | 407 PP_Bool* result) { |
| 408 SetAllowPluginReentrancy(); |
| 402 ppb_var_target()->RemoveProperty(var.Get(dispatcher()), | 409 ppb_var_target()->RemoveProperty(var.Get(dispatcher()), |
| 403 name.Get(dispatcher()), | 410 name.Get(dispatcher()), |
| 404 exception.OutParam(dispatcher())); | 411 exception.OutParam(dispatcher())); |
| 405 // This deprecated function doesn't actually return a value, but we re-use | 412 // This deprecated function doesn't actually return a value, but we re-use |
| 406 // the message from the non-deprecated interface with the return value. | 413 // the message from the non-deprecated interface with the return value. |
| 407 *result = PP_TRUE; | 414 *result = PP_TRUE; |
| 408 } | 415 } |
| 409 | 416 |
| 410 void PPB_Var_Deprecated_Proxy::OnMsgCallDeprecated( | 417 void PPB_Var_Deprecated_Proxy::OnMsgCallDeprecated( |
| 411 SerializedVarReceiveInput object, | 418 SerializedVarReceiveInput object, |
| 412 SerializedVarReceiveInput method_name, | 419 SerializedVarReceiveInput method_name, |
| 413 SerializedVarVectorReceiveInput arg_vector, | 420 SerializedVarVectorReceiveInput arg_vector, |
| 414 SerializedVarOutParam exception, | 421 SerializedVarOutParam exception, |
| 415 SerializedVarReturnValue result) { | 422 SerializedVarReturnValue result) { |
| 423 SetAllowPluginReentrancy(); |
| 416 uint32_t arg_count = 0; | 424 uint32_t arg_count = 0; |
| 417 PP_Var* args = arg_vector.Get(dispatcher(), &arg_count); | 425 PP_Var* args = arg_vector.Get(dispatcher(), &arg_count); |
| 418 result.Return(dispatcher(), ppb_var_target()->Call( | 426 result.Return(dispatcher(), ppb_var_target()->Call( |
| 419 object.Get(dispatcher()), | 427 object.Get(dispatcher()), |
| 420 method_name.Get(dispatcher()), | 428 method_name.Get(dispatcher()), |
| 421 arg_count, args, | 429 arg_count, args, |
| 422 exception.OutParam(dispatcher()))); | 430 exception.OutParam(dispatcher()))); |
| 423 } | 431 } |
| 424 | 432 |
| 425 void PPB_Var_Deprecated_Proxy::OnMsgConstruct( | 433 void PPB_Var_Deprecated_Proxy::OnMsgConstruct( |
| 426 SerializedVarReceiveInput var, | 434 SerializedVarReceiveInput var, |
| 427 SerializedVarVectorReceiveInput arg_vector, | 435 SerializedVarVectorReceiveInput arg_vector, |
| 428 SerializedVarOutParam exception, | 436 SerializedVarOutParam exception, |
| 429 SerializedVarReturnValue result) { | 437 SerializedVarReturnValue result) { |
| 438 SetAllowPluginReentrancy(); |
| 430 uint32_t arg_count = 0; | 439 uint32_t arg_count = 0; |
| 431 PP_Var* args = arg_vector.Get(dispatcher(), &arg_count); | 440 PP_Var* args = arg_vector.Get(dispatcher(), &arg_count); |
| 432 result.Return(dispatcher(), ppb_var_target()->Construct( | 441 result.Return(dispatcher(), ppb_var_target()->Construct( |
| 433 var.Get(dispatcher()), arg_count, args, | 442 var.Get(dispatcher()), arg_count, args, |
| 434 exception.OutParam(dispatcher()))); | 443 exception.OutParam(dispatcher()))); |
| 435 } | 444 } |
| 436 | 445 |
| 437 void PPB_Var_Deprecated_Proxy::OnMsgIsInstanceOfDeprecated( | 446 void PPB_Var_Deprecated_Proxy::OnMsgIsInstanceOfDeprecated( |
| 438 pp::proxy::SerializedVarReceiveInput var, | 447 pp::proxy::SerializedVarReceiveInput var, |
| 439 int64 ppp_class, | 448 int64 ppp_class, |
| 440 int64* ppp_class_data, | 449 int64* ppp_class_data, |
| 441 PP_Bool* result) { | 450 PP_Bool* result) { |
| 442 // TODO(brettw) write this. | 451 // TODO(brettw) write this. |
| 443 } | 452 } |
| 444 | 453 |
| 445 void PPB_Var_Deprecated_Proxy::OnMsgCreateObjectDeprecated( | 454 void PPB_Var_Deprecated_Proxy::OnMsgCreateObjectDeprecated( |
| 446 PP_Instance instance, | 455 PP_Instance instance, |
| 447 int64 ppp_class, | 456 int64 ppp_class, |
| 448 int64 class_data, | 457 int64 class_data, |
| 449 SerializedVarReturnValue result) { | 458 SerializedVarReturnValue result) { |
| 459 SetAllowPluginReentrancy(); |
| 450 result.Return(dispatcher(), PPP_Class_Proxy::CreateProxiedObject( | 460 result.Return(dispatcher(), PPP_Class_Proxy::CreateProxiedObject( |
| 451 ppb_var_target(), dispatcher(), instance, ppp_class, class_data)); | 461 ppb_var_target(), dispatcher(), instance, ppp_class, class_data)); |
| 452 } | 462 } |
| 453 | 463 |
| 464 void PPB_Var_Deprecated_Proxy::SetAllowPluginReentrancy() { |
| 465 if (dispatcher()->IsPlugin()) |
| 466 NOTREACHED(); |
| 467 else |
| 468 static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy(); |
| 469 } |
| 470 |
| 454 } // namespace proxy | 471 } // namespace proxy |
| 455 } // namespace pp | 472 } // namespace pp |
| OLD | NEW |