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
3 * found in the LICENSE file.
6 /* From private/ppb_nacl_private.idl modified Mon Aug 19 14:06:38 2013. */
8 #ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
9 #define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
11 #include "ppapi/c/pp_bool.h"
12 #include "ppapi/c/pp_completion_callback.h"
13 #include "ppapi/c/pp_instance.h"
14 #include "ppapi/c/pp_macros.h"
15 #include "ppapi/c/pp_stdint.h"
16 #include "ppapi/c/pp_var.h"
17 #include "ppapi/c/private/ppb_instance_private.h"
19 #define PPB_NACL_PRIVATE_INTERFACE_1_0 "PPB_NaCl_Private;1.0"
20 #define PPB_NACL_PRIVATE_INTERFACE PPB_NACL_PRIVATE_INTERFACE_1_0
24 * This file contains NaCl private interfaces. This interface is not versioned
25 * and is for internal Chrome use. It may change without notice. */
28 #include "ppapi/c/private/pp_file_handle.h"
29 #include "ppapi/c/private/ppb_instance_private.h"
35 /** NaCl-specific errors that should be reported to the user */
38 * The manifest program element does not contain a program usable on the
41 PP_NACL_MANIFEST_MISSING_ARCH
= 0
48 * @addtogroup Interfaces
51 /* PPB_NaCl_Private */
52 struct PPB_NaCl_Private_1_0
{
53 /* Launches NaCl's sel_ldr process. Returns PP_EXTERNAL_PLUGIN_OK on success
54 * and writes a NaClHandle to imc_handle. Returns PP_EXTERNAL_PLUGIN_FAILED on
55 * failure. The |enable_ppapi_dev| parameter controls whether GetInterface
56 * returns 'Dev' interfaces to the NaCl plugin. The |uses_ppapi| flag
57 * indicates that the nexe run by sel_ldr will use the PPAPI APIs.
58 * This implies that LaunchSelLdr is run from the main thread. If a nexe
59 * does not need PPAPI, then it can run off the main thread.
60 * The |uses_irt| flag indicates whether the IRT should be loaded in this
61 * NaCl process. This is true for ABI stable nexes.
62 * The |enable_dyncode_syscalls| flag indicates whether or not the nexe
63 * will be able to use dynamic code system calls (e.g., mmap with PROT_EXEC).
64 * The |enable_exception_handling| flag indicates whether or not the nexe
65 * will be able to use hardware exception handling.
66 * The |enable_crash_throttling| flag indicates whether or not crashes of
67 * the nexe contribute to crash throttling statisics and whether nexe starts
68 * are throttled by crash throttling.
70 PP_ExternalPluginResult (*LaunchSelLdr
)(PP_Instance instance
,
71 const char* alleged_url
,
74 PP_Bool enable_ppapi_dev
,
75 PP_Bool enable_dyncode_syscalls
,
76 PP_Bool enable_exception_handling
,
77 PP_Bool enable_crash_throttling
,
79 struct PP_Var
* error_message
);
80 /* This function starts the IPC proxy so the nexe can communicate with the
81 * browser. Returns PP_EXTERNAL_PLUGIN_OK on success, otherwise a result code
82 * indicating the failure. PP_EXTERNAL_PLUGIN_FAILED is returned if
83 * LaunchSelLdr wasn't called with the instance.
84 * PP_EXTERNAL_PLUGIN_ERROR_MODULE is returned if the module can't be
85 * initialized. PP_EXTERNAL_PLUGIN_ERROR_INSTANCE is returned if the instance
86 * can't be initialized.
88 PP_ExternalPluginResult (*StartPpapiProxy
)(PP_Instance instance
);
89 /* On POSIX systems, this function returns the file descriptor of
90 * /dev/urandom. On non-POSIX systems, this function returns 0.
92 int32_t (*UrandomFD
)(void);
93 /* Whether the Pepper 3D interfaces should be disabled in the NaCl PPAPI
94 * proxy. This is so paranoid admins can effectively prevent untrusted shader
95 * code to be processed by the graphics stack.
97 PP_Bool (*Are3DInterfacesDisabled
)(void);
98 /* This is Windows-specific. This is a replacement for DuplicateHandle() for
99 * use inside the Windows sandbox. Note that we provide this via dependency
100 * injection only to avoid the linkage problems that occur because the NaCl
101 * plugin is built as a separate DLL/DSO
102 * (see http://code.google.com/p/chromium/issues/detail?id=114439#c8).
104 int32_t (*BrokerDuplicateHandle
)(PP_FileHandle source_handle
,
106 PP_FileHandle
* target_handle
,
107 uint32_t desired_access
,
109 /* Check if PNaCl is installed and attempt to install if necessary.
110 * Callback is called when the check is done and PNaCl is already installed,
111 * or after an on-demand install is attempted. Called back with PP_OK if
112 * PNaCl is available. Called back with an error otherwise.
114 int32_t (*EnsurePnaclInstalled
)(PP_Instance instance
,
115 struct PP_CompletionCallback callback
);
116 /* Returns a read-only file descriptor of a file rooted in the Pnacl
117 * component directory, or an invalid handle on failure.
119 PP_FileHandle (*GetReadonlyPnaclFd
)(const char* filename
);
120 /* This creates a temporary file that will be deleted by the time
121 * the last handle is closed (or earlier on POSIX systems), and
122 * returns a posix handle to that temporary file.
124 PP_FileHandle (*CreateTemporaryFile
)(PP_Instance instance
);
125 /* Create a temporary file, which will be deleted by the time the last
126 * handle is closed (or earlier on POSIX systems), to use for the nexe
127 * with the cache information given by |pexe_url|, |abi_version|, |opt_level|,
128 * |last_modified|, and |etag|. If the nexe is already present
129 * in the cache, |is_hit| is set to PP_TRUE and the contents of the nexe
130 * will be copied into the temporary file. Otherwise |is_hit| is set to
131 * PP_FALSE and the temporary file will be writeable.
132 * Currently the implementation is a stub, which always sets is_hit to false
133 * and calls the implementation of CreateTemporaryFile. In a subsequent CL
134 * it will call into the browser which will remember the association between
135 * the cache key and the fd, and copy the nexe into the cache after the
136 * translation finishes.
138 int32_t (*GetNexeFd
)(PP_Instance instance
,
139 const char* pexe_url
,
140 uint32_t abi_version
,
142 const char* last_modified
,
145 PP_FileHandle
* nexe_handle
,
146 struct PP_CompletionCallback callback
);
147 /* Report to the browser that translation of the pexe for |instance|
148 * has finished, or aborted with an error. If |success| is true, the
149 * browser may then store the translation in the cache. The renderer
150 * must first have called GetNexeFd for the same instance. (The browser is
151 * not guaranteed to store the nexe even if |success| is true; if there is
152 * an error on the browser side, or the file is too big for the cache, or
153 * the browser is in incognito mode, no notification will be delivered to
156 void (*ReportTranslationFinished
)(PP_Instance instance
, PP_Bool success
);
157 /* Return true if we are off the record.
159 PP_Bool (*IsOffTheRecord
)(void);
160 /* Return true if PNaCl is turned on.
162 PP_Bool (*IsPnaclEnabled
)(void);
163 /* Display a UI message to the user. */
164 PP_ExternalPluginResult (*ReportNaClError
)(PP_Instance instance
,
165 PP_NaClError message_id
);
166 /* Opens a NaCl executable file in the application's extension directory
167 * corresponding to the file URL and returns a file descriptor, or an invalid
168 * handle on failure. |metadata| is left unchanged on failure.
170 PP_FileHandle (*OpenNaClExecutable
)(PP_Instance instance
,
171 const char* file_url
,
172 uint64_t* file_token_lo
,
173 uint64_t* file_token_hi
);
176 typedef struct PPB_NaCl_Private_1_0 PPB_NaCl_Private
;
181 #endif /* PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ */