| OLD | NEW |
| 1 // Copyright (c) 2010 The Native Client Authors. All rights reserved. | 1 // Copyright (c) 2010 The Native Client 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 #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_GLOBALS_H_ | 5 #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_GLOBALS_H_ |
| 6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_GLOBALS_H_ | 6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_GLOBALS_H_ |
| 7 | 7 |
| 8 #include "ppapi/c/pp_instance.h" | 8 #include "ppapi/c/pp_instance.h" |
| 9 #include "ppapi/c/pp_module.h" |
| 9 #include "ppapi/c/ppb.h" | 10 #include "ppapi/c/ppb.h" |
| 10 #include "ppapi/c/ppb_core.h" | 11 #include "ppapi/c/ppb_core.h" |
| 11 #include "ppapi/c/ppb_var.h" | 12 #include "ppapi/c/ppb_var.h" |
| 12 | 13 |
| 14 struct NaClSrpcChannel; |
| 15 |
| 13 namespace ppapi_proxy { | 16 namespace ppapi_proxy { |
| 14 | 17 |
| 15 // These functions handle the browser-side (trusted code) mapping of a browser | 18 // These functions handle the browser-side (trusted code) mapping of a browser |
| 16 // Instance to instance-specific data, such as the SRPC communication channel. | 19 // Instance to instance-specific data, such as the SRPC communication channel. |
| 17 // These functions are called by the in-browser (trusted) plugin code, and are | 20 // These functions are called by the in-browser (trusted) plugin code, and are |
| 18 // always called from the main (foreground, UI, ...) thread. As such, they are | 21 // always called from the main (foreground, UI, ...) thread. As such, they are |
| 19 // not thread-safe (they do not need to be). | 22 // not thread-safe (they do not need to be). |
| 20 | 23 |
| 21 // BrowserPpp keeps browser side PPP_Instance specific information, such as the | 24 // BrowserPpp keeps browser side PPP_Instance specific information, such as the |
| 22 // channel used to talk to the instance. | 25 // channel used to talk to the instance. |
| 23 class BrowserPpp; | 26 class BrowserPpp; |
| 24 | 27 |
| 25 // Associate a particular BrowserPpp with a PP_Instance value. This allows the | 28 // Associate a particular BrowserPpp with a PP_Instance value. This allows the |
| 26 // browser side to look up information it needs to communicate with the stub. | 29 // browser side to look up information it needs to communicate with the stub. |
| 27 void SetBrowserPppForInstance(PP_Instance instance, | 30 void SetBrowserPppForInstance(PP_Instance instance, |
| 28 BrowserPpp* browser_ppp); | 31 BrowserPpp* browser_ppp); |
| 29 // When an instance is destroyed, this is called to remove the association, as | 32 // When an instance is destroyed, this is called to remove the association, as |
| 30 // the stub will be destroyed by a call to Shutdown. | 33 // the stub will be destroyed by a call to Shutdown. |
| 31 void UnsetBrowserPppForInstance(PP_Instance instance); | 34 void UnsetBrowserPppForInstance(PP_Instance instance); |
| 32 // Gets the BrowserPpp information remembered for a particular instance. | 35 // Gets the BrowserPpp information remembered for a particular instance. |
| 33 BrowserPpp* LookupBrowserPppForInstance(PP_Instance instance); | 36 BrowserPpp* LookupBrowserPppForInstance(PP_Instance instance); |
| 34 | 37 |
| 38 // To keep track of memory allocated by a particular module, we need to remember |
| 39 // the PP_Module corresponding to a particular NaClSrpcChannel*. |
| 40 void SetModuleIdForSrpcChannel(NaClSrpcChannel* channel, PP_Module module_id); |
| 41 // Removes the association with a given channel. |
| 42 void UnsetModuleIdForSrpcChannel(NaClSrpcChannel* channel); |
| 43 // Looks up the association with a given channel. |
| 44 PP_Module LookupModuleIdForSrpcChannel(NaClSrpcChannel* channel); |
| 45 |
| 35 // We need to keep the browser GetInterface function pointer, as parts of the | 46 // We need to keep the browser GetInterface function pointer, as parts of the |
| 36 // proxy will need to invoke interfaces such as the 2D and 3D APIs. | 47 // proxy will need to invoke interfaces such as the 2D and 3D APIs. |
| 37 void SetBrowserGetInterface(PPB_GetInterface get_interface_function); | 48 void SetBrowserGetInterface(PPB_GetInterface get_interface_function); |
| 38 const void* GetBrowserInterface(const char* interface_name); | 49 const void* GetBrowserInterface(const char* interface_name); |
| 39 | 50 |
| 40 // We need an interface to get PPB_Core that is spelled the same way for | 51 // We need an interface to get PPB_Core that is spelled the same way for |
| 41 // both plugins and the browser side of the proxy. | 52 // both plugins and the browser side of the proxy. |
| 42 // Set by SetBrowserGetInterface. | 53 // Set by SetBrowserGetInterface. |
| 43 const PPB_Core* CoreInterface(); | 54 const PPB_Core* CoreInterface(); |
| 44 | 55 |
| 45 // We need an interface to get PPB_Var that is spelled the same way for | 56 // We need an interface to get PPB_Var that is spelled the same way for |
| 46 // both plugins and the browser side of the proxy. | 57 // both plugins and the browser side of the proxy. |
| 47 // Set by SetBrowserGetInterface. | 58 // Set by SetBrowserGetInterface. |
| 48 const PPB_Var* VarInterface(); | 59 const PPB_Var* VarInterface(); |
| 49 | 60 |
| 50 } // namespace ppapi_proxy | 61 } // namespace ppapi_proxy |
| 51 | 62 |
| 52 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_GLOBALS_H_ | 63 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_GLOBALS_H_ |
| OLD | NEW |