Add an exponential backoff to rechecking the app list doodle.
[chromium-blink-merge.git] / components / nacl / common / nacl_types.h
blobf691edf9b2f7c6068efb3f686337ada1e994b7b6
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 <utility>
10 #include <vector>
12 #include "base/basictypes.h"
13 #include "base/memory/shared_memory.h"
14 #include "base/process/process_handle.h"
15 #include "build/build_config.h"
16 #include "ipc/ipc_channel.h"
17 #include "ipc/ipc_platform_file.h"
19 #if defined(OS_POSIX)
20 #include "base/file_descriptor_posix.h"
21 #endif
23 #if defined(OS_WIN)
24 #include <windows.h> // for HANDLE
25 #endif
27 // TODO(gregoryd): add a Windows definition for base::FileDescriptor
28 namespace nacl {
30 #if defined(OS_WIN)
31 typedef HANDLE FileDescriptor;
32 inline HANDLE ToNativeHandle(const FileDescriptor& desc) {
33 return desc;
35 #elif defined(OS_POSIX)
36 typedef base::FileDescriptor FileDescriptor;
37 inline int ToNativeHandle(const FileDescriptor& desc) {
38 return desc.fd;
40 #endif
42 // We allocate a page of shared memory for sharing crash information from
43 // trusted code in the NaCl process to the renderer.
44 static const int kNaClCrashInfoShmemSize = 4096;
45 static const int kNaClCrashInfoMaxLogSize = 1024;
47 // Types of untrusted NaCl processes.
48 enum NaClAppProcessType {
49 kUnknownNaClProcessType,
50 // Runs user-provided *native* code. Enabled for Chrome Web Store apps.
51 kNativeNaClProcessType,
52 // Runs user-provided code that is translated from *bitcode* by an
53 // in-browser PNaCl translator.
54 kPNaClProcessType,
55 // Runs pnacl-llc/linker *native* code. These nexes are browser-provided
56 // (not user-provided).
57 kPNaClTranslatorProcessType,
58 kNumNaClProcessTypes
61 // Represents a single prefetched file that's listed in the "files" section of
62 // a NaCl manifest file.
63 struct NaClResourceFileInfo {
64 NaClResourceFileInfo();
65 NaClResourceFileInfo(IPC::PlatformFileForTransit file,
66 const base::FilePath& file_path,
67 const std::string& file_key);
68 ~NaClResourceFileInfo();
70 IPC::PlatformFileForTransit file;
71 base::FilePath file_path_metadata; // a key for validation caching
72 std::string file_key; // a key for open_resource
75 // Parameters sent to the NaCl process when we start it.
76 struct NaClStartParams {
77 NaClStartParams();
78 ~NaClStartParams();
80 IPC::PlatformFileForTransit nexe_file;
81 // Used only as a key for validation caching.
82 base::FilePath nexe_file_path_metadata;
84 std::vector<NaClResourceFileInfo> prefetched_resource_files;
85 std::vector<FileDescriptor> handles;
86 FileDescriptor debug_stub_server_bound_socket;
88 bool validation_cache_enabled;
89 std::string validation_cache_key;
90 // Chrome version string. Sending the version string over IPC avoids linkage
91 // issues in cases where NaCl is not compiled into the main Chromium
92 // executable or DLL.
93 std::string version;
95 bool enable_debug_stub;
96 bool enable_ipc_proxy;
98 // Enables plugin code to use Mojo APIs. See mojo/nacl for details.
99 bool enable_mojo;
101 NaClAppProcessType process_type;
103 // For NaCl <-> renderer crash information reporting.
104 base::SharedMemoryHandle crash_info_shmem_handle;
106 // NOTE: Any new fields added here must also be added to the IPC
107 // serialization in nacl_messages.h and (for POD fields) the constructor
108 // in nacl_types.cc.
111 // Parameters sent to the browser process to have it launch a NaCl process.
113 // If you change this, you will also need to update the IPC serialization in
114 // nacl_host_messages.h.
115 struct NaClLaunchParams {
116 NaClLaunchParams();
117 NaClLaunchParams(
118 const std::string& manifest_url,
119 const IPC::PlatformFileForTransit& nexe_file,
120 uint64_t nexe_token_lo,
121 uint64_t nexe_token_hi,
122 // A pair of a manifest key and its resource URL.
123 const std::vector<
124 std::pair<std::string, std::string> >& resource_files_to_prefetch,
125 int render_view_id,
126 uint32 permission_bits,
127 bool uses_nonsfi_mode,
128 NaClAppProcessType process_type);
129 ~NaClLaunchParams();
131 std::string manifest_url;
132 // On Windows, the HANDLE passed here is valid in the renderer's context.
133 // It's the responsibility of the browser to duplicate this handle properly
134 // for passing it to the plugin.
135 IPC::PlatformFileForTransit nexe_file;
136 uint64_t nexe_token_lo;
137 uint64_t nexe_token_hi;
138 std::vector<std::pair<std::string, std::string> > resource_files_to_prefetch;
140 int render_view_id;
141 uint32 permission_bits;
142 bool uses_nonsfi_mode;
144 NaClAppProcessType process_type;
147 struct NaClLaunchResult {
148 NaClLaunchResult();
149 NaClLaunchResult(
150 FileDescriptor imc_channel_handle,
151 const IPC::ChannelHandle& ppapi_ipc_channel_handle,
152 const IPC::ChannelHandle& trusted_ipc_channel_handle,
153 const IPC::ChannelHandle& manifest_service_ipc_channel_handle,
154 base::ProcessId plugin_pid,
155 int plugin_child_id,
156 base::SharedMemoryHandle crash_info_shmem_handle);
157 ~NaClLaunchResult();
159 // For plugin loader <-> renderer IMC communication.
160 FileDescriptor imc_channel_handle;
162 // For plugin <-> renderer PPAPI communication.
163 IPC::ChannelHandle ppapi_ipc_channel_handle;
165 // For plugin loader <-> renderer control communication (loading and
166 // starting nexe).
167 IPC::ChannelHandle trusted_ipc_channel_handle;
169 // For plugin <-> renderer ManifestService communication.
170 IPC::ChannelHandle manifest_service_ipc_channel_handle;
172 base::ProcessId plugin_pid;
173 int plugin_child_id;
175 // For NaCl <-> renderer crash information reporting.
176 base::SharedMemoryHandle crash_info_shmem_handle;
179 } // namespace nacl
181 #endif // COMPONENTS_NACL_COMMON_NACL_TYPES_H_