| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "native_client/src/shared/ppapi_proxy/browser_globals.h" | 5 #include "native_client/src/shared/ppapi_proxy/browser_globals.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <stdlib.h> | 9 #include <stdlib.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 if (instance_to_ppp_map->size() == 0) { | 76 if (instance_to_ppp_map->size() == 0) { |
| 77 delete instance_to_ppp_map; | 77 delete instance_to_ppp_map; |
| 78 instance_to_ppp_map = NULL; | 78 instance_to_ppp_map = NULL; |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| 82 BrowserPpp* LookupBrowserPppForInstance(PP_Instance instance) { | 82 BrowserPpp* LookupBrowserPppForInstance(PP_Instance instance) { |
| 83 if (NULL == instance_to_ppp_map) { | 83 if (NULL == instance_to_ppp_map) { |
| 84 return NULL; | 84 return NULL; |
| 85 } | 85 } |
| 86 return (*instance_to_ppp_map)[instance]; | 86 std::map<PP_Instance, BrowserPpp*>::const_iterator iter = |
| 87 instance_to_ppp_map->find(instance); |
| 88 if (iter == instance_to_ppp_map->end()) |
| 89 return NULL; |
| 90 return iter->second; |
| 87 } | 91 } |
| 88 | 92 |
| 89 void SetModuleIdForSrpcChannel(NaClSrpcChannel* channel, PP_Module module_id) { | 93 void SetModuleIdForSrpcChannel(NaClSrpcChannel* channel, PP_Module module_id) { |
| 90 // If there was no map, create one. | 94 // If there was no map, create one. |
| 91 if (NULL == channel_to_module_id_map) { | 95 if (NULL == channel_to_module_id_map) { |
| 92 channel_to_module_id_map = new std::map<NaClSrpcChannel*, PP_Module>; | 96 channel_to_module_id_map = new std::map<NaClSrpcChannel*, PP_Module>; |
| 93 } | 97 } |
| 94 // Add the channel to the map. | 98 // Add the channel to the map. |
| 95 (*channel_to_module_id_map)[channel] = module_id; | 99 (*channel_to_module_id_map)[channel] = module_id; |
| 96 } | 100 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 if (channel_to_instance_id_map->size() == 0) { | 132 if (channel_to_instance_id_map->size() == 0) { |
| 129 delete channel_to_module_id_map; | 133 delete channel_to_module_id_map; |
| 130 channel_to_module_id_map = NULL; | 134 channel_to_module_id_map = NULL; |
| 131 } | 135 } |
| 132 } | 136 } |
| 133 | 137 |
| 134 PP_Module LookupModuleIdForSrpcChannel(NaClSrpcChannel* channel) { | 138 PP_Module LookupModuleIdForSrpcChannel(NaClSrpcChannel* channel) { |
| 135 if (NULL == channel_to_module_id_map) { | 139 if (NULL == channel_to_module_id_map) { |
| 136 return 0; | 140 return 0; |
| 137 } | 141 } |
| 138 return (*channel_to_module_id_map)[channel]; | 142 std::map<NaClSrpcChannel*, PP_Module>::const_iterator iter = |
| 143 channel_to_module_id_map->find(channel); |
| 144 if (iter == channel_to_module_id_map->end()) { |
| 145 return 0; |
| 146 } |
| 147 return iter->second; |
| 139 } | 148 } |
| 140 | 149 |
| 141 PP_Module LookupInstanceIdForSrpcChannel(NaClSrpcChannel* channel) { | 150 PP_Instance LookupInstanceIdForSrpcChannel(NaClSrpcChannel* channel) { |
| 142 if (NULL == channel_to_instance_id_map) { | 151 if (NULL == channel_to_instance_id_map) { |
| 143 return 0; | 152 return 0; |
| 144 } | 153 } |
| 145 return (*channel_to_instance_id_map)[channel]; | 154 std::map<NaClSrpcChannel*, PP_Instance>::const_iterator iter = |
| 155 channel_to_instance_id_map->find(channel); |
| 156 if (iter == channel_to_instance_id_map->end()) { |
| 157 return 0; |
| 158 } |
| 159 return iter->second; |
| 146 } | 160 } |
| 147 | 161 |
| 148 NaClSrpcChannel* GetMainSrpcChannel(NaClSrpcRpc* upcall_rpc) { | 162 NaClSrpcChannel* GetMainSrpcChannel(NaClSrpcRpc* upcall_rpc) { |
| 149 // The upcall channel's server_instance_data member is initialized to point | 163 // The upcall channel's server_instance_data member is initialized to point |
| 150 // to the main channel for this instance. Here it is retrieved to use in | 164 // to the main channel for this instance. Here it is retrieved to use in |
| 151 // constructing a RemoteCallbackInfo. | 165 // constructing a RemoteCallbackInfo. |
| 152 return static_cast<NaClSrpcChannel*>( | 166 return static_cast<NaClSrpcChannel*>( |
| 153 upcall_rpc->channel->server_instance_data); | 167 upcall_rpc->channel->server_instance_data); |
| 154 } | 168 } |
| 155 | 169 |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 } | 491 } |
| 478 | 492 |
| 479 const PPB_UDPSocket_Private* PPBUDPSocketPrivateInterface() { | 493 const PPB_UDPSocket_Private* PPBUDPSocketPrivateInterface() { |
| 480 static const PPB_UDPSocket_Private* ppb = | 494 static const PPB_UDPSocket_Private* ppb = |
| 481 static_cast<const PPB_UDPSocket_Private*>( | 495 static_cast<const PPB_UDPSocket_Private*>( |
| 482 GetBrowserInterfaceSafe(PPB_UDPSOCKET_PRIVATE_INTERFACE)); | 496 GetBrowserInterfaceSafe(PPB_UDPSOCKET_PRIVATE_INTERFACE)); |
| 483 return ppb; | 497 return ppb; |
| 484 } | 498 } |
| 485 | 499 |
| 486 } // namespace ppapi_proxy | 500 } // namespace ppapi_proxy |
| OLD | NEW |