- add sources.
[platform/framework/web/crosswalk.git] / src / ppapi / c / private / ppb_nacl_private.h
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 Thu Oct 31 15:10:06 2013. */
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/ppb_instance_private.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 typedef enum {
37   /**
38    *  The manifest program element does not contain a program usable on the
39    *  user's architecture
40    */
41   PP_NACL_MANIFEST_MISSING_ARCH = 0
42 } PP_NaClError;
43 /**
44  * @}
45  */
46
47 /**
48  * @addtogroup Interfaces
49  * @{
50  */
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.
69    */
70   PP_ExternalPluginResult (*LaunchSelLdr)(PP_Instance instance,
71                                           const char* alleged_url,
72                                           PP_Bool uses_irt,
73                                           PP_Bool uses_ppapi,
74                                           PP_Bool enable_ppapi_dev,
75                                           PP_Bool enable_dyncode_syscalls,
76                                           PP_Bool enable_exception_handling,
77                                           PP_Bool enable_crash_throttling,
78                                           void* imc_handle,
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.
87    */
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.
91    */
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.
96    */
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).
103    */
104   int32_t (*BrokerDuplicateHandle)(PP_FileHandle source_handle,
105                                    uint32_t process_id,
106                                    PP_FileHandle* target_handle,
107                                    uint32_t desired_access,
108                                    uint32_t options);
109   /* Returns a read-only file descriptor of a file rooted in the Pnacl
110    * component directory, or an invalid handle on failure.
111    */
112   PP_FileHandle (*GetReadonlyPnaclFd)(const char* filename);
113   /* This creates a temporary file that will be deleted by the time
114    * the last handle is closed (or earlier on POSIX systems), and
115    * returns a posix handle to that temporary file.
116    */
117   PP_FileHandle (*CreateTemporaryFile)(PP_Instance instance);
118   /* Create a temporary file, which will be deleted by the time the
119    * last handle is closed (or earlier on POSIX systems), to use for
120    * the nexe with the cache information given by |pexe_url|,
121    * |abi_version|, |opt_level|, |last_modified|, |etag|, and
122    * |has_no_store_header|. If the nexe is already present in the
123    * cache, |is_hit| is set to PP_TRUE and the contents of the nexe
124    * will be copied into the temporary file. Otherwise |is_hit| is set
125    * to PP_FALSE and the temporary file will be writeable.  Currently
126    * the implementation is a stub, which always sets is_hit to false
127    * and calls the implementation of CreateTemporaryFile. In a
128    * subsequent CL it will call into the browser which will remember
129    * the association between the cache key and the fd, and copy the
130    * nexe into the cache after the translation finishes.
131    */
132   int32_t (*GetNexeFd)(PP_Instance instance,
133                        const char* pexe_url,
134                        uint32_t abi_version,
135                        uint32_t opt_level,
136                        const char* last_modified,
137                        const char* etag,
138                        PP_Bool has_no_store_header,
139                        PP_Bool* is_hit,
140                        PP_FileHandle* nexe_handle,
141                        struct PP_CompletionCallback callback);
142   /* Report to the browser that translation of the pexe for |instance|
143    * has finished, or aborted with an error. If |success| is true, the
144    * browser may then store the translation in the cache. The renderer
145    * must first have called GetNexeFd for the same instance. (The browser is
146    * not guaranteed to store the nexe even if |success| is true; if there is
147    * an error on the browser side, or the file is too big for the cache, or
148    * the browser is in incognito mode, no notification will be delivered to
149    * the plugin.)
150    */
151   void (*ReportTranslationFinished)(PP_Instance instance, PP_Bool success);
152   /* Return true if we are off the record.
153    */
154   PP_Bool (*IsOffTheRecord)(void);
155   /* Display a UI message to the user. */
156   PP_ExternalPluginResult (*ReportNaClError)(PP_Instance instance,
157                                              PP_NaClError message_id);
158   /* Opens a NaCl executable file in the application's extension directory
159    * corresponding to the file URL and returns a file descriptor, or an invalid
160    * handle on failure. |metadata| is left unchanged on failure.
161    */
162   PP_FileHandle (*OpenNaClExecutable)(PP_Instance instance,
163                                       const char* file_url,
164                                       uint64_t* file_token_lo,
165                                       uint64_t* file_token_hi);
166 };
167
168 typedef struct PPB_NaCl_Private_1_0 PPB_NaCl_Private;
169 /**
170  * @}
171  */
172
173 #endif  /* PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ */
174