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 /* This file contains NaCl private interfaces. This interface is not versioned
7 * and is for internal Chrome use. It may change without notice. */
14 #include "ppapi/c/private/pp_file_handle.h"
15 #include "ppapi/c/private/ppb_instance_private.h"
18 /** NaCl-specific errors that should be reported to the user */
21 * The manifest program element does not contain a program usable on the
24 PP_NACL_MANIFEST_MISSING_ARCH = 0
27 /* PPB_NaCl_Private */
28 interface PPB_NaCl_Private {
29 /* Launches NaCl's sel_ldr process. Returns PP_EXTERNAL_PLUGIN_OK on success
30 * and writes a NaClHandle to imc_handle. Returns PP_EXTERNAL_PLUGIN_FAILED on
31 * failure. The |enable_ppapi_dev| parameter controls whether GetInterface
32 * returns 'Dev' interfaces to the NaCl plugin. The |uses_ppapi| flag
33 * indicates that the nexe run by sel_ldr will use the PPAPI APIs.
34 * This implies that LaunchSelLdr is run from the main thread. If a nexe
35 * does not need PPAPI, then it can run off the main thread.
36 * The |uses_irt| flag indicates whether the IRT should be loaded in this
37 * NaCl process. This is true for ABI stable nexes.
38 * The |enable_dyncode_syscalls| flag indicates whether or not the nexe
39 * will be able to use dynamic code system calls (e.g., mmap with PROT_EXEC).
40 * The |enable_exception_handling| flag indicates whether or not the nexe
41 * will be able to use hardware exception handling.
42 * The |enable_crash_throttling| flag indicates whether or not crashes of
43 * the nexe contribute to crash throttling statisics and whether nexe starts
44 * are throttled by crash throttling.
46 PP_ExternalPluginResult LaunchSelLdr([in] PP_Instance instance,
47 [in] str_t alleged_url,
48 [in] PP_Bool uses_irt,
49 [in] PP_Bool uses_ppapi,
50 [in] PP_Bool enable_ppapi_dev,
51 [in] PP_Bool enable_dyncode_syscalls,
52 [in] PP_Bool enable_exception_handling,
53 [in] PP_Bool enable_crash_throttling,
54 [out] mem_t imc_handle,
55 [out] PP_Var error_message);
57 /* This function starts the IPC proxy so the nexe can communicate with the
58 * browser. Returns PP_EXTERNAL_PLUGIN_OK on success, otherwise a result code
59 * indicating the failure. PP_EXTERNAL_PLUGIN_FAILED is returned if
60 * LaunchSelLdr wasn't called with the instance.
61 * PP_EXTERNAL_PLUGIN_ERROR_MODULE is returned if the module can't be
62 * initialized. PP_EXTERNAL_PLUGIN_ERROR_INSTANCE is returned if the instance
63 * can't be initialized.
65 PP_ExternalPluginResult StartPpapiProxy(PP_Instance instance);
67 /* On POSIX systems, this function returns the file descriptor of
68 * /dev/urandom. On non-POSIX systems, this function returns 0.
72 /* Whether the Pepper 3D interfaces should be disabled in the NaCl PPAPI
73 * proxy. This is so paranoid admins can effectively prevent untrusted shader
74 * code to be processed by the graphics stack.
76 PP_Bool Are3DInterfacesDisabled();
78 /* This is Windows-specific. This is a replacement for DuplicateHandle() for
79 * use inside the Windows sandbox. Note that we provide this via dependency
80 * injection only to avoid the linkage problems that occur because the NaCl
81 * plugin is built as a separate DLL/DSO
82 * (see http://code.google.com/p/chromium/issues/detail?id=114439#c8).
84 int32_t BrokerDuplicateHandle([in] PP_FileHandle source_handle,
85 [in] uint32_t process_id,
86 [out] PP_FileHandle target_handle,
87 [in] uint32_t desired_access,
88 [in] uint32_t options);
90 /* Returns a read-only file descriptor of a file rooted in the Pnacl
91 * component directory, or an invalid handle on failure.
93 PP_FileHandle GetReadonlyPnaclFd([in] str_t filename);
95 /* This creates a temporary file that will be deleted by the time
96 * the last handle is closed (or earlier on POSIX systems), and
97 * returns a posix handle to that temporary file.
99 PP_FileHandle CreateTemporaryFile([in] PP_Instance instance);
101 /* Create a temporary file, which will be deleted by the time the
102 * last handle is closed (or earlier on POSIX systems), to use for
103 * the nexe with the cache information given by |pexe_url|,
104 * |abi_version|, |opt_level|, |last_modified|, |etag|, and
105 * |has_no_store_header|. If the nexe is already present in the
106 * cache, |is_hit| is set to PP_TRUE and the contents of the nexe
107 * will be copied into the temporary file. Otherwise |is_hit| is set
108 * to PP_FALSE and the temporary file will be writeable. Currently
109 * the implementation is a stub, which always sets is_hit to false
110 * and calls the implementation of CreateTemporaryFile. In a
111 * subsequent CL it will call into the browser which will remember
112 * the association between the cache key and the fd, and copy the
113 * nexe into the cache after the translation finishes.
115 int32_t GetNexeFd([in] PP_Instance instance,
117 [in] uint32_t abi_version,
118 [in] uint32_t opt_level,
119 [in] str_t last_modified,
121 [in] PP_Bool has_no_store_header,
122 [out] PP_Bool is_hit,
123 [out] PP_FileHandle nexe_handle,
124 [in] PP_CompletionCallback callback);
126 /* Report to the browser that translation of the pexe for |instance|
127 * has finished, or aborted with an error. If |success| is true, the
128 * browser may then store the translation in the cache. The renderer
129 * must first have called GetNexeFd for the same instance. (The browser is
130 * not guaranteed to store the nexe even if |success| is true; if there is
131 * an error on the browser side, or the file is too big for the cache, or
132 * the browser is in incognito mode, no notification will be delivered to
135 void ReportTranslationFinished([in] PP_Instance instance,
136 [in] PP_Bool success);
138 /* Return true if we are off the record.
140 PP_Bool IsOffTheRecord();
142 /* Display a UI message to the user. */
143 PP_ExternalPluginResult ReportNaClError([in] PP_Instance instance,
144 [in] PP_NaClError message_id);
146 /* Opens a NaCl executable file in the application's extension directory
147 * corresponding to the file URL and returns a file descriptor, or an invalid
148 * handle on failure. |metadata| is left unchanged on failure.
150 PP_FileHandle OpenNaClExecutable([in] PP_Instance instance,
152 [out] uint64_t file_token_lo,
153 [out] uint64_t file_token_hi);