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 #include "components/nacl/common/nacl_types.h" | 5 #include "components/nacl/common/nacl_types.h" |
| 6 #include "ipc/ipc_message_attachment_set.h" |
6 #include "ipc/ipc_platform_file.h" | 7 #include "ipc/ipc_platform_file.h" |
7 | 8 |
8 namespace nacl { | 9 namespace nacl { |
9 | 10 |
10 NaClStartParams::NaClStartParams() | 11 NaClStartParams::NaClStartParams() |
11 : nexe_file(IPC::InvalidPlatformFileForTransit()), | 12 : nexe_file(IPC::InvalidPlatformFileForTransit()), |
12 validation_cache_enabled(false), | 13 validation_cache_enabled(false), |
13 enable_debug_stub(false), | 14 enable_debug_stub(false), |
14 enable_ipc_proxy(false), | 15 enable_ipc_proxy(false), |
15 enable_mojo(false), | 16 enable_mojo(false), |
16 process_type(kUnknownNaClProcessType), | 17 process_type(kUnknownNaClProcessType), |
17 crash_info_shmem_handle(base::SharedMemory::NULLHandle()) { | 18 crash_info_shmem_handle(base::SharedMemory::NULLHandle()) { |
18 } | 19 } |
19 | 20 |
20 NaClStartParams::~NaClStartParams() { | 21 NaClStartParams::~NaClStartParams() { |
21 } | 22 } |
22 | 23 |
| 24 void NaClStartParams::CheckNumOfDescriptors() { |
| 25 // TODO(yusukes): Change this to OS_POSIX once we support batch-opening |
| 26 // resource files on SFI-NaCl. Note that OS_WIN does not have such an |
| 27 // artificial limitation on the number of handles per IPC. |
| 28 #if defined(OS_LINUX) |
| 29 // '3' is for |nexe_file|, |debug_stub_server_bound_socket|, and |
| 30 // |crash_info_shmem_handle|. |
| 31 size_t num_descs = handles.size() + resource_files.size() + 3; |
| 32 // If this CHECK fails, either of the following has to be done: |
| 33 // * Increase kMaxDescriptorsPerMessage in ipc/ipc_message_attachment_set.h |
| 34 // * Or, decrease kMaxPreOpenResourceFiles in |
| 35 // components/nacl/renderer/ppb_nacl_private_impl.cc. |
| 36 CHECK(num_descs <= IPC::MessageAttachmentSet::kMaxDescriptorsPerMessage); |
| 37 #endif |
| 38 } |
| 39 |
| 40 NaClStartParams::ResourceFileInfo::ResourceFileInfo() |
| 41 : file(IPC::InvalidPlatformFileForTransit()) { |
| 42 } |
| 43 |
| 44 NaClStartParams::ResourceFileInfo::ResourceFileInfo( |
| 45 IPC::PlatformFileForTransit file, |
| 46 const base::FilePath& file_path, |
| 47 const std::string& file_key) |
| 48 : file(file), file_path(file_path), file_key(file_key) { |
| 49 } |
| 50 |
| 51 NaClStartParams::ResourceFileInfo::~ResourceFileInfo() { |
| 52 } |
| 53 |
23 NaClLaunchParams::NaClLaunchParams() | 54 NaClLaunchParams::NaClLaunchParams() |
24 : nexe_file(IPC::InvalidPlatformFileForTransit()), | 55 : nexe_file(IPC::InvalidPlatformFileForTransit()), |
25 nexe_token_lo(0), | 56 nexe_token_lo(0), |
26 nexe_token_hi(0), | 57 nexe_token_hi(0), |
27 render_view_id(0), | 58 render_view_id(0), |
28 permission_bits(0), | 59 permission_bits(0), |
29 process_type(kUnknownNaClProcessType) { | 60 process_type(kUnknownNaClProcessType) { |
30 } | 61 } |
31 | 62 |
32 NaClLaunchParams::NaClLaunchParams( | 63 NaClLaunchParams::NaClLaunchParams( |
33 const std::string& manifest_url, | 64 const std::string& manifest_url, |
34 const IPC::PlatformFileForTransit& nexe_file, | 65 const IPC::PlatformFileForTransit& nexe_file, |
35 uint64_t nexe_token_lo, | 66 uint64_t nexe_token_lo, |
36 uint64_t nexe_token_hi, | 67 uint64_t nexe_token_hi, |
| 68 const std::vector<ResourceFileInfo>& resource_files_info, |
37 int render_view_id, | 69 int render_view_id, |
38 uint32 permission_bits, | 70 uint32 permission_bits, |
39 bool uses_nonsfi_mode, | 71 bool uses_nonsfi_mode, |
40 NaClAppProcessType process_type) | 72 NaClAppProcessType process_type) |
41 : manifest_url(manifest_url), | 73 : manifest_url(manifest_url), |
42 nexe_file(nexe_file), | 74 nexe_file(nexe_file), |
43 nexe_token_lo(nexe_token_lo), | 75 nexe_token_lo(nexe_token_lo), |
44 nexe_token_hi(nexe_token_hi), | 76 nexe_token_hi(nexe_token_hi), |
| 77 resource_files_info(resource_files_info), |
45 render_view_id(render_view_id), | 78 render_view_id(render_view_id), |
46 permission_bits(permission_bits), | 79 permission_bits(permission_bits), |
47 uses_nonsfi_mode(uses_nonsfi_mode), | 80 uses_nonsfi_mode(uses_nonsfi_mode), |
48 process_type(process_type) { | 81 process_type(process_type) { |
49 } | 82 } |
50 | 83 |
51 NaClLaunchParams::~NaClLaunchParams() { | 84 NaClLaunchParams::~NaClLaunchParams() { |
52 } | 85 } |
53 | 86 |
| 87 NaClLaunchParams::ResourceFileInfo::ResourceFileInfo() { |
| 88 } |
| 89 |
| 90 NaClLaunchParams::ResourceFileInfo::ResourceFileInfo( |
| 91 NaClFileInfo file_info, const std::string& file_key) |
| 92 : file_info(file_info), |
| 93 file_key(file_key) { |
| 94 } |
| 95 |
| 96 NaClLaunchParams::ResourceFileInfo::~ResourceFileInfo() { |
| 97 } |
| 98 |
54 NaClLaunchResult::NaClLaunchResult() | 99 NaClLaunchResult::NaClLaunchResult() |
55 : imc_channel_handle(IPC::InvalidPlatformFileForTransit()), | 100 : imc_channel_handle(IPC::InvalidPlatformFileForTransit()), |
56 ppapi_ipc_channel_handle(), | 101 ppapi_ipc_channel_handle(), |
57 trusted_ipc_channel_handle(), | 102 trusted_ipc_channel_handle(), |
58 plugin_pid(base::kNullProcessId), | 103 plugin_pid(base::kNullProcessId), |
59 plugin_child_id(0), | 104 plugin_child_id(0), |
60 crash_info_shmem_handle(base::SharedMemory::NULLHandle()) { | 105 crash_info_shmem_handle(base::SharedMemory::NULLHandle()) { |
61 } | 106 } |
62 | 107 |
63 NaClLaunchResult::NaClLaunchResult( | 108 NaClLaunchResult::NaClLaunchResult( |
64 FileDescriptor imc_channel_handle, | 109 FileDescriptor imc_channel_handle, |
65 const IPC::ChannelHandle& ppapi_ipc_channel_handle, | 110 const IPC::ChannelHandle& ppapi_ipc_channel_handle, |
66 const IPC::ChannelHandle& trusted_ipc_channel_handle, | 111 const IPC::ChannelHandle& trusted_ipc_channel_handle, |
67 const IPC::ChannelHandle& manifest_service_ipc_channel_handle, | 112 const IPC::ChannelHandle& manifest_service_ipc_channel_handle, |
68 base::ProcessId plugin_pid, | 113 base::ProcessId plugin_pid, |
69 int plugin_child_id, | 114 int plugin_child_id, |
70 base::SharedMemoryHandle crash_info_shmem_handle) | 115 base::SharedMemoryHandle crash_info_shmem_handle) |
71 : imc_channel_handle(imc_channel_handle), | 116 : imc_channel_handle(imc_channel_handle), |
72 ppapi_ipc_channel_handle(ppapi_ipc_channel_handle), | 117 ppapi_ipc_channel_handle(ppapi_ipc_channel_handle), |
73 trusted_ipc_channel_handle(trusted_ipc_channel_handle), | 118 trusted_ipc_channel_handle(trusted_ipc_channel_handle), |
74 manifest_service_ipc_channel_handle(manifest_service_ipc_channel_handle), | 119 manifest_service_ipc_channel_handle(manifest_service_ipc_channel_handle), |
75 plugin_pid(plugin_pid), | 120 plugin_pid(plugin_pid), |
76 plugin_child_id(plugin_child_id), | 121 plugin_child_id(plugin_child_id), |
77 crash_info_shmem_handle(crash_info_shmem_handle) { | 122 crash_info_shmem_handle(crash_info_shmem_handle) { |
78 } | 123 } |
79 | 124 |
80 NaClLaunchResult::~NaClLaunchResult() { | 125 NaClLaunchResult::~NaClLaunchResult() { |
81 } | 126 } |
82 | 127 |
| 128 NaClFileInfo::NaClFileInfo() |
| 129 : file(IPC::InvalidPlatformFileForTransit()), |
| 130 file_token_lo(0), |
| 131 file_token_hi(0) { |
| 132 } |
| 133 |
| 134 NaClFileInfo::NaClFileInfo(IPC::PlatformFileForTransit file, |
| 135 uint64_t file_token_lo, |
| 136 uint64_t file_token_hi) |
| 137 : file(file), |
| 138 file_token_lo(file_token_lo), |
| 139 file_token_hi(file_token_hi) { |
| 140 } |
| 141 |
| 142 NaClFileInfo::~NaClFileInfo() { |
| 143 } |
| 144 |
83 } // namespace nacl | 145 } // namespace nacl |
OLD | NEW |