diff options
author | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-19 18:43:58 +0000 |
---|---|---|
committer | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-19 18:43:58 +0000 |
commit | 2abe9b2919b04cb8134fd51f2799800538c5764e (patch) | |
tree | a0370a0d106c39d32e572522c67d97139cef79af /ppapi/c | |
parent | 1399697956a48287a3118aefd8ee462c323588e2 (diff) | |
download | chromium_src-2abe9b2919b04cb8134fd51f2799800538c5764e.zip chromium_src-2abe9b2919b04cb8134fd51f2799800538c5764e.tar.gz chromium_src-2abe9b2919b04cb8134fd51f2799800538c5764e.tar.bz2 |
Improve NaCl plugin error reporting when using IPC proxy.
While we're at it, create the IDL for PPB_NaCl_Private.
BUG=160076
TEST=manual
Review URL: https://codereview.chromium.org/11312193
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168557 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/c')
-rw-r--r-- | ppapi/c/private/ppb_nacl_private.h | 171 |
1 files changed, 105 insertions, 66 deletions
diff --git a/ppapi/c/private/ppb_nacl_private.h b/ppapi/c/private/ppb_nacl_private.h index 2e4d563..ccb6af9 100644 --- a/ppapi/c/private/ppb_nacl_private.h +++ b/ppapi/c/private/ppb_nacl_private.h @@ -1,83 +1,122 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. +/* Copyright (c) 2012 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ -#ifndef PPAPI_C_PRIVATE_PPB_NACL_UTIL_PRIVATE_H_ -#define PPAPI_C_PRIVATE_PPB_NACL_UTIL_PRIVATE_H_ +/* From private/ppb_nacl_private.idl modified Fri Nov 16 05:20:17 2012. */ + +#ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ +#define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_macros.h" #include "ppapi/c/pp_stdint.h" -#include "ppapi/c/private/pp_file_handle.h" -#define PPB_NACL_PRIVATE_INTERFACE "PPB_NaCl(Private);0.9" +#define PPB_NACL_PRIVATE_INTERFACE_1_0 "PPB_NaCl_Private;1.0" +#define PPB_NACL_PRIVATE_INTERFACE PPB_NACL_PRIVATE_INTERFACE_1_0 -struct PPB_NaCl_Private { - // This function launches NaCl's sel_ldr process. On success, the function - // returns true, otherwise it returns false. When it returns true, it will - // write |socket_count| nacl::Handles to imc_handles. The |enable_ppapi_dev| - // parameter controls whether GetInterfaces returns 'Dev' interfaces to the - // NaCl plugin. - // - // Unless EnableBackgroundSelLdrLaunch is called, this method must be invoked - // from the main thread. - PP_Bool (*LaunchSelLdr)(PP_Instance instance, - const char* alleged_url, - bool enable_ppapi_dev, - int socket_count, - void* imc_handles); +/** + * @file + * This file contains NaCl private interfaces. */ - // This function starts the IPC proxy so the nexe can communicate with the - // browser. Returns an error code from pp_errors.h. PP_ERROR_NOTSUPPORTED - // signals the plugin to use the SRPC proxy. PP_OK indicates the proxy started - // successfully. Any other error indicates the proxy couldn't be started. - int32_t (*StartPpapiProxy)(PP_Instance instance); - // On POSIX systems, this function returns the file descriptor of - // /dev/urandom. On non-POSIX systems, this function returns 0. - int (*UrandomFD)(void); +#include "ppapi/c/private/pp_file_handle.h" - // Whether the Pepper 3D interfaces should be disabled in the NaCl PPAPI - // proxy. This is so paranoid admins can effectively prevent untrusted shader - // code to be processed by the graphics stack. - bool (*Are3DInterfacesDisabled)(); +/** + * @addtogroup Enums + * @{ + */ +/** + * The <code>PP_NaClResult</code> enum contains NaCl result codes. + */ +typedef enum { + /** Successful NaCl call */ + PP_NACL_OK = 0, + /** Unspecified NaCl error */ + PP_NACL_FAILED = 1, + /** Error creating the module */ + PP_NACL_ERROR_MODULE = 2, + /** Error creating and initializing the instance */ + PP_NACL_ERROR_INSTANCE = 3, + /** SRPC proxy should be used instead */ + PP_NACL_USE_SRPC = 128 +} PP_NaClResult; +PP_COMPILE_ASSERT_SIZE_IN_BYTES(PP_NaClResult, 4); +/** + * @} + */ - // Enables the creation of sel_ldr processes from other than the main thread. +/** + * @addtogroup Interfaces + * @{ + */ +/* PPB_NaCl_Private */ +struct PPB_NaCl_Private_1_0 { + /* Launches NaCl's sel_ldr process. Returns PP_NACL_OK on success and writes + * |socket_count| nacl::Handles to imc_handles. Returns PP_NACL_FAILED on + * failure. The |enable_ppapi_dev| parameter controls whether GetInterface + * returns 'Dev' interfaces to the NaCl plugin. + */ + PP_NaClResult (*LaunchSelLdr)(PP_Instance instance, + const char* alleged_url, + PP_Bool enable_ppapi_dev, + int32_t socket_count, + void* imc_handles); + /* This function starts the IPC proxy so the nexe can communicate with the + * browser. Returns PP_NACL_OK on success, otherwise a result code indicating + * the failure. PP_NACL_FAILED is returned if LaunchSelLdr wasn't called with + * the instance. PP_NACL_ERROR_MODULE is returned if the module can't be + * initialized. PP_NACL_ERROR_INSTANCE is returned if the instance can't be + * initialized. PP_NACL_USE_SRPC is returned if the plugin should use SRPC. + */ + PP_NaClResult (*StartPpapiProxy)(PP_Instance instance); + /* On POSIX systems, this function returns the file descriptor of + * /dev/urandom. On non-POSIX systems, this function returns 0. + */ + int32_t (*UrandomFD)(); + /* Whether the Pepper 3D interfaces should be disabled in the NaCl PPAPI + * proxy. This is so paranoid admins can effectively prevent untrusted shader + * code to be processed by the graphics stack. + */ + PP_Bool (*Are3DInterfacesDisabled)(); + /* Enables the creation of sel_ldr processes off of the main thread. + */ void (*EnableBackgroundSelLdrLaunch)(); - - // This is Windows-specific. This is a replacement for - // DuplicateHandle() for use inside the Windows sandbox. Note that - // we provide this via dependency injection only to avoid the - // linkage problems that occur because the NaCl plugin is built as a - // separate DLL/DSO (see - // http://code.google.com/p/chromium/issues/detail?id=114439#c8). - // We use void* rather than the Windows HANDLE type to avoid an - // #ifdef here. We use int rather than PP_Bool/bool so that this is - // usable with NaClSetBrokerDuplicateHandleFunc() without further - // wrapping. - int (*BrokerDuplicateHandle)(void* source_handle, - uint32_t process_id, - void** target_handle, - uint32_t desired_access, - uint32_t options); - - // Returns a read-only file descriptor of a file rooted in the Pnacl - // component directory, or -1 on error. - // Do we want this to take a completion callback and be async, or - // or could we make this happen on another thread? + /* This is Windows-specific. This is a replacement for DuplicateHandle() for + * use inside the Windows sandbox. Note that we provide this via dependency + * injection only to avoid the linkage problems that occur because the NaCl + * plugin is built as a separate DLL/DSO + * (see http://code.google.com/p/chromium/issues/detail?id=114439#c8). + */ + int32_t (*BrokerDuplicateHandle)(PP_FileHandle source_handle, + uint32_t process_id, + PP_FileHandle* target_handle, + uint32_t desired_access, + uint32_t options); + /* Returns a read-only file descriptor of a file rooted in the Pnacl + * component directory, or -1 on error. + * Do we want this to take a completion callback and be async, or + * could we make this happen on another thread? + */ PP_FileHandle (*GetReadonlyPnaclFd)(const char* filename); - - // This creates a temporary file that will be deleted by the time - // the last handle is closed (or earlier on POSIX systems), and - // returns a posix handle to that temporary file. + /* This creates a temporary file that will be deleted by the time + * the last handle is closed (or earlier on POSIX systems), and + * returns a posix handle to that temporary file. + */ PP_FileHandle (*CreateTemporaryFile)(PP_Instance instance); + /* Return true if we are off the record. + */ + PP_Bool (*IsOffTheRecord)(); + /* Return true if PNaCl is turned on. + */ + PP_Bool (*IsPnaclEnabled)(); +}; - // Return true if we are off the record. - PP_Bool (*IsOffTheRecord)(void); +typedef struct PPB_NaCl_Private_1_0 PPB_NaCl_Private; +/** + * @} + */ - // Return true if PNaCl is turned on. - PP_Bool (*IsPnaclEnabled)(void); -}; +#endif /* PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ */ -#endif // PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ |