| Index: src/shared/ppapi_proxy/browser_globals.cc
|
| ===================================================================
|
| --- src/shared/ppapi_proxy/browser_globals.cc (revision 3312)
|
| +++ src/shared/ppapi_proxy/browser_globals.cc (working copy)
|
| @@ -13,6 +13,8 @@
|
| namespace {
|
|
|
| std::map<PP_Instance, BrowserPpp*>* instance_to_ppp_map = NULL;
|
| +std::map<NaClSrpcChannel*, PP_Module>* channel_to_module_id_map = NULL;
|
| +
|
| // The GetInterface pointer from the browser.
|
| PPB_GetInterface get_interface;
|
| // For efficiency, cached results from GetInterface.
|
| @@ -53,6 +55,38 @@
|
| return (*instance_to_ppp_map)[instance];
|
| }
|
|
|
| +void SetModuleIdForSrpcChannel(NaClSrpcChannel* channel, PP_Module module_id) {
|
| + // If there was no map, create one.
|
| + if (channel_to_module_id_map == NULL) {
|
| + channel_to_module_id_map = new std::map<NaClSrpcChannel*, PP_Module>;
|
| + }
|
| + // Add the channel to the map.
|
| + (*channel_to_module_id_map)[channel] = module_id;
|
| +}
|
| +
|
| +void UnsetModuleIdForSrpcChannel(NaClSrpcChannel* channel) {
|
| + if (channel_to_module_id_map == NULL) {
|
| + // Something major is wrong here. We are deleting a map entry
|
| + // when there is no map.
|
| + // TODO(sehr): a CHECK here would be appropriate if we had one in NaCl.
|
| + return;
|
| + }
|
| + // Erase the channel from the map.
|
| + channel_to_module_id_map->erase(channel);
|
| + // If there are no more channels alive, remove the map.
|
| + if (channel_to_module_id_map->size() == 0) {
|
| + delete channel_to_module_id_map;
|
| + channel_to_module_id_map = NULL;
|
| + }
|
| +}
|
| +
|
| +PP_Module LookupModuleIdForSrpcChannel(NaClSrpcChannel* channel) {
|
| + if (channel_to_module_id_map == NULL) {
|
| + return NULL;
|
| + }
|
| + return (*channel_to_module_id_map)[channel];
|
| +}
|
| +
|
| void SetBrowserGetInterface(PPB_GetInterface get_interface_function) {
|
| get_interface = get_interface_function;
|
| const void* core = (*get_interface_function)(PPB_CORE_INTERFACE);
|
|
|