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