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