Chromium Code Reviews| Index: ppapi/cpp/instance.cc |
| diff --git a/ppapi/cpp/instance.cc b/ppapi/cpp/instance.cc |
| index e42adf62ddd25e0f521761b79b02cca3acbc3936..9aa4ae954b96d6435928255be5e497a35d7d1d50 100644 |
| --- a/ppapi/cpp/instance.cc |
| +++ b/ppapi/cpp/instance.cc |
| @@ -11,6 +11,7 @@ |
| #include "ppapi/cpp/graphics_2d.h" |
| #include "ppapi/cpp/graphics_3d.h" |
| #include "ppapi/cpp/image_data.h" |
| +#include "ppapi/cpp/instance_handle.h" |
| #include "ppapi/cpp/logging.h" |
| #include "ppapi/cpp/module.h" |
| #include "ppapi/cpp/module_impl.h" |
| @@ -137,6 +138,17 @@ void Instance::AddPerInstanceObject(const std::string& interface_name, |
| interface_name_to_objects_[interface_name] = object; |
| } |
| +// static |
| +void Instance::AddPerInstanceObject(const InstanceHandle& instance, |
| + const std::string& interface_name, |
| + void* object) { |
| + // TODO(brettw) assert we're on the main thread. |
|
dmichael (off chromium)
2012/02/21 23:38:02
May be worth adding a brief comment why the stuff
|
| + Instance* that = Module::Get()->InstanceForPPInstance(instance.pp_instance()); |
| + if (!that) |
| + return; |
| + that->AddPerInstanceObject(interface_name, object); |
| +} |
| + |
| void Instance::RemovePerInstanceObject(const std::string& interface_name, |
| void* object) { |
| InterfaceNameToObjectMap::iterator found = interface_name_to_objects_.find( |
| @@ -156,6 +168,17 @@ void Instance::RemovePerInstanceObject(const std::string& interface_name, |
| } |
| // static |
| +void Instance::RemovePerInstanceObject(const InstanceHandle& instance, |
| + const std::string& interface_name, |
| + void* object) { |
| + // TODO(brettw) assert we're on the main thread. |
| + Instance* that = Module::Get()->InstanceForPPInstance(instance.pp_instance()); |
| + if (!that) |
| + return; |
| + that->RemovePerInstanceObject(interface_name, object); |
| +} |
| + |
| +// static |
| void* Instance::GetPerInstanceObject(PP_Instance instance, |
| const std::string& interface_name) { |
| Instance* that = Module::Get()->InstanceForPPInstance(instance); |