OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_NACL_COMMON_NACL_TYPES_H_ | 5 #ifndef COMPONENTS_NACL_COMMON_NACL_TYPES_H_ |
6 #define COMPONENTS_NACL_COMMON_NACL_TYPES_H_ | 6 #define COMPONENTS_NACL_COMMON_NACL_TYPES_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/shared_memory.h" | 13 #include "base/memory/shared_memory.h" |
14 #include "base/process/process_handle.h" | 14 #include "base/process/process_handle.h" |
15 #include "build/build_config.h" | 15 #include "build/build_config.h" |
16 #include "ipc/ipc_channel.h" | 16 #include "ipc/ipc_channel.h" |
17 #include "ipc/ipc_platform_file.h" | 17 #include "ipc/ipc_platform_file.h" |
18 | 18 |
19 #if defined(OS_POSIX) | |
20 #include "base/file_descriptor_posix.h" | |
21 #endif | |
22 | |
23 #if defined(OS_WIN) | |
24 #include <windows.h> // for HANDLE | |
25 #endif | |
26 | |
27 // TODO(gregoryd): add a Windows definition for base::FileDescriptor | |
28 namespace nacl { | 19 namespace nacl { |
29 | 20 |
30 #if defined(OS_WIN) | |
31 typedef HANDLE FileDescriptor; | |
32 inline HANDLE ToNativeHandle(const FileDescriptor& desc) { | |
33 return desc; | |
34 } | |
35 #elif defined(OS_POSIX) | |
36 typedef base::FileDescriptor FileDescriptor; | |
37 inline int ToNativeHandle(const FileDescriptor& desc) { | |
38 return desc.fd; | |
39 } | |
40 #endif | |
41 | |
42 // We allocate a page of shared memory for sharing crash information from | 21 // We allocate a page of shared memory for sharing crash information from |
43 // trusted code in the NaCl process to the renderer. | 22 // trusted code in the NaCl process to the renderer. |
44 static const int kNaClCrashInfoShmemSize = 4096; | 23 static const int kNaClCrashInfoShmemSize = 4096; |
45 static const int kNaClCrashInfoMaxLogSize = 1024; | 24 static const int kNaClCrashInfoMaxLogSize = 1024; |
46 | 25 |
47 // Types of untrusted NaCl processes. | 26 // Types of untrusted NaCl processes. |
48 enum NaClAppProcessType { | 27 enum NaClAppProcessType { |
49 kUnknownNaClProcessType, | 28 kUnknownNaClProcessType, |
50 // Runs user-provided *native* code. Enabled for Chrome Web Store apps. | 29 // Runs user-provided *native* code. Enabled for Chrome Web Store apps. |
51 kNativeNaClProcessType, | 30 kNativeNaClProcessType, |
(...skipping 15 matching lines...) Expand all Loading... |
67 ~NaClResourcePrefetchRequest(); | 46 ~NaClResourcePrefetchRequest(); |
68 | 47 |
69 std::string file_key; // a key for open_resource. | 48 std::string file_key; // a key for open_resource. |
70 std::string resource_url; | 49 std::string resource_url; |
71 }; | 50 }; |
72 | 51 |
73 // Represents a single prefetched file that's listed in the "files" section of | 52 // Represents a single prefetched file that's listed in the "files" section of |
74 // a NaCl manifest file. | 53 // a NaCl manifest file. |
75 struct NaClResourcePrefetchResult { | 54 struct NaClResourcePrefetchResult { |
76 NaClResourcePrefetchResult(); | 55 NaClResourcePrefetchResult(); |
77 NaClResourcePrefetchResult(IPC::PlatformFileForTransit file, | 56 NaClResourcePrefetchResult(const IPC::PlatformFileForTransit& file, |
78 const base::FilePath& file_path, | 57 const base::FilePath& file_path, |
79 const std::string& file_key); | 58 const std::string& file_key); |
80 ~NaClResourcePrefetchResult(); | 59 ~NaClResourcePrefetchResult(); |
81 | 60 |
82 IPC::PlatformFileForTransit file; | 61 IPC::PlatformFileForTransit file; |
83 base::FilePath file_path_metadata; // a key for validation caching | 62 base::FilePath file_path_metadata; // a key for validation caching |
84 std::string file_key; // a key for open_resource | 63 std::string file_key; // a key for open_resource |
85 }; | 64 }; |
86 | 65 |
87 // Parameters sent to the NaCl process when we start it. | 66 // Parameters sent to the NaCl process when we start it. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 int render_view_id; | 133 int render_view_id; |
155 uint32 permission_bits; | 134 uint32 permission_bits; |
156 bool uses_nonsfi_mode; | 135 bool uses_nonsfi_mode; |
157 | 136 |
158 NaClAppProcessType process_type; | 137 NaClAppProcessType process_type; |
159 }; | 138 }; |
160 | 139 |
161 struct NaClLaunchResult { | 140 struct NaClLaunchResult { |
162 NaClLaunchResult(); | 141 NaClLaunchResult(); |
163 NaClLaunchResult( | 142 NaClLaunchResult( |
164 FileDescriptor imc_channel_handle, | 143 const IPC::PlatformFileForTransit& imc_channel_handle, |
165 const IPC::ChannelHandle& ppapi_ipc_channel_handle, | 144 const IPC::ChannelHandle& ppapi_ipc_channel_handle, |
166 const IPC::ChannelHandle& trusted_ipc_channel_handle, | 145 const IPC::ChannelHandle& trusted_ipc_channel_handle, |
167 const IPC::ChannelHandle& manifest_service_ipc_channel_handle, | 146 const IPC::ChannelHandle& manifest_service_ipc_channel_handle, |
168 base::ProcessId plugin_pid, | 147 base::ProcessId plugin_pid, |
169 int plugin_child_id, | 148 int plugin_child_id, |
170 base::SharedMemoryHandle crash_info_shmem_handle); | 149 base::SharedMemoryHandle crash_info_shmem_handle); |
171 ~NaClLaunchResult(); | 150 ~NaClLaunchResult(); |
172 | 151 |
173 // For plugin loader <-> renderer IMC communication. | 152 // For plugin loader <-> renderer IMC communication. |
174 FileDescriptor imc_channel_handle; | 153 IPC::PlatformFileForTransit imc_channel_handle; |
175 | 154 |
176 // For plugin <-> renderer PPAPI communication. | 155 // For plugin <-> renderer PPAPI communication. |
177 IPC::ChannelHandle ppapi_ipc_channel_handle; | 156 IPC::ChannelHandle ppapi_ipc_channel_handle; |
178 | 157 |
179 // For plugin loader <-> renderer control communication (loading and | 158 // For plugin loader <-> renderer control communication (loading and |
180 // starting nexe). | 159 // starting nexe). |
181 IPC::ChannelHandle trusted_ipc_channel_handle; | 160 IPC::ChannelHandle trusted_ipc_channel_handle; |
182 | 161 |
183 // For plugin <-> renderer ManifestService communication. | 162 // For plugin <-> renderer ManifestService communication. |
184 IPC::ChannelHandle manifest_service_ipc_channel_handle; | 163 IPC::ChannelHandle manifest_service_ipc_channel_handle; |
185 | 164 |
186 base::ProcessId plugin_pid; | 165 base::ProcessId plugin_pid; |
187 int plugin_child_id; | 166 int plugin_child_id; |
188 | 167 |
189 // For NaCl <-> renderer crash information reporting. | 168 // For NaCl <-> renderer crash information reporting. |
190 base::SharedMemoryHandle crash_info_shmem_handle; | 169 base::SharedMemoryHandle crash_info_shmem_handle; |
191 }; | 170 }; |
192 | 171 |
193 } // namespace nacl | 172 } // namespace nacl |
194 | 173 |
195 #endif // COMPONENTS_NACL_COMMON_NACL_TYPES_H_ | 174 #endif // COMPONENTS_NACL_COMMON_NACL_TYPES_H_ |
OLD | NEW |