OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_GLOBALS_H_ |
| 6 #define NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_GLOBALS_H_ |
| 7 |
| 8 #include "ppapi/c/dev/ppb_cursor_control_dev.h" |
| 9 #include "ppapi/c/dev/ppb_find_dev.h" |
| 10 #include "ppapi/c/dev/ppb_graphics_3d_dev.h" |
| 11 #include "ppapi/c/dev/ppb_graphics_3d_trusted_dev.h" |
| 12 #include "ppapi/c/dev/ppb_font_dev.h" |
| 13 #include "ppapi/c/dev/ppb_memory_dev.h" |
| 14 #include "ppapi/c/dev/ppb_scrollbar_dev.h" |
| 15 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 16 #include "ppapi/c/dev/ppb_var_deprecated.h" |
| 17 #include "ppapi/c/dev/ppb_widget_dev.h" |
| 18 #include "ppapi/c/dev/ppb_zoom_dev.h" |
| 19 #include "ppapi/c/pp_instance.h" |
| 20 #include "ppapi/c/pp_module.h" |
| 21 #include "ppapi/c/ppb.h" |
| 22 #include "ppapi/c/ppb_core.h" |
| 23 #include "ppapi/c/ppb_file_io.h" |
| 24 #include "ppapi/c/ppb_file_ref.h" |
| 25 #include "ppapi/c/ppb_file_system.h" |
| 26 #include "ppapi/c/ppb_graphics_2d.h" |
| 27 #include "ppapi/c/ppb_image_data.h" |
| 28 #include "ppapi/c/ppb_input_event.h" |
| 29 #include "ppapi/c/ppb_instance.h" |
| 30 #include "ppapi/c/ppb_messaging.h" |
| 31 #include "ppapi/c/ppb_url_loader.h" |
| 32 #include "ppapi/c/ppb_url_request_info.h" |
| 33 #include "ppapi/c/ppb_url_response_info.h" |
| 34 #include "ppapi/c/ppb_var.h" |
| 35 #include "ppapi/c/private/ppb_pdf.h" |
| 36 #include "ppapi/c/trusted/ppb_image_data_trusted.h" |
| 37 |
| 38 struct NaClSrpcRpc; |
| 39 struct NaClSrpcChannel; |
| 40 |
| 41 namespace ppapi_proxy { |
| 42 |
| 43 // These functions handle the browser-side (trusted code) mapping of a browser |
| 44 // Instance to instance-specific data, such as the SRPC communication channel. |
| 45 // These functions are called by the in-browser (trusted) plugin code, and are |
| 46 // always called from the main (foreground, UI, ...) thread. As such, they are |
| 47 // not thread-safe (they do not need to be). |
| 48 |
| 49 // BrowserPpp keeps browser side PPP_Instance specific information, such as the |
| 50 // channel used to talk to the instance. |
| 51 class BrowserPpp; |
| 52 |
| 53 // Returns true if the PPAPI Developer interface is enabled. |
| 54 // To enable, set the environment variable NACL_ENABLE_PPAPI_DEV=1 |
| 55 // Note: Developer interfaces are _not_ enabled by default. |
| 56 bool DevInterfaceEnabled(); |
| 57 |
| 58 // Associate a particular BrowserPpp with a PP_Instance value. This allows the |
| 59 // browser side to look up information it needs to communicate with the stub. |
| 60 void SetBrowserPppForInstance(PP_Instance instance, |
| 61 BrowserPpp* browser_ppp); |
| 62 // When an instance is destroyed, this is called to remove the association, as |
| 63 // the stub will be destroyed by a call to Shutdown. |
| 64 void UnsetBrowserPppForInstance(PP_Instance instance); |
| 65 // Gets the BrowserPpp information remembered for a particular instance. |
| 66 BrowserPpp* LookupBrowserPppForInstance(PP_Instance instance); |
| 67 |
| 68 // To keep track of memory allocated by a particular module, we need to remember |
| 69 // the PP_Module corresponding to a particular NaClSrpcChannel*. |
| 70 void SetModuleIdForSrpcChannel(NaClSrpcChannel* channel, PP_Module module_id); |
| 71 // To call remote callbacks only when the proxy is up and running, we need to |
| 72 // remember the PP_Instance corresponding to a particular NaClSrpcChannel*. |
| 73 void SetInstanceIdForSrpcChannel(NaClSrpcChannel* channel, |
| 74 PP_Instance instance_id); |
| 75 // Removes the association with a given channel. |
| 76 void UnsetModuleIdForSrpcChannel(NaClSrpcChannel* channel); |
| 77 void UnsetInstanceIdForSrpcChannel(NaClSrpcChannel* channel); |
| 78 // Looks up the association with a given channel. |
| 79 PP_Module LookupModuleIdForSrpcChannel(NaClSrpcChannel* channel); |
| 80 PP_Instance LookupInstanceIdForSrpcChannel(NaClSrpcChannel* channel); |
| 81 |
| 82 // Helpers for getting a pointer to the "main channel" for a specific nexe. |
| 83 NaClSrpcChannel* GetMainSrpcChannel(NaClSrpcRpc* upcall_rpc); |
| 84 NaClSrpcChannel* GetMainSrpcChannel(PP_Instance); |
| 85 |
| 86 // Invalidates the proxy and alerts the plugin about a dead nexe. |
| 87 void CleanUpAfterDeadNexe(PP_Instance instance); |
| 88 |
| 89 // Support for getting PPB_ browser interfaces. |
| 90 // Safe version CHECK's for NULL. |
| 91 void SetPPBGetInterface(PPB_GetInterface get_interface_function, |
| 92 bool dev_interface); |
| 93 const void* GetBrowserInterface(const char* interface_name); |
| 94 const void* GetBrowserInterfaceSafe(const char* interface_name); |
| 95 // Functions marked "shared" are to be provided by both the browser and the |
| 96 // plugin side of the proxy, so they can be used by the shared proxy code |
| 97 // under both trusted and untrusted compilation. |
| 98 const PPB_Core* PPBCoreInterface(); // shared |
| 99 const PPB_CursorControl_Dev* PPBCursorControlInterface(); |
| 100 const PPB_FileIO* PPBFileIOInterface(); |
| 101 const PPB_FileRef* PPBFileRefInterface(); |
| 102 const PPB_FileSystem* PPBFileSystemInterface(); |
| 103 const PPB_Find_Dev* PPBFindInterface(); |
| 104 const PPB_Font_Dev* PPBFontInterface(); |
| 105 const PPB_Graphics2D* PPBGraphics2DInterface(); |
| 106 const PPB_Graphics3D_Dev* PPBGraphics3DInterface(); |
| 107 const PPB_Graphics3DTrusted_Dev* PPBGraphics3DTrustedInterface(); |
| 108 const PPB_ImageData* PPBImageDataInterface(); |
| 109 const PPB_ImageDataTrusted* PPBImageDataTrustedInterface(); |
| 110 const PPB_InputEvent* PPBInputEventInterface(); |
| 111 const PPB_Instance* PPBInstanceInterface(); |
| 112 const PPB_KeyboardInputEvent* PPBKeyboardInputEventInterface(); |
| 113 const PPB_Memory_Dev* PPBMemoryInterface(); // shared |
| 114 const PPB_MouseInputEvent* PPBMouseInputEventInterface(); |
| 115 const PPB_Messaging* PPBMessagingInterface(); |
| 116 const PPB_PDF* PPBPDFInterface(); |
| 117 const PPB_Scrollbar_Dev* PPBScrollbarInterface(); |
| 118 const PPB_Testing_Dev* PPBTestingInterface(); |
| 119 const PPB_URLLoader* PPBURLLoaderInterface(); |
| 120 const PPB_URLRequestInfo* PPBURLRequestInfoInterface(); |
| 121 const PPB_URLResponseInfo* PPBURLResponseInfoInterface(); |
| 122 const PPB_Var* PPBVarInterface(); // shared |
| 123 const PPB_WheelInputEvent* PPBWheelInputEventInterface(); |
| 124 const PPB_Widget_Dev* PPBWidgetInterface(); |
| 125 const PPB_Zoom_Dev* PPBZoomInterface(); |
| 126 |
| 127 // PPAPI constants used in the proxy. |
| 128 extern const PP_Resource kInvalidResourceId; |
| 129 |
| 130 } // namespace ppapi_proxy |
| 131 |
| 132 #endif // NATIVE_CLIENT_SRC_SHARED_PPAPI_PROXY_BROWSER_GLOBALS_H_ |
OLD | NEW |