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/plugin_var_tracker.h" | 5 #include "ppapi/proxy/plugin_var_tracker.h" |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
9 #include "ppapi/c/ppb_var.h" | 9 #include "ppapi/c/ppb_var.h" |
10 #include "ppapi/proxy/plugin_dispatcher.h" | 10 #include "ppapi/proxy/plugin_dispatcher.h" |
11 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
12 #include "ppapi/proxy/interface_id.h" | |
13 #include "ppapi/proxy/proxy_object_var.h" | 12 #include "ppapi/proxy/proxy_object_var.h" |
| 13 #include "ppapi/shared_impl/api_id.h" |
14 #include "ppapi/shared_impl/var.h" | 14 #include "ppapi/shared_impl/var.h" |
15 | 15 |
16 namespace ppapi { | 16 namespace ppapi { |
17 namespace proxy { | 17 namespace proxy { |
18 | 18 |
19 PluginVarTracker::HostVar::HostVar(PluginDispatcher* d, int32 i) | 19 PluginVarTracker::HostVar::HostVar(PluginDispatcher* d, int32 i) |
20 : dispatcher(d), | 20 : dispatcher(d), |
21 host_object_id(i) { | 21 host_object_id(i) { |
22 } | 22 } |
23 | 23 |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 PP_Var ret; | 233 PP_Var ret; |
234 ret.type = PP_VARTYPE_OBJECT; | 234 ret.type = PP_VARTYPE_OBJECT; |
235 ret.value.as_id = var_id; | 235 ret.value.as_id = var_id; |
236 return ret; | 236 return ret; |
237 } | 237 } |
238 | 238 |
239 void PluginVarTracker::SendAddRefObjectMsg( | 239 void PluginVarTracker::SendAddRefObjectMsg( |
240 const ProxyObjectVar& proxy_object) { | 240 const ProxyObjectVar& proxy_object) { |
241 int unused; | 241 int unused; |
242 proxy_object.dispatcher()->Send(new PpapiHostMsg_PPBVar_AddRefObject( | 242 proxy_object.dispatcher()->Send(new PpapiHostMsg_PPBVar_AddRefObject( |
243 INTERFACE_ID_PPB_VAR_DEPRECATED, proxy_object.host_var_id(), &unused)); | 243 API_ID_PPB_VAR_DEPRECATED, proxy_object.host_var_id(), &unused)); |
244 } | 244 } |
245 | 245 |
246 void PluginVarTracker::SendReleaseObjectMsg( | 246 void PluginVarTracker::SendReleaseObjectMsg( |
247 const ProxyObjectVar& proxy_object) { | 247 const ProxyObjectVar& proxy_object) { |
248 proxy_object.dispatcher()->Send(new PpapiHostMsg_PPBVar_ReleaseObject( | 248 proxy_object.dispatcher()->Send(new PpapiHostMsg_PPBVar_ReleaseObject( |
249 INTERFACE_ID_PPB_VAR_DEPRECATED, proxy_object.host_var_id())); | 249 API_ID_PPB_VAR_DEPRECATED, proxy_object.host_var_id())); |
250 } | 250 } |
251 | 251 |
252 scoped_refptr<ProxyObjectVar> PluginVarTracker::FindOrMakePluginVarFromHostVar( | 252 scoped_refptr<ProxyObjectVar> PluginVarTracker::FindOrMakePluginVarFromHostVar( |
253 const PP_Var& var, | 253 const PP_Var& var, |
254 PluginDispatcher* dispatcher) { | 254 PluginDispatcher* dispatcher) { |
255 DCHECK(var.type == PP_VARTYPE_OBJECT); | 255 DCHECK(var.type == PP_VARTYPE_OBJECT); |
256 HostVar host_var(dispatcher, var.value.as_id); | 256 HostVar host_var(dispatcher, var.value.as_id); |
257 | 257 |
258 HostVarToPluginVarMap::iterator found = | 258 HostVarToPluginVarMap::iterator found = |
259 host_var_to_plugin_var_.find(host_var); | 259 host_var_to_plugin_var_.find(host_var); |
260 if (found == host_var_to_plugin_var_.end()) { | 260 if (found == host_var_to_plugin_var_.end()) { |
261 // Create a new object. | 261 // Create a new object. |
262 return scoped_refptr<ProxyObjectVar>( | 262 return scoped_refptr<ProxyObjectVar>( |
263 new ProxyObjectVar(dispatcher, static_cast<int32>(var.value.as_id))); | 263 new ProxyObjectVar(dispatcher, static_cast<int32>(var.value.as_id))); |
264 } | 264 } |
265 | 265 |
266 // Have this host var, look up the object. | 266 // Have this host var, look up the object. |
267 VarMap::iterator ret = live_vars_.find(found->second); | 267 VarMap::iterator ret = live_vars_.find(found->second); |
268 DCHECK(ret != live_vars_.end()); | 268 DCHECK(ret != live_vars_.end()); |
269 | 269 |
270 // All objects should be proxy objects. | 270 // All objects should be proxy objects. |
271 DCHECK(ret->second.var->AsProxyObjectVar()); | 271 DCHECK(ret->second.var->AsProxyObjectVar()); |
272 return scoped_refptr<ProxyObjectVar>(ret->second.var->AsProxyObjectVar()); | 272 return scoped_refptr<ProxyObjectVar>(ret->second.var->AsProxyObjectVar()); |
273 } | 273 } |
274 | 274 |
275 } // namesace proxy | 275 } // namesace proxy |
276 } // namespace ppapi | 276 } // namespace ppapi |
OLD | NEW |