Add testing/scripts/OWNERS
[chromium-blink-merge.git] / components / nacl / common / nacl_types.h
blob490ec64118976a107658063963ba4015eae803e6
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.
5 #ifndef COMPONENTS_NACL_COMMON_NACL_TYPES_H_
6 #define COMPONENTS_NACL_COMMON_NACL_TYPES_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/memory/shared_memory.h"
13 #include "base/process/process_handle.h"
14 #include "build/build_config.h"
15 #include "ipc/ipc_channel.h"
16 #include "ipc/ipc_platform_file.h"
18 #if defined(OS_POSIX)
19 #include "base/file_descriptor_posix.h"
20 #endif
22 #if defined(OS_WIN)
23 #include <windows.h> // for HANDLE
24 #endif
26 // TODO(gregoryd): add a Windows definition for base::FileDescriptor
27 namespace nacl {
29 #if defined(OS_WIN)
30 typedef HANDLE FileDescriptor;
31 inline HANDLE ToNativeHandle(const FileDescriptor& desc) {
32 return desc;
34 #elif defined(OS_POSIX)
35 typedef base::FileDescriptor FileDescriptor;
36 inline int ToNativeHandle(const FileDescriptor& desc) {
37 return desc.fd;
39 #endif
41 // We allocate a page of shared memory for sharing crash information from
42 // trusted code in the NaCl process to the renderer.
43 static const int kNaClCrashInfoShmemSize = 4096;
44 static const int kNaClCrashInfoMaxLogSize = 1024;
46 // Types of untrusted NaCl processes.
47 enum NaClAppProcessType {
48 kUnknownNaClProcessType,
49 // Runs user-provided *native* code. Enabled for Chrome Web Store apps.
50 kNativeNaClProcessType,
51 // Runs user-provided code that is translated from *bitcode* by an
52 // in-browser PNaCl translator.
53 kPNaClProcessType,
54 // Runs pnacl-llc/linker *native* code. These nexes are browser-provided
55 // (not user-provided).
56 kPNaClTranslatorProcessType,
57 kNumNaClProcessTypes
60 // Parameters sent to the NaCl process when we start it.
61 struct NaClStartParams {
62 NaClStartParams();
63 ~NaClStartParams();
65 IPC::PlatformFileForTransit nexe_file;
66 uint64_t nexe_token_lo;
67 uint64_t nexe_token_hi;
69 std::vector<FileDescriptor> handles;
70 FileDescriptor debug_stub_server_bound_socket;
72 bool validation_cache_enabled;
73 std::string validation_cache_key;
74 // Chrome version string. Sending the version string over IPC avoids linkage
75 // issues in cases where NaCl is not compiled into the main Chromium
76 // executable or DLL.
77 std::string version;
79 bool enable_debug_stub;
80 bool enable_ipc_proxy;
82 NaClAppProcessType process_type;
84 // For NaCl <-> renderer crash information reporting.
85 base::SharedMemoryHandle crash_info_shmem_handle;
87 // NOTE: Any new fields added here must also be added to the IPC
88 // serialization in nacl_messages.h and (for POD fields) the constructor
89 // in nacl_types.cc.
92 // Parameters sent to the browser process to have it launch a NaCl process.
94 // If you change this, you will also need to update the IPC serialization in
95 // nacl_host_messages.h.
96 struct NaClLaunchParams {
97 NaClLaunchParams();
98 NaClLaunchParams(const std::string& manifest_url,
99 const IPC::PlatformFileForTransit& nexe_file,
100 uint64_t nexe_token_lo,
101 uint64_t nexe_token_hi,
102 int render_view_id,
103 uint32 permission_bits,
104 bool uses_nonsfi_mode,
105 NaClAppProcessType process_type);
106 ~NaClLaunchParams();
108 std::string manifest_url;
109 // On Windows, the HANDLE passed here is valid in the renderer's context.
110 // It's the responsibility of the browser to duplicate this handle properly
111 // for passing it to the plugin.
112 IPC::PlatformFileForTransit nexe_file;
113 uint64_t nexe_token_lo;
114 uint64_t nexe_token_hi;
116 int render_view_id;
117 uint32 permission_bits;
118 bool uses_nonsfi_mode;
120 NaClAppProcessType process_type;
123 struct NaClLaunchResult {
124 NaClLaunchResult();
125 NaClLaunchResult(
126 FileDescriptor imc_channel_handle,
127 const IPC::ChannelHandle& ppapi_ipc_channel_handle,
128 const IPC::ChannelHandle& trusted_ipc_channel_handle,
129 const IPC::ChannelHandle& manifest_service_ipc_channel_handle,
130 base::ProcessId plugin_pid,
131 int plugin_child_id,
132 base::SharedMemoryHandle crash_info_shmem_handle);
133 ~NaClLaunchResult();
135 // For plugin loader <-> renderer IMC communication.
136 FileDescriptor imc_channel_handle;
138 // For plugin <-> renderer PPAPI communication.
139 IPC::ChannelHandle ppapi_ipc_channel_handle;
141 // For plugin loader <-> renderer control communication (loading and
142 // starting nexe).
143 IPC::ChannelHandle trusted_ipc_channel_handle;
145 // For plugin <-> renderer ManifestService communication.
146 IPC::ChannelHandle manifest_service_ipc_channel_handle;
148 base::ProcessId plugin_pid;
149 int plugin_child_id;
151 // For NaCl <-> renderer crash information reporting.
152 base::SharedMemoryHandle crash_info_shmem_handle;
155 } // namespace nacl
157 #endif // COMPONENTS_NACL_COMMON_NACL_TYPES_H_