Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(455)

Unified Diff: components/nacl/loader/nacl_listener.cc

Issue 1085583005: Refactor params of NaClProcessMsg_Start. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/nacl/loader/nacl_listener.cc
diff --git a/components/nacl/loader/nacl_listener.cc b/components/nacl/loader/nacl_listener.cc
index 4cf4a3ed2e8435964d729a4c5ca75e6464c4949e..78c50f2b5aefe2d83c579de77f5daf6b55ab7737 100644
--- a/components/nacl/loader/nacl_listener.cc
+++ b/components/nacl/loader/nacl_listener.cc
@@ -295,8 +295,9 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) {
struct NaClApp* nap = NULL;
NaClChromeMainInit();
- crash_info_shmem_.reset(new base::SharedMemory(params.crash_info_shmem_handle,
- false));
+ CHECK(base::SharedMemory::IsHandleValid(params.crash_info_shmem_handle));
+ crash_info_shmem_.reset(new base::SharedMemory(
+ params.crash_info_shmem_handle, false /* not readonly */));
CHECK(crash_info_shmem_->Map(nacl::kNaClCrashInfoShmemSize));
NaClSetFatalErrorCallback(&FatalLogHandler);
@@ -343,7 +344,6 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) {
manifest_service_handle)))
LOG(ERROR) << "Failed to send IPC channel handle to NaClProcessHost.";
- std::vector<nacl::FileDescriptor> handles = params.handles;
struct NaClChromeMainArgs* args = NaClChromeMainArgsCreate();
if (args == NULL) {
LOG(ERROR) << "NaClChromeMainArgsCreate() failed";
@@ -354,16 +354,17 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) {
args->number_of_cores = number_of_cores_;
args->create_memory_object_func = CreateMemoryObject;
# if defined(OS_MACOSX)
Mark Seaborn 2015/04/24 00:53:25 You could move this outside "#if defined(OS_LINUX)
hidehiko 2015/04/24 10:05:18 Acknowledged.
- CHECK(handles.size() >= 1);
- g_shm_fd = nacl::ToNativeHandle(handles[handles.size() - 1]);
- handles.pop_back();
+ CHECK(params.mac_shm_fd != IPC::InvalidPlatformFileForTransit());
+ g_shm_fd = IPC::PlatformFileForTransitToPlatformFile(params.mac_shm_fd);
+# else
+ CHECK(params.mac_shm_fd == IPC::InvalidPlatformFileForTransit());
Mark Seaborn 2015/04/24 00:53:25 Note that you're doing this check on OS_LINUX but
hidehiko 2015/04/24 10:05:18 Now the field is guraded by OS_MACOSX #ifdef, so I
# endif
#endif
DCHECK(params.process_type != nacl::kUnknownNaClProcessType);
- CHECK(handles.size() >= 1);
- NaClHandle irt_handle = nacl::ToNativeHandle(handles[handles.size() - 1]);
- handles.pop_back();
+ CHECK(params.irt_handle != IPC::InvalidPlatformFileForTransit());
+ NaClHandle irt_handle =
+ IPC::PlatformFileForTransitToPlatformFile(params.irt_handle);
#if defined(OS_WIN)
args->irt_fd = _open_osfhandle(reinterpret_cast<intptr_t>(irt_handle),
@@ -385,8 +386,9 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) {
params.version);
}
- CHECK(handles.size() == 1);
- args->imc_bootstrap_handle = nacl::ToNativeHandle(handles[0]);
+ CHECK(params.imc_bootstrap_handle != IPC::InvalidPlatformFileForTransit());
+ args->imc_bootstrap_handle =
+ IPC::PlatformFileForTransitToPlatformFile(params.imc_bootstrap_handle);
args->enable_debug_stub = params.enable_debug_stub;
// Now configure parts that depend on process type.
@@ -416,9 +418,13 @@ void NaClListener::OnStart(const nacl::NaClStartParams& params) {
args->pnacl_mode = 0;
}
-#if defined(OS_LINUX) || defined(OS_MACOSX)
- args->debug_stub_server_bound_socket_fd = nacl::ToNativeHandle(
- params.debug_stub_server_bound_socket);
+#if defined(OS_POSIX)
+ args->debug_stub_server_bound_socket_fd =
+ IPC::PlatformFileForTransitToPlatformFile(
+ params.debug_stub_server_bound_socket);
+#else
+ CHECK(params.debug_stub_server_bound_socket ==
+ IPC::InvalidPlatformFileForTransit());
#endif
#if defined(OS_WIN)
args->broker_duplicate_handle_func = BrokerDuplicateHandle;

Powered by Google App Engine
This is Rietveld 408576698