Home | History | Annotate | Download | only in common
      1 // Copyright 2013 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 #ifndef COMPONENTS_NACL_COMMON_NACL_TYPES_H_
      6 #define COMPONENTS_NACL_COMMON_NACL_TYPES_H_
      7 
      8 #include <string>
      9 #include <vector>
     10 
     11 #include "base/basictypes.h"
     12 #include "base/process/process_handle.h"
     13 #include "build/build_config.h"
     14 #include "ipc/ipc_channel.h"
     15 
     16 #if defined(OS_POSIX)
     17 #include "base/file_descriptor_posix.h"
     18 #endif
     19 
     20 #if defined(OS_WIN)
     21 #include <windows.h>   // for HANDLE
     22 #endif
     23 
     24 // TODO(gregoryd): add a Windows definition for base::FileDescriptor
     25 namespace nacl {
     26 
     27 #if defined(OS_WIN)
     28 typedef HANDLE FileDescriptor;
     29 inline HANDLE ToNativeHandle(const FileDescriptor& desc) {
     30   return desc;
     31 }
     32 #elif defined(OS_POSIX)
     33 typedef base::FileDescriptor FileDescriptor;
     34 inline int ToNativeHandle(const FileDescriptor& desc) {
     35   return desc.fd;
     36 }
     37 #endif
     38 
     39 
     40 // Parameters sent to the NaCl process when we start it.
     41 //
     42 // If you change this, you will also need to update the IPC serialization in
     43 // nacl_messages.h.
     44 struct NaClStartParams {
     45   NaClStartParams();
     46   ~NaClStartParams();
     47 
     48   std::vector<FileDescriptor> handles;
     49   FileDescriptor debug_stub_server_bound_socket;
     50 
     51   bool validation_cache_enabled;
     52   std::string validation_cache_key;
     53   // Chrome version string. Sending the version string over IPC avoids linkage
     54   // issues in cases where NaCl is not compiled into the main Chromium
     55   // executable or DLL.
     56   std::string version;
     57 
     58   bool enable_exception_handling;
     59   bool enable_debug_stub;
     60   bool enable_ipc_proxy;
     61   bool uses_irt;
     62   bool enable_dyncode_syscalls;
     63 };
     64 
     65 // Parameters sent to the browser process to have it launch a NaCl process.
     66 //
     67 // If you change this, you will also need to update the IPC serialization in
     68 // nacl_host_messages.h.
     69 struct NaClLaunchParams {
     70   NaClLaunchParams();
     71   NaClLaunchParams(const std::string& u, int r, uint32 p, bool uses_irt,
     72                    bool enable_dyncode_syscalls,
     73                    bool enable_exception_handling);
     74   NaClLaunchParams(const NaClLaunchParams& l);
     75   ~NaClLaunchParams();
     76 
     77   std::string manifest_url;
     78   int render_view_id;
     79   uint32 permission_bits;
     80   bool uses_irt;
     81   bool enable_dyncode_syscalls;
     82   bool enable_exception_handling;
     83 };
     84 
     85 struct NaClLaunchResult {
     86   NaClLaunchResult();
     87   NaClLaunchResult(FileDescriptor imc_channel_handle,
     88                    const IPC::ChannelHandle& ipc_channel_handle,
     89                    base::ProcessId plugin_pid,
     90                    int plugin_child_id);
     91   ~NaClLaunchResult();
     92 
     93   FileDescriptor imc_channel_handle;
     94   IPC::ChannelHandle ipc_channel_handle;
     95   base::ProcessId plugin_pid;
     96   int plugin_child_id;
     97 };
     98 
     99 }  // namespace nacl
    100 
    101 #endif  // COMPONENTS_NACL_COMMON_NACL_TYPES_H_
    102