| 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 "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 &GetProperty, | 281 &GetProperty, |
| 282 &EnumerateProperties, | 282 &EnumerateProperties, |
| 283 &SetProperty, | 283 &SetProperty, |
| 284 &RemoveProperty, | 284 &RemoveProperty, |
| 285 &Call, | 285 &Call, |
| 286 &Construct, | 286 &Construct, |
| 287 &IsInstanceOf, | 287 &IsInstanceOf, |
| 288 &CreateObject | 288 &CreateObject |
| 289 }; | 289 }; |
| 290 | 290 |
| 291 InterfaceProxy* CreateVarDeprecatedProxy(Dispatcher* dispatcher) { | 291 InterfaceProxy* CreateVarDeprecatedProxy(Dispatcher* dispatcher, |
| 292 return new PPB_Var_Deprecated_Proxy(dispatcher ); | 292 const void* target_interface) { |
| 293 return new PPB_Var_Deprecated_Proxy(dispatcher, target_interface); |
| 293 } | 294 } |
| 294 | 295 |
| 295 } // namespace | 296 } // namespace |
| 296 | 297 |
| 297 PPB_Var_Deprecated_Proxy::PPB_Var_Deprecated_Proxy( | 298 PPB_Var_Deprecated_Proxy::PPB_Var_Deprecated_Proxy( |
| 298 Dispatcher* dispatcher) | 299 Dispatcher* dispatcher, |
| 299 : InterfaceProxy(dispatcher), | 300 const void* target_interface) |
| 300 task_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 301 : InterfaceProxy(dispatcher, target_interface), |
| 301 ppb_var_impl_(NULL) { | 302 task_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { |
| 302 if (!dispatcher->IsPlugin()) { | |
| 303 ppb_var_impl_ = static_cast<const PPB_Var_Deprecated*>( | |
| 304 dispatcher->local_get_interface()(PPB_VAR_DEPRECATED_INTERFACE)); | |
| 305 } | |
| 306 } | 303 } |
| 307 | 304 |
| 308 PPB_Var_Deprecated_Proxy::~PPB_Var_Deprecated_Proxy() { | 305 PPB_Var_Deprecated_Proxy::~PPB_Var_Deprecated_Proxy() { |
| 309 } | 306 } |
| 310 | 307 |
| 311 // static | 308 // static |
| 312 const InterfaceProxy::Info* PPB_Var_Deprecated_Proxy::GetInfo() { | 309 const InterfaceProxy::Info* PPB_Var_Deprecated_Proxy::GetInfo() { |
| 313 static const Info info = { | 310 static const Info info = { |
| 314 &var_deprecated_interface, | 311 &var_deprecated_interface, |
| 315 PPB_VAR_DEPRECATED_INTERFACE, | 312 PPB_VAR_DEPRECATED_INTERFACE, |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 IPC_END_MESSAGE_MAP() | 353 IPC_END_MESSAGE_MAP() |
| 357 // TODO(brettw) handle bad messages! | 354 // TODO(brettw) handle bad messages! |
| 358 return handled; | 355 return handled; |
| 359 } | 356 } |
| 360 | 357 |
| 361 void PPB_Var_Deprecated_Proxy::OnMsgAddRefObject(int64 object_id, | 358 void PPB_Var_Deprecated_Proxy::OnMsgAddRefObject(int64 object_id, |
| 362 int* /* unused */) { | 359 int* /* unused */) { |
| 363 PP_Var var; | 360 PP_Var var; |
| 364 var.type = PP_VARTYPE_OBJECT; | 361 var.type = PP_VARTYPE_OBJECT; |
| 365 var.value.as_id = object_id; | 362 var.value.as_id = object_id; |
| 366 ppb_var_impl_->AddRef(var); | 363 ppb_var_target()->AddRef(var); |
| 367 } | 364 } |
| 368 | 365 |
| 369 void PPB_Var_Deprecated_Proxy::OnMsgReleaseObject(int64 object_id) { | 366 void PPB_Var_Deprecated_Proxy::OnMsgReleaseObject(int64 object_id) { |
| 370 // Ok, so this is super subtle. | 367 // Ok, so this is super subtle. |
| 371 // When the browser side sends a sync IPC message that returns a var, and the | 368 // When the browser side sends a sync IPC message that returns a var, and the |
| 372 // plugin wants to give ownership of that var to the browser, dropping all | 369 // plugin wants to give ownership of that var to the browser, dropping all |
| 373 // references, it may call ReleaseObject right after returning the result. | 370 // references, it may call ReleaseObject right after returning the result. |
| 374 // However, the IPC system doesn't enforce strict ordering of messages in that | 371 // However, the IPC system doesn't enforce strict ordering of messages in that |
| 375 // case, where a message that is set to unblock (e.g. a sync message, or in | 372 // case, where a message that is set to unblock (e.g. a sync message, or in |
| 376 // our case all messages coming from the plugin) that is sent *after* the | 373 // our case all messages coming from the plugin) that is sent *after* the |
| (...skipping 12 matching lines...) Expand all Loading... |
| 389 task_factory_.NewRunnableMethod( | 386 task_factory_.NewRunnableMethod( |
| 390 &PPB_Var_Deprecated_Proxy::DoReleaseObject, object_id)); | 387 &PPB_Var_Deprecated_Proxy::DoReleaseObject, object_id)); |
| 391 } | 388 } |
| 392 | 389 |
| 393 void PPB_Var_Deprecated_Proxy::OnMsgHasProperty( | 390 void PPB_Var_Deprecated_Proxy::OnMsgHasProperty( |
| 394 SerializedVarReceiveInput var, | 391 SerializedVarReceiveInput var, |
| 395 SerializedVarReceiveInput name, | 392 SerializedVarReceiveInput name, |
| 396 SerializedVarOutParam exception, | 393 SerializedVarOutParam exception, |
| 397 PP_Bool* result) { | 394 PP_Bool* result) { |
| 398 SetAllowPluginReentrancy(); | 395 SetAllowPluginReentrancy(); |
| 399 *result = PP_FromBool(ppb_var_impl_->HasProperty( | 396 *result = PP_FromBool(ppb_var_target()->HasProperty( |
| 400 var.Get(dispatcher()), | 397 var.Get(dispatcher()), |
| 401 name.Get(dispatcher()), | 398 name.Get(dispatcher()), |
| 402 exception.OutParam(dispatcher()))); | 399 exception.OutParam(dispatcher()))); |
| 403 } | 400 } |
| 404 | 401 |
| 405 void PPB_Var_Deprecated_Proxy::OnMsgHasMethodDeprecated( | 402 void PPB_Var_Deprecated_Proxy::OnMsgHasMethodDeprecated( |
| 406 SerializedVarReceiveInput var, | 403 SerializedVarReceiveInput var, |
| 407 SerializedVarReceiveInput name, | 404 SerializedVarReceiveInput name, |
| 408 SerializedVarOutParam exception, | 405 SerializedVarOutParam exception, |
| 409 PP_Bool* result) { | 406 PP_Bool* result) { |
| 410 SetAllowPluginReentrancy(); | 407 SetAllowPluginReentrancy(); |
| 411 *result = PP_FromBool(ppb_var_impl_->HasMethod( | 408 *result = PP_FromBool(ppb_var_target()->HasMethod( |
| 412 var.Get(dispatcher()), | 409 var.Get(dispatcher()), |
| 413 name.Get(dispatcher()), | 410 name.Get(dispatcher()), |
| 414 exception.OutParam(dispatcher()))); | 411 exception.OutParam(dispatcher()))); |
| 415 } | 412 } |
| 416 | 413 |
| 417 void PPB_Var_Deprecated_Proxy::OnMsgGetProperty( | 414 void PPB_Var_Deprecated_Proxy::OnMsgGetProperty( |
| 418 SerializedVarReceiveInput var, | 415 SerializedVarReceiveInput var, |
| 419 SerializedVarReceiveInput name, | 416 SerializedVarReceiveInput name, |
| 420 SerializedVarOutParam exception, | 417 SerializedVarOutParam exception, |
| 421 SerializedVarReturnValue result) { | 418 SerializedVarReturnValue result) { |
| 422 SetAllowPluginReentrancy(); | 419 SetAllowPluginReentrancy(); |
| 423 result.Return(dispatcher(), ppb_var_impl_->GetProperty( | 420 result.Return(dispatcher(), ppb_var_target()->GetProperty( |
| 424 var.Get(dispatcher()), name.Get(dispatcher()), | 421 var.Get(dispatcher()), name.Get(dispatcher()), |
| 425 exception.OutParam(dispatcher()))); | 422 exception.OutParam(dispatcher()))); |
| 426 } | 423 } |
| 427 | 424 |
| 428 void PPB_Var_Deprecated_Proxy::OnMsgEnumerateProperties( | 425 void PPB_Var_Deprecated_Proxy::OnMsgEnumerateProperties( |
| 429 SerializedVarReceiveInput var, | 426 SerializedVarReceiveInput var, |
| 430 SerializedVarVectorOutParam props, | 427 SerializedVarVectorOutParam props, |
| 431 SerializedVarOutParam exception) { | 428 SerializedVarOutParam exception) { |
| 432 SetAllowPluginReentrancy(); | 429 SetAllowPluginReentrancy(); |
| 433 ppb_var_impl_->GetAllPropertyNames(var.Get(dispatcher()), | 430 ppb_var_target()->GetAllPropertyNames(var.Get(dispatcher()), |
| 434 props.CountOutParam(), props.ArrayOutParam(dispatcher()), | 431 props.CountOutParam(), props.ArrayOutParam(dispatcher()), |
| 435 exception.OutParam(dispatcher())); | 432 exception.OutParam(dispatcher())); |
| 436 } | 433 } |
| 437 | 434 |
| 438 void PPB_Var_Deprecated_Proxy::OnMsgSetPropertyDeprecated( | 435 void PPB_Var_Deprecated_Proxy::OnMsgSetPropertyDeprecated( |
| 439 SerializedVarReceiveInput var, | 436 SerializedVarReceiveInput var, |
| 440 SerializedVarReceiveInput name, | 437 SerializedVarReceiveInput name, |
| 441 SerializedVarReceiveInput value, | 438 SerializedVarReceiveInput value, |
| 442 SerializedVarOutParam exception) { | 439 SerializedVarOutParam exception) { |
| 443 SetAllowPluginReentrancy(); | 440 SetAllowPluginReentrancy(); |
| 444 ppb_var_impl_->SetProperty(var.Get(dispatcher()), | 441 ppb_var_target()->SetProperty(var.Get(dispatcher()), |
| 445 name.Get(dispatcher()), | 442 name.Get(dispatcher()), |
| 446 value.Get(dispatcher()), | 443 value.Get(dispatcher()), |
| 447 exception.OutParam(dispatcher())); | 444 exception.OutParam(dispatcher())); |
| 448 } | 445 } |
| 449 | 446 |
| 450 void PPB_Var_Deprecated_Proxy::OnMsgDeleteProperty( | 447 void PPB_Var_Deprecated_Proxy::OnMsgDeleteProperty( |
| 451 SerializedVarReceiveInput var, | 448 SerializedVarReceiveInput var, |
| 452 SerializedVarReceiveInput name, | 449 SerializedVarReceiveInput name, |
| 453 SerializedVarOutParam exception, | 450 SerializedVarOutParam exception, |
| 454 PP_Bool* result) { | 451 PP_Bool* result) { |
| 455 SetAllowPluginReentrancy(); | 452 SetAllowPluginReentrancy(); |
| 456 ppb_var_impl_->RemoveProperty(var.Get(dispatcher()), | 453 ppb_var_target()->RemoveProperty(var.Get(dispatcher()), |
| 457 name.Get(dispatcher()), | 454 name.Get(dispatcher()), |
| 458 exception.OutParam(dispatcher())); | 455 exception.OutParam(dispatcher())); |
| 459 // This deprecated function doesn't actually return a value, but we re-use | 456 // This deprecated function doesn't actually return a value, but we re-use |
| 460 // the message from the non-deprecated interface with the return value. | 457 // the message from the non-deprecated interface with the return value. |
| 461 *result = PP_TRUE; | 458 *result = PP_TRUE; |
| 462 } | 459 } |
| 463 | 460 |
| 464 void PPB_Var_Deprecated_Proxy::OnMsgCallDeprecated( | 461 void PPB_Var_Deprecated_Proxy::OnMsgCallDeprecated( |
| 465 SerializedVarReceiveInput object, | 462 SerializedVarReceiveInput object, |
| 466 SerializedVarReceiveInput method_name, | 463 SerializedVarReceiveInput method_name, |
| 467 SerializedVarVectorReceiveInput arg_vector, | 464 SerializedVarVectorReceiveInput arg_vector, |
| 468 SerializedVarOutParam exception, | 465 SerializedVarOutParam exception, |
| 469 SerializedVarReturnValue result) { | 466 SerializedVarReturnValue result) { |
| 470 SetAllowPluginReentrancy(); | 467 SetAllowPluginReentrancy(); |
| 471 uint32_t arg_count = 0; | 468 uint32_t arg_count = 0; |
| 472 PP_Var* args = arg_vector.Get(dispatcher(), &arg_count); | 469 PP_Var* args = arg_vector.Get(dispatcher(), &arg_count); |
| 473 result.Return(dispatcher(), ppb_var_impl_->Call( | 470 result.Return(dispatcher(), ppb_var_target()->Call( |
| 474 object.Get(dispatcher()), | 471 object.Get(dispatcher()), |
| 475 method_name.Get(dispatcher()), | 472 method_name.Get(dispatcher()), |
| 476 arg_count, args, | 473 arg_count, args, |
| 477 exception.OutParam(dispatcher()))); | 474 exception.OutParam(dispatcher()))); |
| 478 } | 475 } |
| 479 | 476 |
| 480 void PPB_Var_Deprecated_Proxy::OnMsgConstruct( | 477 void PPB_Var_Deprecated_Proxy::OnMsgConstruct( |
| 481 SerializedVarReceiveInput var, | 478 SerializedVarReceiveInput var, |
| 482 SerializedVarVectorReceiveInput arg_vector, | 479 SerializedVarVectorReceiveInput arg_vector, |
| 483 SerializedVarOutParam exception, | 480 SerializedVarOutParam exception, |
| 484 SerializedVarReturnValue result) { | 481 SerializedVarReturnValue result) { |
| 485 SetAllowPluginReentrancy(); | 482 SetAllowPluginReentrancy(); |
| 486 uint32_t arg_count = 0; | 483 uint32_t arg_count = 0; |
| 487 PP_Var* args = arg_vector.Get(dispatcher(), &arg_count); | 484 PP_Var* args = arg_vector.Get(dispatcher(), &arg_count); |
| 488 result.Return(dispatcher(), ppb_var_impl_->Construct( | 485 result.Return(dispatcher(), ppb_var_target()->Construct( |
| 489 var.Get(dispatcher()), arg_count, args, | 486 var.Get(dispatcher()), arg_count, args, |
| 490 exception.OutParam(dispatcher()))); | 487 exception.OutParam(dispatcher()))); |
| 491 } | 488 } |
| 492 | 489 |
| 493 void PPB_Var_Deprecated_Proxy::OnMsgIsInstanceOfDeprecated( | 490 void PPB_Var_Deprecated_Proxy::OnMsgIsInstanceOfDeprecated( |
| 494 SerializedVarReceiveInput var, | 491 SerializedVarReceiveInput var, |
| 495 int64 ppp_class, | 492 int64 ppp_class, |
| 496 int64* ppp_class_data, | 493 int64* ppp_class_data, |
| 497 PP_Bool* result) { | 494 PP_Bool* result) { |
| 498 // TODO(brettw) write this. | 495 // TODO(brettw) write this. |
| 499 } | 496 } |
| 500 | 497 |
| 501 void PPB_Var_Deprecated_Proxy::OnMsgCreateObjectDeprecated( | 498 void PPB_Var_Deprecated_Proxy::OnMsgCreateObjectDeprecated( |
| 502 PP_Instance instance, | 499 PP_Instance instance, |
| 503 int64 ppp_class, | 500 int64 ppp_class, |
| 504 int64 class_data, | 501 int64 class_data, |
| 505 SerializedVarReturnValue result) { | 502 SerializedVarReturnValue result) { |
| 506 SetAllowPluginReentrancy(); | 503 SetAllowPluginReentrancy(); |
| 507 result.Return(dispatcher(), PPP_Class_Proxy::CreateProxiedObject( | 504 result.Return(dispatcher(), PPP_Class_Proxy::CreateProxiedObject( |
| 508 ppb_var_impl_, dispatcher(), instance, ppp_class, class_data)); | 505 ppb_var_target(), dispatcher(), instance, ppp_class, class_data)); |
| 509 } | 506 } |
| 510 | 507 |
| 511 void PPB_Var_Deprecated_Proxy::SetAllowPluginReentrancy() { | 508 void PPB_Var_Deprecated_Proxy::SetAllowPluginReentrancy() { |
| 512 if (dispatcher()->IsPlugin()) | 509 if (dispatcher()->IsPlugin()) |
| 513 NOTREACHED(); | 510 NOTREACHED(); |
| 514 else | 511 else |
| 515 static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy(); | 512 static_cast<HostDispatcher*>(dispatcher())->set_allow_plugin_reentrancy(); |
| 516 } | 513 } |
| 517 | 514 |
| 518 void PPB_Var_Deprecated_Proxy::DoReleaseObject(int64 object_id) { | 515 void PPB_Var_Deprecated_Proxy::DoReleaseObject(int64 object_id) { |
| 519 PP_Var var; | 516 PP_Var var; |
| 520 var.type = PP_VARTYPE_OBJECT; | 517 var.type = PP_VARTYPE_OBJECT; |
| 521 var.value.as_id = object_id; | 518 var.value.as_id = object_id; |
| 522 ppb_var_impl_->Release(var); | 519 ppb_var_target()->Release(var); |
| 523 } | 520 } |
| 524 | 521 |
| 525 } // namespace proxy | 522 } // namespace proxy |
| 526 } // namespace ppapi | 523 } // namespace ppapi |
| OLD | NEW |