Home | History | Annotate | Download | only in private
      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 Fri Nov 29 09:11:40 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 /** Event types that NaCl may use when reporting load progress or errors. */
     45 typedef enum {
     46   PP_NACL_EVENT_LOADSTART,
     47   PP_NACL_EVENT_PROGRESS,
     48   PP_NACL_EVENT_ERROR,
     49   PP_NACL_EVENT_ABORT,
     50   PP_NACL_EVENT_LOAD,
     51   PP_NACL_EVENT_LOADEND,
     52   PP_NACL_EVENT_CRASH
     53 } PP_NaClEventType;
     54 /**
     55  * @}
     56  */
     57 
     58 /**
     59  * @addtogroup Interfaces
     60  * @{
     61  */
     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.
     80    */
     81   PP_ExternalPluginResult (*LaunchSelLdr)(PP_Instance instance,
     82                                           const char* alleged_url,
     83                                           PP_Bool uses_irt,
     84                                           PP_Bool uses_ppapi,
     85                                           PP_Bool enable_ppapi_dev,
     86                                           PP_Bool enable_dyncode_syscalls,
     87                                           PP_Bool enable_exception_handling,
     88                                           PP_Bool enable_crash_throttling,
     89                                           void* imc_handle,
     90                                           struct PP_Var* error_message);
     91   /* This function starts the IPC proxy so the nexe can communicate with the
     92    * browser. Returns PP_EXTERNAL_PLUGIN_OK on success, otherwise a result code
     93    * indicating the failure. PP_EXTERNAL_PLUGIN_FAILED is returned if
     94    * LaunchSelLdr wasn't called with the instance.
     95    * PP_EXTERNAL_PLUGIN_ERROR_MODULE is returned if the module can't be
     96    * initialized. PP_EXTERNAL_PLUGIN_ERROR_INSTANCE is returned if the instance
     97    * can't be initialized.
     98    */
     99   PP_ExternalPluginResult (*StartPpapiProxy)(PP_Instance instance);
    100   /* On POSIX systems, this function returns the file descriptor of
    101    * /dev/urandom.  On non-POSIX systems, this function returns 0.
    102    */
    103   int32_t (*UrandomFD)(void);
    104   /* Whether the Pepper 3D interfaces should be disabled in the NaCl PPAPI
    105    * proxy. This is so paranoid admins can effectively prevent untrusted shader
    106    * code to be processed by the graphics stack.
    107    */
    108   PP_Bool (*Are3DInterfacesDisabled)(void);
    109   /* This is Windows-specific.  This is a replacement for DuplicateHandle() for
    110    * use inside the Windows sandbox.  Note that we provide this via dependency
    111    * injection only to avoid the linkage problems that occur because the NaCl
    112    * plugin is built as a separate DLL/DSO
    113    * (see http://code.google.com/p/chromium/issues/detail?id=114439#c8).
    114    */
    115   int32_t (*BrokerDuplicateHandle)(PP_FileHandle source_handle,
    116                                    uint32_t process_id,
    117                                    PP_FileHandle* target_handle,
    118                                    uint32_t desired_access,
    119                                    uint32_t options);
    120   /* Returns a read-only file descriptor of a file rooted in the Pnacl
    121    * component directory, or an invalid handle on failure.
    122    */
    123   PP_FileHandle (*GetReadonlyPnaclFd)(const char* filename);
    124   /* This creates a temporary file that will be deleted by the time
    125    * the last handle is closed (or earlier on POSIX systems), and
    126    * returns a posix handle to that temporary file.
    127    */
    128   PP_FileHandle (*CreateTemporaryFile)(PP_Instance instance);
    129   /* Create a temporary file, which will be deleted by the time the
    130    * last handle is closed (or earlier on POSIX systems), to use for
    131    * the nexe with the cache information given by |pexe_url|,
    132    * |abi_version|, |opt_level|, |last_modified|, |etag|, and
    133    * |has_no_store_header|. If the nexe is already present in the
    134    * cache, |is_hit| is set to PP_TRUE and the contents of the nexe
    135    * will be copied into the temporary file. Otherwise |is_hit| is set
    136    * to PP_FALSE and the temporary file will be writeable.  Currently
    137    * the implementation is a stub, which always sets is_hit to false
    138    * and calls the implementation of CreateTemporaryFile. In a
    139    * subsequent CL it will call into the browser which will remember
    140    * the association between the cache key and the fd, and copy the
    141    * nexe into the cache after the translation finishes.
    142    */
    143   int32_t (*GetNexeFd)(PP_Instance instance,
    144                        const char* pexe_url,
    145                        uint32_t abi_version,
    146                        uint32_t opt_level,
    147                        const char* last_modified,
    148                        const char* etag,
    149                        PP_Bool has_no_store_header,
    150                        PP_Bool* is_hit,
    151                        PP_FileHandle* nexe_handle,
    152                        struct PP_CompletionCallback callback);
    153   /* Report to the browser that translation of the pexe for |instance|
    154    * has finished, or aborted with an error. If |success| is true, the
    155    * browser may then store the translation in the cache. The renderer
    156    * must first have called GetNexeFd for the same instance. (The browser is
    157    * not guaranteed to store the nexe even if |success| is true; if there is
    158    * an error on the browser side, or the file is too big for the cache, or
    159    * the browser is in incognito mode, no notification will be delivered to
    160    * the plugin.)
    161    */
    162   void (*ReportTranslationFinished)(PP_Instance instance, PP_Bool success);
    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.
    169    */
    170   PP_FileHandle (*OpenNaClExecutable)(PP_Instance instance,
    171                                       const char* file_url,
    172                                       uint64_t* file_token_lo,
    173                                       uint64_t* file_token_hi);
    174   /* Dispatch a progress event on the DOM element where the given instance is
    175    * embedded.
    176    */
    177   void (*DispatchEvent)(PP_Instance instance,
    178                         PP_NaClEventType event_type,
    179                         struct PP_Var resource_url,
    180                         PP_Bool length_is_computable,
    181                         uint64_t loaded_bytes,
    182                         uint64_t total_bytes);
    183   /* Sets a read-only property on the <embed> DOM element that corresponds to
    184    * the given instance.
    185    */
    186   void (*SetReadOnlyProperty)(PP_Instance instance,
    187                               struct PP_Var key,
    188                               struct PP_Var value);
    189 };
    190 
    191 typedef struct PPB_NaCl_Private_1_0 PPB_NaCl_Private;
    192 /**
    193  * @}
    194  */
    195 
    196 #endif  /* PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ */
    197 
    198