| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "ppapi/c/dev/ppb_var_deprecated.h" | 12 #include "ppapi/c/dev/ppb_var_deprecated.h" |
| 13 #include "ppapi/c/pp_var.h" | 13 #include "ppapi/c/pp_var.h" |
| 14 #include "ppapi/c/ppb_core.h" | 14 #include "ppapi/c/ppb_core.h" |
| 15 #include "ppapi/c/ppb_var.h" | 15 #include "ppapi/c/ppb_var.h" |
| 16 #include "ppapi/proxy/host_dispatcher.h" | 16 #include "ppapi/proxy/host_dispatcher.h" |
| 17 #include "ppapi/proxy/plugin_dispatcher.h" | 17 #include "ppapi/proxy/plugin_dispatcher.h" |
| 18 #include "ppapi/proxy/plugin_globals.h" | 18 #include "ppapi/proxy/plugin_globals.h" |
| 19 #include "ppapi/proxy/plugin_resource_tracker.h" | 19 #include "ppapi/proxy/plugin_resource_tracker.h" |
| 20 #include "ppapi/proxy/plugin_var_tracker.h" | 20 #include "ppapi/proxy/plugin_var_tracker.h" |
| 21 #include "ppapi/proxy/ppapi_messages.h" | 21 #include "ppapi/proxy/ppapi_messages.h" |
| 22 #include "ppapi/proxy/ppp_class_proxy.h" | 22 #include "ppapi/proxy/ppp_class_proxy.h" |
| 23 #include "ppapi/proxy/proxy_object_var.h" | 23 #include "ppapi/proxy/proxy_object_var.h" |
| 24 #include "ppapi/proxy/serialized_var.h" | 24 #include "ppapi/proxy/serialized_var.h" |
| 25 #include "ppapi/shared_impl/ppapi_globals.h" |
| 25 #include "ppapi/shared_impl/ppb_var_shared.h" | 26 #include "ppapi/shared_impl/ppb_var_shared.h" |
| 26 #include "ppapi/shared_impl/proxy_lock.h" | 27 #include "ppapi/shared_impl/proxy_lock.h" |
| 27 #include "ppapi/shared_impl/var.h" | 28 #include "ppapi/shared_impl/var.h" |
| 28 | 29 |
| 29 namespace ppapi { | 30 namespace ppapi { |
| 30 namespace proxy { | 31 namespace proxy { |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| 33 | 34 |
| 34 // Used to do get the set-up information for calling a var object. If the | 35 // Used to do get the set-up information for calling a var object. If the |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 // returned (see ipc_sync_channel.cc). In this case, that means it could | 373 // returned (see ipc_sync_channel.cc). In this case, that means it could |
| 373 // release the object before it is AddRef'ed on the browser side. | 374 // release the object before it is AddRef'ed on the browser side. |
| 374 // To work around this, we post a task here, that will not execute before | 375 // To work around this, we post a task here, that will not execute before |
| 375 // control goes back to the main message loop, that will ensure the sync send | 376 // control goes back to the main message loop, that will ensure the sync send |
| 376 // has returned and the browser side can take its reference before we Release. | 377 // has returned and the browser side can take its reference before we Release. |
| 377 // Note: if the instance is gone by the time the task is executed, then it | 378 // Note: if the instance is gone by the time the task is executed, then it |
| 378 // will Release the objects itself and this Release will be a NOOP (aside of a | 379 // will Release the objects itself and this Release will be a NOOP (aside of a |
| 379 // spurious warning). | 380 // spurious warning). |
| 380 // TODO(piman): See if we can fix the IPC code to enforce strict ordering, and | 381 // TODO(piman): See if we can fix the IPC code to enforce strict ordering, and |
| 381 // then remove this. | 382 // then remove this. |
| 382 base::MessageLoop::current()->PostNonNestableTask( | 383 PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostNonNestableTask( |
| 383 FROM_HERE, | 384 FROM_HERE, |
| 384 RunWhileLocked(base::Bind(&PPB_Var_Deprecated_Proxy::DoReleaseObject, | 385 RunWhileLocked(base::Bind(&PPB_Var_Deprecated_Proxy::DoReleaseObject, |
| 385 task_factory_.GetWeakPtr(), | 386 task_factory_.GetWeakPtr(), |
| 386 object_id))); | 387 object_id))); |
| 387 } | 388 } |
| 388 | 389 |
| 389 void PPB_Var_Deprecated_Proxy::OnMsgHasProperty( | 390 void PPB_Var_Deprecated_Proxy::OnMsgHasProperty( |
| 390 SerializedVarReceiveInput var, | 391 SerializedVarReceiveInput var, |
| 391 SerializedVarReceiveInput name, | 392 SerializedVarReceiveInput name, |
| 392 SerializedVarOutParam exception, | 393 SerializedVarOutParam exception, |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 } | 517 } |
| 517 | 518 |
| 518 void PPB_Var_Deprecated_Proxy::DoReleaseObject(int64 object_id) { | 519 void PPB_Var_Deprecated_Proxy::DoReleaseObject(int64 object_id) { |
| 519 PP_Var var = { PP_VARTYPE_OBJECT }; | 520 PP_Var var = { PP_VARTYPE_OBJECT }; |
| 520 var.value.as_id = object_id; | 521 var.value.as_id = object_id; |
| 521 ppb_var_impl_->Release(var); | 522 ppb_var_impl_->Release(var); |
| 522 } | 523 } |
| 523 | 524 |
| 524 } // namespace proxy | 525 } // namespace proxy |
| 525 } // namespace ppapi | 526 } // namespace ppapi |
| OLD | NEW |