| 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 /* 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 struct PP_NaClFileInfo { | |
| 158 PP_FileHandle handle; | |
| 159 | |
| 160 /* See NaClFileToken comment in nacl_process_host.h */ | |
| 161 uint64_t token_lo; | |
| 162 uint64_t token_hi; | |
| 163 }; | |
| 164 | |
| 165 /* PPB_NaCl_Private */ | |
| 166 interface PPB_NaCl_Private { | |
| 167 /* Launches NaCl's sel_ldr process. Returns PP_EXTERNAL_PLUGIN_OK on success | |
| 168 * and writes a NaClHandle to imc_handle. Returns PP_EXTERNAL_PLUGIN_FAILED on | |
| 169 * failure. | |
| 170 * The |nexe_file_info| is currently used only in non-SFI mode. It is the | |
| 171 * file handle for the main nexe file, which should be initially loaded. | |
| 172 * LaunchSelLdr takes the ownership of the file handle. | |
| 173 * The |uses_nonsfi_mode| flag indicates whether or not nonsfi-mode should | |
| 174 * be used with the binary pointed by the url. | |
| 175 */ | |
| 176 void LaunchSelLdr([in] PP_Instance instance, | |
| 177 [in] PP_Bool main_service_runtime, | |
| 178 [in] str_t alleged_url, | |
| 179 [in] PP_NaClFileInfo nexe_file_info, | |
| 180 [in] PP_Bool uses_nonsfi_mode, | |
| 181 [in] PP_NaClAppProcessType process_type, | |
| 182 [out] mem_t imc_handle, | |
| 183 [in] PP_CompletionCallback callback); | |
| 184 | |
| 185 /* On POSIX systems, this function returns the file descriptor of | |
| 186 * /dev/urandom. On non-POSIX systems, this function returns 0. | |
| 187 */ | |
| 188 int32_t UrandomFD(); | |
| 189 | |
| 190 /* This is Windows-specific. This is a replacement for DuplicateHandle() for | |
| 191 * use inside the Windows sandbox. Note that we provide this via dependency | |
| 192 * injection only to avoid the linkage problems that occur because the NaCl | |
| 193 * plugin is built as a separate DLL/DSO | |
| 194 * (see http://code.google.com/p/chromium/issues/detail?id=114439#c8). | |
| 195 */ | |
| 196 int32_t BrokerDuplicateHandle([in] PP_FileHandle source_handle, | |
| 197 [in] uint32_t process_id, | |
| 198 [out] PP_FileHandle target_handle, | |
| 199 [in] uint32_t desired_access, | |
| 200 [in] uint32_t options); | |
| 201 | |
| 202 /* Returns a read-only (but executable) file descriptor / file info for | |
| 203 * a url for pnacl translator tools. Returns an invalid handle on failure. | |
| 204 */ | |
| 205 void GetReadExecPnaclFd([in] str_t url, | |
| 206 [out] PP_NaClFileInfo out_file_info); | |
| 207 | |
| 208 /* This creates a temporary file that will be deleted by the time | |
| 209 * the last handle is closed (or earlier on POSIX systems), and | |
| 210 * returns a posix handle to that temporary file. | |
| 211 */ | |
| 212 PP_FileHandle CreateTemporaryFile([in] PP_Instance instance); | |
| 213 | |
| 214 /* Return the number of processors in the system as reported by the OS */ | |
| 215 int32_t GetNumberOfProcessors(); | |
| 216 | |
| 217 /* Report to the browser that translation of the pexe for |instance| | |
| 218 * has finished, or aborted with an error. If |success| is true, the | |
| 219 * browser may then store the translation in the cache. The renderer | |
| 220 * must first have called GetNexeFd for the same instance. (The browser is | |
| 221 * not guaranteed to store the nexe even if |success| is true; if there is | |
| 222 * an error on the browser side, or the file is too big for the cache, or | |
| 223 * the browser is in incognito mode, no notification will be delivered to | |
| 224 * the plugin.) | |
| 225 */ | |
| 226 void ReportTranslationFinished([in] PP_Instance instance, | |
| 227 [in] PP_Bool success, | |
| 228 [in] int32_t opt_level, | |
| 229 [in] int64_t pexe_size, | |
| 230 [in] int64_t compile_time_us); | |
| 231 | |
| 232 /* Dispatch a progress event on the DOM element where the given instance is | |
| 233 * embedded. | |
| 234 */ | |
| 235 void DispatchEvent([in] PP_Instance instance, | |
| 236 [in] PP_NaClEventType event_type, | |
| 237 [in] str_t resource_url, | |
| 238 [in] PP_Bool length_is_computable, | |
| 239 [in] uint64_t loaded_bytes, | |
| 240 [in] uint64_t total_bytes); | |
| 241 | |
| 242 /* Report an error that occured while attempting to load a nexe. */ | |
| 243 void ReportLoadError([in] PP_Instance instance, | |
| 244 [in] PP_NaClError error, | |
| 245 [in] str_t error_message); | |
| 246 | |
| 247 /* Performs internal setup when an instance is created. */ | |
| 248 void InstanceCreated([in] PP_Instance instance); | |
| 249 | |
| 250 /* Performs internal cleanup when an instance is destroyed. */ | |
| 251 void InstanceDestroyed([in] PP_Instance instance); | |
| 252 | |
| 253 /* Returns the kind of SFI sandbox implemented by NaCl on this | |
| 254 * platform. | |
| 255 */ | |
| 256 str_t GetSandboxArch(); | |
| 257 | |
| 258 /* Logs the message via VLOG. */ | |
| 259 void Vlog([in] str_t message); | |
| 260 | |
| 261 /* Initializes internal state for a NaCl plugin. */ | |
| 262 void InitializePlugin([in] PP_Instance instance, | |
| 263 [in] uint32_t argc, | |
| 264 [in, size_as=argc] str_t[] argn, | |
| 265 [in, size_as=argv] str_t[] argv); | |
| 266 | |
| 267 /* Requests the NaCl manifest specified in the plugin arguments. */ | |
| 268 void RequestNaClManifest([in] PP_Instance instance, | |
| 269 [in] PP_CompletionCallback callback); | |
| 270 | |
| 271 PP_Var GetManifestBaseURL([in] PP_Instance instance); | |
| 272 | |
| 273 /* Processes the NaCl manifest once it's been retrieved. | |
| 274 * TODO(teravest): Move the rest of the supporting logic out of the trusted | |
| 275 * plugin. | |
| 276 */ | |
| 277 void ProcessNaClManifest([in] PP_Instance instance, | |
| 278 [in] str_t program_url); | |
| 279 | |
| 280 PP_Bool GetManifestProgramURL([in] PP_Instance instance, | |
| 281 [out] PP_Var full_url, | |
| 282 [out] PP_PNaClOptions pnacl_options, | |
| 283 [out] PP_Bool uses_nonsfi_mode); | |
| 284 | |
| 285 /* Returns the filenames for the llc and ld tools. */ | |
| 286 PP_Bool GetPnaclResourceInfo([in] PP_Instance instance, | |
| 287 [out] PP_Var llc_tool_name, | |
| 288 [out] PP_Var ld_tool_name); | |
| 289 | |
| 290 // PP_Var string of attributes describing the CPU features supported | |
| 291 // by the current architecture. The string is a comma-delimited list | |
| 292 // of attributes supported by LLVM in its -mattr= option: | |
| 293 // http://llvm.org/docs/CommandGuide/llc.html#cmdoption-mattr | |
| 294 PP_Var GetCpuFeatureAttrs(); | |
| 295 | |
| 296 /* Downloads the .nexe file at the given URL to a file, and sets |file_info| | |
| 297 * to information for a handle to a file containing its contents. | |
| 298 * If metadata for identity-based validation caching is available | |
| 299 * then it sets token information in |file_info| (otherwise left untouched). | |
| 300 */ | |
| 301 void DownloadNexe([in] PP_Instance instance, | |
| 302 [in] str_t url, | |
| 303 [out] PP_NaClFileInfo file_info, | |
| 304 [in] PP_CompletionCallback callback); | |
| 305 | |
| 306 /* Reports the status of sel_ldr for UMA reporting. | |
| 307 * |max_status| has to be provided because the implementation of this | |
| 308 * interface can't access the NaClErrorCode enum. | |
| 309 */ | |
| 310 void ReportSelLdrStatus([in] PP_Instance instance, | |
| 311 [in] int32_t load_status, | |
| 312 [in] int32_t max_status); | |
| 313 | |
| 314 /* Logs time taken by an operation to UMA histograms. | |
| 315 * This function is safe to call on any thread. | |
| 316 */ | |
| 317 void LogTranslateTime([in] str_t histogram_name, | |
| 318 [in] int64_t time_us); | |
| 319 | |
| 320 /* Sets the start time for PNaCl downloading and translation to the current | |
| 321 * time. | |
| 322 */ | |
| 323 void SetPNaClStartTime([in] PP_Instance instance); | |
| 324 | |
| 325 /* Downloads and streams a pexe file for PNaCl translation. | |
| 326 * Fetches the content at |pexe_url| for the given instance and opt_level. | |
| 327 * If a translated cached nexe is already available, |cache_hit_handle| | |
| 328 * is set and |cache_hit_callback| is called. | |
| 329 * Otherwise, |stream_callback| is called repeatedly with blocks of data | |
| 330 * as they are received. |stream_finished_callback| is called after all | |
| 331 * data has been received and dispatched to |stream_callback|. | |
| 332 */ | |
| 333 void StreamPexe([in] PP_Instance instance, | |
| 334 [in] str_t pexe_url, | |
| 335 [in] int32_t opt_level, | |
| 336 [in] PPP_PexeStreamHandler stream_handler, | |
| 337 [inout] mem_t stream_handler_user_data); | |
| 338 }; | |
| OLD | NEW |