| 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.h" | 11 #include "base/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_var.h" | 14 #include "ppapi/c/ppb_var.h" |
| 15 #include "ppapi/c/ppb_core.h" | 15 #include "ppapi/c/ppb_core.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/proxy_object_var.h" |
| 21 #include "ppapi/proxy/ppapi_messages.h" | 22 #include "ppapi/proxy/ppapi_messages.h" |
| 22 #include "ppapi/proxy/ppp_class_proxy.h" | 23 #include "ppapi/proxy/ppp_class_proxy.h" |
| 23 #include "ppapi/proxy/serialized_var.h" | 24 #include "ppapi/proxy/serialized_var.h" |
| 24 #include "ppapi/shared_impl/ppb_var_shared.h" | 25 #include "ppapi/shared_impl/ppb_var_shared.h" |
| 25 #include "ppapi/shared_impl/proxy_lock.h" | 26 #include "ppapi/shared_impl/proxy_lock.h" |
| 26 #include "ppapi/shared_impl/var.h" | 27 #include "ppapi/shared_impl/var.h" |
| 27 | 28 |
| 28 namespace ppapi { | 29 namespace ppapi { |
| 29 namespace proxy { | 30 namespace proxy { |
| 30 | 31 |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 248 } |
| 248 | 249 |
| 249 PP_Var CreateObject(PP_Instance instance, | 250 PP_Var CreateObject(PP_Instance instance, |
| 250 const PPP_Class_Deprecated* ppp_class, | 251 const PPP_Class_Deprecated* ppp_class, |
| 251 void* ppp_class_data) { | 252 void* ppp_class_data) { |
| 252 ProxyAutoLock lock; | 253 ProxyAutoLock lock; |
| 253 Dispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); | 254 Dispatcher* dispatcher = PluginDispatcher::GetForInstance(instance); |
| 254 if (!dispatcher) | 255 if (!dispatcher) |
| 255 return PP_MakeUndefined(); | 256 return PP_MakeUndefined(); |
| 256 | 257 |
| 258 PluginVarTracker* tracker = PluginGlobals::Get()->plugin_var_tracker(); |
| 259 if (tracker->IsPluginImplementedObjectAlive(ppp_class_data)) |
| 260 return PP_MakeUndefined(); // Object already exists with this user data. |
| 261 |
| 257 ReceiveSerializedVarReturnValue result; | 262 ReceiveSerializedVarReturnValue result; |
| 258 int64 class_int = static_cast<int64>(reinterpret_cast<intptr_t>(ppp_class)); | 263 int64 class_int = static_cast<int64>(reinterpret_cast<intptr_t>(ppp_class)); |
| 259 int64 data_int = | 264 int64 data_int = |
| 260 static_cast<int64>(reinterpret_cast<intptr_t>(ppp_class_data)); | 265 static_cast<int64>(reinterpret_cast<intptr_t>(ppp_class_data)); |
| 261 dispatcher->Send(new PpapiHostMsg_PPBVar_CreateObjectDeprecated( | 266 dispatcher->Send(new PpapiHostMsg_PPBVar_CreateObjectDeprecated( |
| 262 API_ID_PPB_VAR_DEPRECATED, instance, class_int, data_int, | 267 API_ID_PPB_VAR_DEPRECATED, instance, class_int, data_int, |
| 263 &result)); | 268 &result)); |
| 264 return result.Return(dispatcher); | 269 PP_Var ret_var = result.Return(dispatcher); |
| 270 |
| 271 // Register this object as being implemented by the plugin. |
| 272 tracker->PluginImplementedObjectCreated(instance, ret_var, |
| 273 ppp_class, ppp_class_data); |
| 274 return ret_var; |
| 265 } | 275 } |
| 266 | 276 |
| 267 InterfaceProxy* CreateVarDeprecatedProxy(Dispatcher* dispatcher) { | 277 InterfaceProxy* CreateVarDeprecatedProxy(Dispatcher* dispatcher) { |
| 268 return new PPB_Var_Deprecated_Proxy(dispatcher ); | 278 return new PPB_Var_Deprecated_Proxy(dispatcher ); |
| 269 } | 279 } |
| 270 | 280 |
| 271 } // namespace | 281 } // namespace |
| 272 | 282 |
| 273 PPB_Var_Deprecated_Proxy::PPB_Var_Deprecated_Proxy( | 283 PPB_Var_Deprecated_Proxy::PPB_Var_Deprecated_Proxy( |
| 274 Dispatcher* dispatcher) | 284 Dispatcher* dispatcher) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 } | 523 } |
| 514 | 524 |
| 515 void PPB_Var_Deprecated_Proxy::DoReleaseObject(int64 object_id) { | 525 void PPB_Var_Deprecated_Proxy::DoReleaseObject(int64 object_id) { |
| 516 PP_Var var = { PP_VARTYPE_OBJECT }; | 526 PP_Var var = { PP_VARTYPE_OBJECT }; |
| 517 var.value.as_id = object_id; | 527 var.value.as_id = object_id; |
| 518 ppb_var_impl_->Release(var); | 528 ppb_var_impl_->Release(var); |
| 519 } | 529 } |
| 520 | 530 |
| 521 } // namespace proxy | 531 } // namespace proxy |
| 522 } // namespace ppapi | 532 } // namespace ppapi |
| OLD | NEW |