OLD | NEW |
| (Empty) |
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. | |
4 */ | |
5 | |
6 /* From private/ppb_nacl_private.idl modified Sun Feb 8 11:33:30 2015. */ | |
7 | |
8 #ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ | |
9 #define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ | |
10 | |
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/ppp_pexe_stream_handler.h" | |
18 | |
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 | |
21 | |
22 /** | |
23 * @file | |
24 * This file contains NaCl private interfaces. This interface is not versioned | |
25 * and is for internal Chrome use. It may change without notice. */ | |
26 | |
27 | |
28 #include "ppapi/c/private/pp_file_handle.h" | |
29 #include "ppapi/c/private/ppb_instance_private.h" | |
30 | |
31 /** | |
32 * @addtogroup Enums | |
33 * @{ | |
34 */ | |
35 /** NaCl-specific errors that should be reported to the user. | |
36 * These error codes are reported via UMA so, if you edit them: | |
37 * 1) make sure you understand UMA first. | |
38 * 2) update src/tools/metrics/histograms/histograms.xml | |
39 * Values are explicitly specified to make sure they don't shift around when | |
40 * edited, and also to make reading about:histograms easier. | |
41 */ | |
42 typedef enum { | |
43 PP_NACL_ERROR_LOAD_SUCCESS = 0, | |
44 PP_NACL_ERROR_LOAD_ABORTED = 1, | |
45 PP_NACL_ERROR_UNKNOWN = 2, | |
46 PP_NACL_ERROR_MANIFEST_RESOLVE_URL = 3, | |
47 PP_NACL_ERROR_MANIFEST_LOAD_URL = 4, | |
48 PP_NACL_ERROR_MANIFEST_STAT = 5, | |
49 PP_NACL_ERROR_MANIFEST_TOO_LARGE = 6, | |
50 PP_NACL_ERROR_MANIFEST_OPEN = 7, | |
51 PP_NACL_ERROR_MANIFEST_MEMORY_ALLOC = 8, | |
52 PP_NACL_ERROR_MANIFEST_READ = 9, | |
53 PP_NACL_ERROR_MANIFEST_PARSING = 10, | |
54 PP_NACL_ERROR_MANIFEST_SCHEMA_VALIDATE = 11, | |
55 PP_NACL_ERROR_MANIFEST_GET_NEXE_URL = 12, | |
56 PP_NACL_ERROR_NEXE_LOAD_URL = 13, | |
57 PP_NACL_ERROR_NEXE_ORIGIN_PROTOCOL = 14, | |
58 PP_NACL_ERROR_NEXE_FH_DUP = 15, | |
59 PP_NACL_ERROR_NEXE_STAT = 16, | |
60 PP_NACL_ERROR_ELF_CHECK_IO = 17, | |
61 PP_NACL_ERROR_ELF_CHECK_FAIL = 18, | |
62 PP_NACL_ERROR_SEL_LDR_INIT = 19, | |
63 PP_NACL_ERROR_SEL_LDR_CREATE_LAUNCHER = 20, | |
64 PP_NACL_ERROR_SEL_LDR_FD = 21, | |
65 PP_NACL_ERROR_SEL_LDR_LAUNCH = 22, | |
66 /* Deprecated, safe to reuse the value because it's never logged in UMA. | |
67 */ | |
68 PP_NACL_ERROR_SEL_LDR_SEND_NEXE = 24, | |
69 PP_NACL_ERROR_SEL_LDR_HANDLE_PASSING = 25, | |
70 PP_NACL_ERROR_SEL_LDR_START_MODULE = 26, | |
71 PP_NACL_ERROR_SEL_LDR_START_STATUS = 27, | |
72 PP_NACL_ERROR_SRPC_CONNECTION_FAIL = 28, | |
73 PP_NACL_ERROR_START_PROXY_CHECK_PPP = 29, | |
74 PP_NACL_ERROR_START_PROXY_ALLOC = 30, | |
75 PP_NACL_ERROR_START_PROXY_MODULE = 31, | |
76 PP_NACL_ERROR_START_PROXY_INSTANCE = 32, | |
77 PP_NACL_ERROR_SEL_LDR_COMMUNICATION_CMD_CHANNEL = 33, | |
78 PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SETUP = 34, | |
79 PP_NACL_ERROR_SEL_LDR_COMMUNICATION_WRAPPER = 35, | |
80 PP_NACL_ERROR_SEL_LDR_COMMUNICATION_REV_SERVICE = 36, | |
81 PP_NACL_ERROR_START_PROXY_CRASH = 37, | |
82 PP_NACL_ERROR_MANIFEST_PROGRAM_MISSING_ARCH = 38, | |
83 PP_NACL_ERROR_PNACL_CACHE_OPEN_INPROGRESS = 39, | |
84 PP_NACL_ERROR_PNACL_CACHE_OPEN_NOACCESS = 40, | |
85 PP_NACL_ERROR_PNACL_CACHE_OPEN_NOQUOTA = 41, | |
86 PP_NACL_ERROR_PNACL_CACHE_OPEN_NOSPACE = 42, | |
87 PP_NACL_ERROR_PNACL_CACHE_OPEN_OTHER = 43, | |
88 PP_NACL_ERROR_PNACL_CACHE_DIRECTORY_CREATE = 44, | |
89 PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOACCESS = 45, | |
90 PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOQUOTA = 46, | |
91 PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOSPACE = 47, | |
92 PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_NOTAFILE = 48, | |
93 PP_NACL_ERROR_PNACL_CACHE_FILEOPEN_OTHER = 49, | |
94 PP_NACL_ERROR_PNACL_CACHE_FETCH_NOACCESS = 50, | |
95 PP_NACL_ERROR_PNACL_CACHE_FETCH_NOTFOUND = 51, | |
96 PP_NACL_ERROR_PNACL_CACHE_FETCH_OTHER = 52, | |
97 PP_NACL_ERROR_PNACL_CACHE_FINALIZE_COPY_NOQUOTA = 53, | |
98 PP_NACL_ERROR_PNACL_CACHE_FINALIZE_COPY_NOSPACE = 54, | |
99 PP_NACL_ERROR_PNACL_CACHE_FINALIZE_COPY_OTHER = 55, | |
100 PP_NACL_ERROR_PNACL_CACHE_FINALIZE_RENAME_NOACCESS = 56, | |
101 PP_NACL_ERROR_PNACL_CACHE_FINALIZE_RENAME_OTHER = 57, | |
102 PP_NACL_ERROR_PNACL_RESOURCE_FETCH = 58, | |
103 PP_NACL_ERROR_PNACL_PEXE_FETCH_ABORTED = 59, | |
104 PP_NACL_ERROR_PNACL_PEXE_FETCH_NOACCESS = 60, | |
105 PP_NACL_ERROR_PNACL_PEXE_FETCH_OTHER = 61, | |
106 PP_NACL_ERROR_PNACL_THREAD_CREATE = 62, | |
107 PP_NACL_ERROR_PNACL_LLC_SETUP = 63, | |
108 PP_NACL_ERROR_PNACL_LD_SETUP = 64, | |
109 PP_NACL_ERROR_PNACL_LLC_INTERNAL = 65, | |
110 PP_NACL_ERROR_PNACL_LD_INTERNAL = 66, | |
111 PP_NACL_ERROR_PNACL_CREATE_TEMP = 67, | |
112 /* This entry is no longer used, but should not be removed, because UMA | |
113 */ | |
114 PP_NACL_ERROR_PNACL_NOT_ENABLED = 68, | |
115 PP_NACL_ERROR_MANIFEST_NOACCESS_URL = 69, | |
116 PP_NACL_ERROR_NEXE_NOACCESS_URL = 70, | |
117 PP_NACL_ERROR_PNACL_CRASH_THROTTLED = 71, | |
118 /* If you add a code, read the enum comment above on how to update | |
119 */ | |
120 PP_NACL_ERROR_MAX | |
121 } PP_NaClError; | |
122 | |
123 /** Event types that NaCl may use when reporting load progress or errors. */ | |
124 typedef enum { | |
125 PP_NACL_EVENT_LOADSTART, | |
126 PP_NACL_EVENT_PROGRESS, | |
127 PP_NACL_EVENT_ERROR, | |
128 PP_NACL_EVENT_ABORT, | |
129 PP_NACL_EVENT_LOAD, | |
130 PP_NACL_EVENT_LOADEND, | |
131 PP_NACL_EVENT_CRASH | |
132 } PP_NaClEventType; | |
133 | |
134 typedef enum { | |
135 PP_SCHEME_CHROME_EXTENSION, | |
136 PP_SCHEME_DATA, | |
137 PP_SCHEME_OTHER | |
138 } PP_UrlSchemeType; | |
139 | |
140 typedef enum { | |
141 /* The trusted plugin begins in this ready state. */ | |
142 PP_NACL_READY_STATE_UNSENT = 0, | |
143 /* The manifest file has been requested, but not yet received. */ | |
144 PP_NACL_READY_STATE_OPENED = 1, | |
145 /* The manifest file has been received and the nexe successfully requested. */ | |
146 PP_NACL_READY_STATE_LOADING = 3, | |
147 /* The nexe has been loaded and the proxy started, so it is ready for | |
148 */ | |
149 PP_NACL_READY_STATE_DONE = 4 | |
150 } PP_NaClReadyState; | |
151 | |
152 /** Types of untrusted NaCl processes. Mirrors NaClAppProcessType from | |
153 * components/nacl/common/nacl_types.h. | |
154 */ | |
155 typedef enum { | |
156 PP_UNKNOWN_NACL_PROCESS_TYPE, | |
157 PP_NATIVE_NACL_PROCESS_TYPE, | |
158 PP_PNACL_PROCESS_TYPE, | |
159 PP_PNACL_TRANSLATOR_PROCESS_TYPE, | |
160 PP_NUM_NACL_PROCESS_TYPES | |
161 } PP_NaClAppProcessType; | |
162 /** | |
163 * @} | |
164 */ | |
165 | |
166 /** | |
167 * @addtogroup Structs | |
168 * @{ | |
169 */ | |
170 struct PP_PNaClOptions { | |
171 PP_Bool translate; | |
172 PP_Bool is_debug; | |
173 int32_t opt_level; | |
174 }; | |
175 /** | |
176 * @} | |
177 */ | |
178 | |
179 /** | |
180 * @addtogroup Typedefs | |
181 * @{ | |
182 */ | |
183 /* Callback invoked upon completion of PPP_ManifestService::OpenResource(). */ | |
184 typedef void (*PP_OpenResourceCompletionCallback)(void* user_data, | |
185 PP_FileHandle file_handle); | |
186 /** | |
187 * @} | |
188 */ | |
189 | |
190 /** | |
191 * @addtogroup Structs | |
192 * @{ | |
193 */ | |
194 struct PP_NaClFileInfo { | |
195 PP_FileHandle handle; | |
196 /* See NaClFileToken comment in nacl_process_host.h */ | |
197 uint64_t token_lo; | |
198 uint64_t token_hi; | |
199 }; | |
200 /** | |
201 * @} | |
202 */ | |
203 | |
204 /** | |
205 * @addtogroup Interfaces | |
206 * @{ | |
207 */ | |
208 /* PPB_NaCl_Private */ | |
209 struct PPB_NaCl_Private_1_0 { | |
210 /* Launches NaCl's sel_ldr process. Returns PP_EXTERNAL_PLUGIN_OK on success | |
211 * and writes a NaClHandle to imc_handle. Returns PP_EXTERNAL_PLUGIN_FAILED on | |
212 * failure. | |
213 * The |nexe_file_info| is currently used only in non-SFI mode. It is the | |
214 * file handle for the main nexe file, which should be initially loaded. | |
215 * LaunchSelLdr takes the ownership of the file handle. | |
216 * The |uses_nonsfi_mode| flag indicates whether or not nonsfi-mode should | |
217 * be used with the binary pointed by the url. | |
218 */ | |
219 void (*LaunchSelLdr)(PP_Instance instance, | |
220 PP_Bool main_service_runtime, | |
221 const char* alleged_url, | |
222 const struct PP_NaClFileInfo* nexe_file_info, | |
223 PP_Bool uses_nonsfi_mode, | |
224 PP_NaClAppProcessType process_type, | |
225 void* imc_handle, | |
226 struct PP_CompletionCallback callback); | |
227 /* On POSIX systems, this function returns the file descriptor of | |
228 * /dev/urandom. On non-POSIX systems, this function returns 0. | |
229 */ | |
230 int32_t (*UrandomFD)(void); | |
231 /* This is Windows-specific. This is a replacement for DuplicateHandle() for | |
232 * use inside the Windows sandbox. Note that we provide this via dependency | |
233 * injection only to avoid the linkage problems that occur because the NaCl | |
234 * plugin is built as a separate DLL/DSO | |
235 * (see http://code.google.com/p/chromium/issues/detail?id=114439#c8). | |
236 */ | |
237 int32_t (*BrokerDuplicateHandle)(PP_FileHandle source_handle, | |
238 uint32_t process_id, | |
239 PP_FileHandle* target_handle, | |
240 uint32_t desired_access, | |
241 uint32_t options); | |
242 /* Returns a read-only (but executable) file descriptor / file info for | |
243 * a url for pnacl translator tools. Returns an invalid handle on failure. | |
244 */ | |
245 void (*GetReadExecPnaclFd)(const char* url, | |
246 struct PP_NaClFileInfo* out_file_info); | |
247 /* This creates a temporary file that will be deleted by the time | |
248 * the last handle is closed (or earlier on POSIX systems), and | |
249 * returns a posix handle to that temporary file. | |
250 */ | |
251 PP_FileHandle (*CreateTemporaryFile)(PP_Instance instance); | |
252 /* Return the number of processors in the system as reported by the OS */ | |
253 int32_t (*GetNumberOfProcessors)(void); | |
254 /* Report to the browser that translation of the pexe for |instance| | |
255 * has finished, or aborted with an error. If |success| is true, the | |
256 * browser may then store the translation in the cache. The renderer | |
257 * must first have called GetNexeFd for the same instance. (The browser is | |
258 * not guaranteed to store the nexe even if |success| is true; if there is | |
259 * an error on the browser side, or the file is too big for the cache, or | |
260 * the browser is in incognito mode, no notification will be delivered to | |
261 * the plugin.) | |
262 */ | |
263 void (*ReportTranslationFinished)(PP_Instance instance, | |
264 PP_Bool success, | |
265 int32_t opt_level, | |
266 int64_t pexe_size, | |
267 int64_t compile_time_us); | |
268 /* Dispatch a progress event on the DOM element where the given instance is | |
269 * embedded. | |
270 */ | |
271 void (*DispatchEvent)(PP_Instance instance, | |
272 PP_NaClEventType event_type, | |
273 const char* resource_url, | |
274 PP_Bool length_is_computable, | |
275 uint64_t loaded_bytes, | |
276 uint64_t total_bytes); | |
277 /* Report an error that occured while attempting to load a nexe. */ | |
278 void (*ReportLoadError)(PP_Instance instance, | |
279 PP_NaClError error, | |
280 const char* error_message); | |
281 /* Performs internal setup when an instance is created. */ | |
282 void (*InstanceCreated)(PP_Instance instance); | |
283 /* Performs internal cleanup when an instance is destroyed. */ | |
284 void (*InstanceDestroyed)(PP_Instance instance); | |
285 /* Returns the kind of SFI sandbox implemented by NaCl on this | |
286 * platform. | |
287 */ | |
288 const char* (*GetSandboxArch)(void); | |
289 /* Logs the message via VLOG. */ | |
290 void (*Vlog)(const char* message); | |
291 /* Initializes internal state for a NaCl plugin. */ | |
292 void (*InitializePlugin)(PP_Instance instance, | |
293 uint32_t argc, | |
294 const char* argn[], | |
295 const char* argv[]); | |
296 /* Requests the NaCl manifest specified in the plugin arguments. */ | |
297 void (*RequestNaClManifest)(PP_Instance instance, | |
298 struct PP_CompletionCallback callback); | |
299 struct PP_Var (*GetManifestBaseURL)(PP_Instance instance); | |
300 /* Processes the NaCl manifest once it's been retrieved. | |
301 * TODO(teravest): Move the rest of the supporting logic out of the trusted | |
302 * plugin. | |
303 */ | |
304 void (*ProcessNaClManifest)(PP_Instance instance, const char* program_url); | |
305 PP_Bool (*GetManifestProgramURL)(PP_Instance instance, | |
306 struct PP_Var* full_url, | |
307 struct PP_PNaClOptions* pnacl_options, | |
308 PP_Bool* uses_nonsfi_mode); | |
309 /* Returns the filenames for the llc and ld tools. */ | |
310 PP_Bool (*GetPnaclResourceInfo)(PP_Instance instance, | |
311 struct PP_Var* llc_tool_name, | |
312 struct PP_Var* ld_tool_name); | |
313 /* PP_Var string of attributes describing the CPU features supported | |
314 * by the current architecture. The string is a comma-delimited list | |
315 * of attributes supported by LLVM in its -mattr= option: | |
316 * http://llvm.org/docs/CommandGuide/llc.html#cmdoption-mattr */ | |
317 struct PP_Var (*GetCpuFeatureAttrs)(void); | |
318 /* Downloads the .nexe file at the given URL to a file, and sets |file_info| | |
319 * to information for a handle to a file containing its contents. | |
320 * If metadata for identity-based validation caching is available | |
321 * then it sets token information in |file_info| (otherwise left untouched). | |
322 */ | |
323 void (*DownloadNexe)(PP_Instance instance, | |
324 const char* url, | |
325 struct PP_NaClFileInfo* file_info, | |
326 struct PP_CompletionCallback callback); | |
327 /* Reports the status of sel_ldr for UMA reporting. | |
328 * |max_status| has to be provided because the implementation of this | |
329 * interface can't access the NaClErrorCode enum. | |
330 */ | |
331 void (*ReportSelLdrStatus)(PP_Instance instance, | |
332 int32_t load_status, | |
333 int32_t max_status); | |
334 /* Logs time taken by an operation to UMA histograms. | |
335 * This function is safe to call on any thread. | |
336 */ | |
337 void (*LogTranslateTime)(const char* histogram_name, int64_t time_us); | |
338 /* Sets the start time for PNaCl downloading and translation to the current | |
339 * time. | |
340 */ | |
341 void (*SetPNaClStartTime)(PP_Instance instance); | |
342 /* Downloads and streams a pexe file for PNaCl translation. | |
343 * Fetches the content at |pexe_url| for the given instance and opt_level. | |
344 * If a translated cached nexe is already available, |cache_hit_handle| | |
345 * is set and |cache_hit_callback| is called. | |
346 * Otherwise, |stream_callback| is called repeatedly with blocks of data | |
347 * as they are received. |stream_finished_callback| is called after all | |
348 * data has been received and dispatched to |stream_callback|. | |
349 */ | |
350 void (*StreamPexe)(PP_Instance instance, | |
351 const char* pexe_url, | |
352 int32_t opt_level, | |
353 const struct PPP_PexeStreamHandler_1_0* stream_handler, | |
354 void* stream_handler_user_data); | |
355 }; | |
356 | |
357 typedef struct PPB_NaCl_Private_1_0 PPB_NaCl_Private; | |
358 /** | |
359 * @} | |
360 */ | |
361 | |
362 #endif /* PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ */ | |
363 | |
OLD | NEW |