| 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/proxy_object_var.h" | 5 #include "ppapi/proxy/proxy_object_var.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/c/pp_var.h" | 8 #include "ppapi/c/pp_var.h" |
| 9 | 9 |
| 10 using ppapi::proxy::PluginDispatcher; | 10 using ppapi::proxy::PluginDispatcher; |
| 11 | 11 |
| 12 namespace ppapi { | 12 namespace ppapi { |
| 13 | 13 |
| 14 ProxyObjectVar::ProxyObjectVar(PluginDispatcher* dispatcher, | 14 ProxyObjectVar::ProxyObjectVar(PluginDispatcher* dispatcher, |
| 15 int32 host_var_id) | 15 int32 host_var_id) |
| 16 : dispatcher_(dispatcher), | 16 : dispatcher_(dispatcher), |
| 17 host_var_id_(host_var_id) { | 17 host_var_id_(host_var_id) { |
| 18 // Should be given valid objects or we'll crash later. | 18 // Should be given valid objects or we'll crash later. |
| 19 DCHECK(dispatcher_); | 19 DCHECK(dispatcher_); |
| 20 DCHECK(host_var_id_); | 20 DCHECK(host_var_id_); |
| 21 } | 21 } |
| 22 | 22 |
| 23 ProxyObjectVar::~ProxyObjectVar() { | 23 ProxyObjectVar::~ProxyObjectVar() { |
| 24 } | 24 } |
| 25 | 25 |
| 26 ProxyObjectVar* ProxyObjectVar::AsProxyObjectVar() { | 26 ProxyObjectVar* ProxyObjectVar::AsProxyObjectVar() { |
| 27 return this; | 27 return this; |
| 28 } | 28 } |
| 29 | 29 |
| 30 PP_Var ProxyObjectVar::GetPPVar() { | |
| 31 int32 id = GetOrCreateVarID(); | |
| 32 if (!id) | |
| 33 return PP_MakeNull(); | |
| 34 | |
| 35 PP_Var result; | |
| 36 result.type = PP_VARTYPE_OBJECT; | |
| 37 result.value.as_id = id; | |
| 38 return result; | |
| 39 } | |
| 40 | |
| 41 PP_VarType ProxyObjectVar::GetType() const { | 30 PP_VarType ProxyObjectVar::GetType() const { |
| 42 return PP_VARTYPE_OBJECT; | 31 return PP_VARTYPE_OBJECT; |
| 43 } | 32 } |
| 44 | 33 |
| 45 void ProxyObjectVar::AssignVarID(int32 id) { | 34 void ProxyObjectVar::AssignVarID(int32 id) { |
| 46 return Var::AssignVarID(id); | 35 return Var::AssignVarID(id); |
| 47 } | 36 } |
| 48 | 37 |
| 49 } // namespace ppapi | 38 } // namespace ppapi |
| OLD | NEW |