1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
|
// Copyright 2013 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_NACL_COMMON_NACL_TYPES_H_
#define COMPONENTS_NACL_COMMON_NACL_TYPES_H_
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
#include "base/memory/read_only_shared_memory_region.h"
#include "base/memory/writable_shared_memory_region.h"
#include "base/process/process_handle.h"
#include "build/build_config.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_platform_file.h"
namespace nacl {
// 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
};
// Represents a request to prefetch a file that's listed in the "files" section
// of a NaCl manifest file.
struct NaClResourcePrefetchRequest {
NaClResourcePrefetchRequest();
NaClResourcePrefetchRequest(const std::string& file_key,
const std::string& resource_url);
~NaClResourcePrefetchRequest();
std::string file_key; // a key for open_resource.
std::string resource_url;
};
// Represents a single prefetched file that's listed in the "files" section of
// a NaCl manifest file.
struct NaClResourcePrefetchResult {
NaClResourcePrefetchResult();
NaClResourcePrefetchResult(const IPC::PlatformFileForTransit& file,
const base::FilePath& file_path,
const std::string& file_key);
~NaClResourcePrefetchResult();
IPC::PlatformFileForTransit file;
base::FilePath file_path_metadata; // a key for validation caching
std::string file_key; // a key for open_resource
};
// Parameters sent to the NaCl process when we start it.
struct NaClStartParams {
NaClStartParams();
NaClStartParams(const NaClStartParams&) = delete;
NaClStartParams& operator=(const NaClStartParams&) = delete;
NaClStartParams(NaClStartParams&& other);
~NaClStartParams();
IPC::PlatformFileForTransit nexe_file;
// Used only as a key for validation caching.
base::FilePath nexe_file_path_metadata;
IPC::PlatformFileForTransit irt_handle;
#if BUILDFLAG(IS_POSIX)
IPC::PlatformFileForTransit debug_stub_server_bound_socket;
#endif
bool validation_cache_enabled;
std::string validation_cache_key;
// Chrome version string. Sending the version string over IPC avoids linkage
// issues in cases where NaCl is not compiled into the main Chromium
// executable or DLL.
std::string version;
bool enable_debug_stub;
NaClAppProcessType process_type;
// For NaCl <-> renderer crash information reporting.
base::WritableSharedMemoryRegion crash_info_shmem_region;
// 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.
//
// If you change this, you will also need to update the IPC serialization in
// nacl_host_messages.h.
struct NaClLaunchParams {
NaClLaunchParams();
NaClLaunchParams(const std::string& manifest_url,
const IPC::PlatformFileForTransit& nexe_file,
uint64_t nexe_token_lo,
uint64_t nexe_token_hi,
const std::vector<NaClResourcePrefetchRequest>&
resource_prefetch_request_list,
int render_frame_id,
uint32_t permission_bits,
NaClAppProcessType process_type);
NaClLaunchParams(const NaClLaunchParams& other);
~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 = IPC::InvalidPlatformFileForTransit();
uint64_t nexe_token_lo = 0;
uint64_t nexe_token_hi = 0;
std::vector<NaClResourcePrefetchRequest> resource_prefetch_request_list;
int render_frame_id = 0;
uint32_t permission_bits = 0;
NaClAppProcessType process_type = kUnknownNaClProcessType;
};
struct NaClLaunchResult {
NaClLaunchResult();
NaClLaunchResult(
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::ReadOnlySharedMemoryRegion crash_info_shmem_region);
NaClLaunchResult(const NaClLaunchResult&) = delete;
NaClLaunchResult& operator=(const NaClLaunchResult&) = delete;
~NaClLaunchResult();
// 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::ReadOnlySharedMemoryRegion crash_info_shmem_region;
};
} // namespace nacl
#endif // COMPONENTS_NACL_COMMON_NACL_TYPES_H_
|