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 Feb 10 11:05:29 2014. */
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
44 /** Event types that NaCl may use when reporting load progress or errors. */
46 PP_NACL_EVENT_LOADSTART,
47 PP_NACL_EVENT_PROGRESS,
51 PP_NACL_EVENT_LOADEND,
59 * @addtogroup Interfaces
62 /* PPB_NaCl_Private */
63 struct PPB_NaCl_Private_1_0 {
64 /* Launches NaCl's sel_ldr process. Returns PP_EXTERNAL_PLUGIN_OK on success
65 * and writes a NaClHandle to imc_handle. Returns PP_EXTERNAL_PLUGIN_FAILED on
66 * failure. The |enable_ppapi_dev| parameter controls whether GetInterface
67 * returns 'Dev' interfaces to the NaCl plugin. The |uses_ppapi| flag
68 * indicates that the nexe run by sel_ldr will use the PPAPI APIs.
69 * This implies that LaunchSelLdr is run from the main thread. If a nexe
70 * does not need PPAPI, then it can run off the main thread.
71 * The |uses_irt| flag indicates whether the IRT should be loaded in this
72 * NaCl process. This is true for ABI stable nexes.
73 * The |enable_dyncode_syscalls| flag indicates whether or not the nexe
74 * will be able to use dynamic code system calls (e.g., mmap with PROT_EXEC).
75 * The |enable_exception_handling| flag indicates whether or not the nexe
76 * will be able to use hardware exception handling.
77 * The |enable_crash_throttling| flag indicates whether or not crashes of
78 * the nexe contribute to crash throttling statisics and whether nexe starts
79 * are throttled by crash throttling.
81 void (*LaunchSelLdr)(PP_Instance instance,
82 const char* alleged_url,
85 PP_Bool enable_ppapi_dev,
86 PP_Bool enable_dyncode_syscalls,
87 PP_Bool enable_exception_handling,
88 PP_Bool enable_crash_throttling,
90 struct PP_Var* error_message,
91 struct PP_CompletionCallback callback);
92 /* This function starts the IPC proxy so the nexe can communicate with the
93 * browser. Returns PP_EXTERNAL_PLUGIN_OK on success, otherwise a result code
94 * indicating the failure. PP_EXTERNAL_PLUGIN_FAILED is returned if
95 * LaunchSelLdr wasn't called with the instance.
96 * PP_EXTERNAL_PLUGIN_ERROR_MODULE is returned if the module can't be
97 * initialized. PP_EXTERNAL_PLUGIN_ERROR_INSTANCE is returned if the instance
98 * can't be initialized.
100 PP_ExternalPluginResult (*StartPpapiProxy)(PP_Instance instance);
101 /* On POSIX systems, this function returns the file descriptor of
102 * /dev/urandom. On non-POSIX systems, this function returns 0.
104 int32_t (*UrandomFD)(void);
105 /* Whether the Pepper 3D interfaces should be disabled in the NaCl PPAPI
106 * proxy. This is so paranoid admins can effectively prevent untrusted shader
107 * code to be processed by the graphics stack.
109 PP_Bool (*Are3DInterfacesDisabled)(void);
110 /* This is Windows-specific. This is a replacement for DuplicateHandle() for
111 * use inside the Windows sandbox. Note that we provide this via dependency
112 * injection only to avoid the linkage problems that occur because the NaCl
113 * plugin is built as a separate DLL/DSO
114 * (see http://code.google.com/p/chromium/issues/detail?id=114439#c8).
116 int32_t (*BrokerDuplicateHandle)(PP_FileHandle source_handle,
118 PP_FileHandle* target_handle,
119 uint32_t desired_access,
121 /* Returns a read-only file descriptor of a file rooted in the Pnacl
122 * component directory, or an invalid handle on failure.
124 PP_FileHandle (*GetReadonlyPnaclFd)(const char* filename);
125 /* This creates a temporary file that will be deleted by the time
126 * the last handle is closed (or earlier on POSIX systems), and
127 * returns a posix handle to that temporary file.
129 PP_FileHandle (*CreateTemporaryFile)(PP_Instance instance);
130 /* Return the number of processors in the system as reported by the OS */
131 int32_t (*GetNumberOfProcessors)(void);
132 /* Create a temporary file, which will be deleted by the time the
133 * last handle is closed (or earlier on POSIX systems), to use for
134 * the nexe with the cache information given by |pexe_url|,
135 * |abi_version|, |opt_level|, |last_modified|, |etag|, and
136 * |has_no_store_header|. If the nexe is already present in the
137 * cache, |is_hit| is set to PP_TRUE and the contents of the nexe
138 * will be copied into the temporary file. Otherwise |is_hit| is set
139 * to PP_FALSE and the temporary file will be writeable. Currently
140 * the implementation is a stub, which always sets is_hit to false
141 * and calls the implementation of CreateTemporaryFile. In a
142 * subsequent CL it will call into the browser which will remember
143 * the association between the cache key and the fd, and copy the
144 * nexe into the cache after the translation finishes.
146 int32_t (*GetNexeFd)(PP_Instance instance,
147 const char* pexe_url,
148 uint32_t abi_version,
150 const char* last_modified,
152 PP_Bool has_no_store_header,
153 const char* sandbox_isa,
154 const char* extra_flags,
156 PP_FileHandle* nexe_handle,
157 struct PP_CompletionCallback callback);
158 /* Report to the browser that translation of the pexe for |instance|
159 * has finished, or aborted with an error. If |success| is true, the
160 * browser may then store the translation in the cache. The renderer
161 * must first have called GetNexeFd for the same instance. (The browser is
162 * not guaranteed to store the nexe even if |success| is true; if there is
163 * an error on the browser side, or the file is too big for the cache, or
164 * the browser is in incognito mode, no notification will be delivered to
167 void (*ReportTranslationFinished)(PP_Instance instance, PP_Bool success);
168 /* Display a UI message to the user. */
169 PP_ExternalPluginResult (*ReportNaClError)(PP_Instance instance,
170 PP_NaClError message_id);
171 /* Opens a NaCl executable file in the application's extension directory
172 * corresponding to the file URL and returns a file descriptor, or an invalid
173 * handle on failure. |metadata| is left unchanged on failure.
175 PP_FileHandle (*OpenNaClExecutable)(PP_Instance instance,
176 const char* file_url,
177 uint64_t* file_token_lo,
178 uint64_t* file_token_hi);
179 /* Dispatch a progress event on the DOM element where the given instance is
182 void (*DispatchEvent)(PP_Instance instance,
183 PP_NaClEventType event_type,
184 const char* resource_url,
185 PP_Bool length_is_computable,
186 uint64_t loaded_bytes,
187 uint64_t total_bytes);
188 /* Sets a read-only property on the <embed> DOM element that corresponds to
189 * the given instance.
191 void (*SetReadOnlyProperty)(PP_Instance instance,
193 struct PP_Var value);
196 typedef struct PPB_NaCl_Private_1_0 PPB_NaCl_Private;
201 #endif /* PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ */