| 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 "webkit/plugins/ppapi/resource_tracker.h" | 5 #include "webkit/plugins/ppapi/resource_tracker.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
| 12 #include "ppapi/c/pp_resource.h" | 12 #include "ppapi/c/pp_resource.h" |
| 13 #include "ppapi/c/pp_var.h" | 13 #include "ppapi/c/pp_var.h" |
| 14 #include "ppapi/shared_impl/function_group_base.h" | 14 #include "ppapi/shared_impl/function_group_base.h" |
| 15 #include "ppapi/shared_impl/tracker_base.h" | 15 #include "ppapi/shared_impl/tracker_base.h" |
| 16 #include "webkit/plugins/ppapi/plugin_module.h" | 16 #include "webkit/plugins/ppapi/plugin_module.h" |
| 17 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 17 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 18 #include "webkit/plugins/ppapi/ppb_char_set_impl.h" | 18 #include "webkit/plugins/ppapi/ppb_char_set_impl.h" |
| 19 #include "webkit/plugins/ppapi/ppb_cursor_control_impl.h" | 19 #include "webkit/plugins/ppapi/ppb_cursor_control_impl.h" |
| 20 #include "webkit/plugins/ppapi/ppb_find_impl.h" |
| 20 #include "webkit/plugins/ppapi/ppb_font_impl.h" | 21 #include "webkit/plugins/ppapi/ppb_font_impl.h" |
| 21 #include "webkit/plugins/ppapi/resource.h" | 22 #include "webkit/plugins/ppapi/resource.h" |
| 22 #include "webkit/plugins/ppapi/resource_creation_impl.h" | 23 #include "webkit/plugins/ppapi/resource_creation_impl.h" |
| 23 #include "webkit/plugins/ppapi/var.h" | 24 #include "webkit/plugins/ppapi/var.h" |
| 24 | 25 |
| 25 enum PPIdType { | 26 enum PPIdType { |
| 26 PP_ID_TYPE_MODULE, | 27 PP_ID_TYPE_MODULE, |
| 27 PP_ID_TYPE_INSTANCE, | 28 PP_ID_TYPE_INSTANCE, |
| 28 PP_ID_TYPE_RESOURCE, | 29 PP_ID_TYPE_RESOURCE, |
| 29 PP_ID_TYPE_VAR, | 30 PP_ID_TYPE_VAR, |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 if (proxy.get()) | 271 if (proxy.get()) |
| 271 return proxy.get(); | 272 return proxy.get(); |
| 272 | 273 |
| 273 switch (id) { | 274 switch (id) { |
| 274 case pp::proxy::INTERFACE_ID_PPB_CHAR_SET: | 275 case pp::proxy::INTERFACE_ID_PPB_CHAR_SET: |
| 275 proxy.reset(new PPB_CharSet_Impl(instance)); | 276 proxy.reset(new PPB_CharSet_Impl(instance)); |
| 276 break; | 277 break; |
| 277 case pp::proxy::INTERFACE_ID_PPB_CURSORCONTROL: | 278 case pp::proxy::INTERFACE_ID_PPB_CURSORCONTROL: |
| 278 proxy.reset(new PPB_CursorControl_Impl(instance)); | 279 proxy.reset(new PPB_CursorControl_Impl(instance)); |
| 279 break; | 280 break; |
| 281 case pp::proxy::INTERFACE_ID_PPB_FIND: |
| 282 proxy.reset(new PPB_Find_Impl(instance)); |
| 283 break; |
| 280 case pp::proxy::INTERFACE_ID_PPB_FONT: | 284 case pp::proxy::INTERFACE_ID_PPB_FONT: |
| 281 proxy.reset(new PPB_Font_FunctionImpl(instance)); | 285 proxy.reset(new PPB_Font_FunctionImpl(instance)); |
| 282 break; | 286 break; |
| 283 case pp::proxy::INTERFACE_ID_RESOURCE_CREATION: | 287 case pp::proxy::INTERFACE_ID_RESOURCE_CREATION: |
| 284 proxy.reset(new ResourceCreationImpl(instance)); | 288 proxy.reset(new ResourceCreationImpl(instance)); |
| 285 break; | 289 break; |
| 286 default: | 290 default: |
| 287 NOTREACHED(); | 291 NOTREACHED(); |
| 288 } | 292 } |
| 289 | 293 |
| 290 return proxy.get(); | 294 return proxy.get(); |
| 291 } | 295 } |
| 292 | 296 |
| 297 PP_Instance ResourceTracker::GetInstanceForResource(PP_Resource pp_resource) { |
| 298 scoped_refptr<Resource> resource(GetResource(pp_resource)); |
| 299 if (!resource.get()) |
| 300 return 0; |
| 301 return resource->instance()->pp_instance(); |
| 302 } |
| 303 |
| 293 scoped_refptr<Var> ResourceTracker::GetVar(int32 var_id) const { | 304 scoped_refptr<Var> ResourceTracker::GetVar(int32 var_id) const { |
| 294 DLOG_IF(ERROR, !CheckIdType(var_id, PP_ID_TYPE_VAR)) | 305 DLOG_IF(ERROR, !CheckIdType(var_id, PP_ID_TYPE_VAR)) |
| 295 << var_id << " is not a PP_Var ID."; | 306 << var_id << " is not a PP_Var ID."; |
| 296 VarMap::const_iterator result = live_vars_.find(var_id); | 307 VarMap::const_iterator result = live_vars_.find(var_id); |
| 297 if (result == live_vars_.end()) | 308 if (result == live_vars_.end()) |
| 298 return scoped_refptr<Var>(); | 309 return scoped_refptr<Var>(); |
| 299 return result->second.first; | 310 return result->second.first; |
| 300 } | 311 } |
| 301 | 312 |
| 302 bool ResourceTracker::AddRefVar(int32 var_id) { | 313 bool ResourceTracker::AddRefVar(int32 var_id) { |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 | 426 |
| 416 // static | 427 // static |
| 417 void ResourceTracker::ClearSingletonOverride() { | 428 void ResourceTracker::ClearSingletonOverride() { |
| 418 DCHECK(singleton_override_); | 429 DCHECK(singleton_override_); |
| 419 singleton_override_ = NULL; | 430 singleton_override_ = NULL; |
| 420 } | 431 } |
| 421 | 432 |
| 422 } // namespace ppapi | 433 } // namespace ppapi |
| 423 } // namespace webkit | 434 } // namespace webkit |
| 424 | 435 |
| OLD | NEW |