Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / components / nacl / common / nacl_types.h
index 747c9ac..490ec64 100644 (file)
@@ -9,9 +9,11 @@
 #include <vector>
 
 #include "base/basictypes.h"
+#include "base/memory/shared_memory.h"
 #include "base/process/process_handle.h"
 #include "build/build_config.h"
 #include "ipc/ipc_channel.h"
+#include "ipc/ipc_platform_file.h"
 
 #if defined(OS_POSIX)
 #include "base/file_descriptor_posix.h"
@@ -36,15 +38,34 @@ inline int ToNativeHandle(const FileDescriptor& desc) {
 }
 #endif
 
+// We allocate a page of shared memory for sharing crash information from
+// trusted code in the NaCl process to the renderer.
+static const int kNaClCrashInfoShmemSize = 4096;
+static const int kNaClCrashInfoMaxLogSize = 1024;
+
+// Types of untrusted NaCl processes.
+enum NaClAppProcessType {
+  kUnknownNaClProcessType,
+  // Runs user-provided *native* code. Enabled for Chrome Web Store apps.
+  kNativeNaClProcessType,
+  // Runs user-provided code that is translated from *bitcode* by an
+  // in-browser PNaCl translator.
+  kPNaClProcessType,
+  // Runs pnacl-llc/linker *native* code. These nexes are browser-provided
+  // (not user-provided).
+  kPNaClTranslatorProcessType,
+  kNumNaClProcessTypes
+};
 
 // Parameters sent to the NaCl process when we start it.
-//
-// If you change this, you will also need to update the IPC serialization in
-// nacl_messages.h.
 struct NaClStartParams {
   NaClStartParams();
   ~NaClStartParams();
 
+  IPC::PlatformFileForTransit nexe_file;
+  uint64_t nexe_token_lo;
+  uint64_t nexe_token_hi;
+
   std::vector<FileDescriptor> handles;
   FileDescriptor debug_stub_server_bound_socket;
 
@@ -55,12 +76,17 @@ struct NaClStartParams {
   // executable or DLL.
   std::string version;
 
-  bool enable_exception_handling;
   bool enable_debug_stub;
   bool enable_ipc_proxy;
-  bool uses_irt;
-  bool enable_dyncode_syscalls;
-  bool enable_nonsfi_mode;
+
+  NaClAppProcessType process_type;
+
+  // For NaCl <-> renderer crash information reporting.
+  base::SharedMemoryHandle crash_info_shmem_handle;
+
+  // NOTE: Any new fields added here must also be added to the IPC
+  // serialization in nacl_messages.h and (for POD fields) the constructor
+  // in nacl_types.cc.
 };
 
 // Parameters sent to the browser process to have it launch a NaCl process.
@@ -69,34 +95,61 @@ struct NaClStartParams {
 // nacl_host_messages.h.
 struct NaClLaunchParams {
   NaClLaunchParams();
-  NaClLaunchParams(const std::string& u, int r, uint32 p, bool uses_irt,
-                   bool enable_dyncode_syscalls,
-                   bool enable_exception_handling,
-                   bool enable_crash_throttling);
-  NaClLaunchParams(const NaClLaunchParams& l);
+  NaClLaunchParams(const std::string& manifest_url,
+                   const IPC::PlatformFileForTransit& nexe_file,
+                   uint64_t nexe_token_lo,
+                   uint64_t nexe_token_hi,
+                   int render_view_id,
+                   uint32 permission_bits,
+                   bool uses_nonsfi_mode,
+                   NaClAppProcessType process_type);
   ~NaClLaunchParams();
 
   std::string manifest_url;
+  // On Windows, the HANDLE passed here is valid in the renderer's context.
+  // It's the responsibility of the browser to duplicate this handle properly
+  // for passing it to the plugin.
+  IPC::PlatformFileForTransit nexe_file;
+  uint64_t nexe_token_lo;
+  uint64_t nexe_token_hi;
+
   int render_view_id;
   uint32 permission_bits;
-  bool uses_irt;
-  bool enable_dyncode_syscalls;
-  bool enable_exception_handling;
-  bool enable_crash_throttling;
+  bool uses_nonsfi_mode;
+
+  NaClAppProcessType process_type;
 };
 
 struct NaClLaunchResult {
   NaClLaunchResult();
-  NaClLaunchResult(FileDescriptor imc_channel_handle,
-                   const IPC::ChannelHandle& ipc_channel_handle,
-                   base::ProcessId plugin_pid,
-                   int plugin_child_id);
+  NaClLaunchResult(
+      FileDescriptor imc_channel_handle,
+      const IPC::ChannelHandle& ppapi_ipc_channel_handle,
+      const IPC::ChannelHandle& trusted_ipc_channel_handle,
+      const IPC::ChannelHandle& manifest_service_ipc_channel_handle,
+      base::ProcessId plugin_pid,
+      int plugin_child_id,
+      base::SharedMemoryHandle crash_info_shmem_handle);
   ~NaClLaunchResult();
 
+  // For plugin loader <-> renderer IMC communication.
   FileDescriptor imc_channel_handle;
-  IPC::ChannelHandle ipc_channel_handle;
+
+  // For plugin <-> renderer PPAPI communication.
+  IPC::ChannelHandle ppapi_ipc_channel_handle;
+
+  // For plugin loader <-> renderer control communication (loading and
+  // starting nexe).
+  IPC::ChannelHandle trusted_ipc_channel_handle;
+
+  // For plugin <-> renderer ManifestService communication.
+  IPC::ChannelHandle manifest_service_ipc_channel_handle;
+
   base::ProcessId plugin_pid;
   int plugin_child_id;
+
+  // For NaCl <-> renderer crash information reporting.
+  base::SharedMemoryHandle crash_info_shmem_handle;
 };
 
 }  // namespace nacl