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

Side by Side Diff: components/nacl/browser/nacl_process_host.cc

Issue 1858973002: ipc: Rename GetFileHandleForProcess->GetPlatformFileForTransit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp16_ipc_pfft_implementation
Patch Set: Comments from tsepez. Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/browser/nacl_process_host.h" 5 #include "components/nacl/browser/nacl_process_host.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 if (enable_nacl_debug) { 876 if (enable_nacl_debug) {
877 base::ProcessId pid = base::GetProcId(process_->GetData().handle); 877 base::ProcessId pid = base::GetProcId(process_->GetData().handle);
878 LOG(WARNING) << "nonsfi nacl plugin running in " << pid; 878 LOG(WARNING) << "nonsfi nacl plugin running in " << pid;
879 } 879 }
880 } else { 880 } else {
881 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled(); 881 params.validation_cache_enabled = nacl_browser->ValidationCacheIsEnabled();
882 params.validation_cache_key = nacl_browser->GetValidationCacheKey(); 882 params.validation_cache_key = nacl_browser->GetValidationCacheKey();
883 params.version = NaClBrowser::GetDelegate()->GetVersionString(); 883 params.version = NaClBrowser::GetDelegate()->GetVersionString();
884 params.enable_debug_stub = enable_nacl_debug; 884 params.enable_debug_stub = enable_nacl_debug;
885 885
886 const ChildProcessData& data = process_->GetData();
887 const base::File& irt_file = nacl_browser->IrtFile(); 886 const base::File& irt_file = nacl_browser->IrtFile();
888 CHECK(irt_file.IsValid()); 887 CHECK(irt_file.IsValid());
889 // Send over the IRT file handle. We don't close our own copy! 888 // Send over the IRT file handle. We don't close our own copy!
890 params.irt_handle = IPC::GetFileHandleForProcess( 889 params.irt_handle = IPC::GetPlatformFileForTransit(
891 irt_file.GetPlatformFile(), data.handle, false); 890 irt_file.GetPlatformFile(), false);
892 if (params.irt_handle == IPC::InvalidPlatformFileForTransit()) { 891 if (params.irt_handle == IPC::InvalidPlatformFileForTransit()) {
893 return false; 892 return false;
894 } 893 }
895 894
896 #if defined(OS_MACOSX) 895 #if defined(OS_MACOSX)
897 // For dynamic loading support, NaCl requires a file descriptor that 896 // For dynamic loading support, NaCl requires a file descriptor that
898 // was created in /tmp, since those created with shm_open() are not 897 // was created in /tmp, since those created with shm_open() are not
899 // mappable with PROT_EXEC. Rather than requiring an extra IPC 898 // mappable with PROT_EXEC. Rather than requiring an extra IPC
900 // round trip out of the sandbox, we create an FD here. 899 // round trip out of the sandbox, we create an FD here.
901 base::SharedMemory memory_buffer; 900 base::SharedMemory memory_buffer;
902 base::SharedMemoryCreateOptions options; 901 base::SharedMemoryCreateOptions options;
903 options.size = 1; 902 options.size = 1;
904 options.executable = true; 903 options.executable = true;
905 904
906 // NaCl expects a POSIX fd. 905 // NaCl expects a POSIX fd.
907 options.type = base::SharedMemoryHandle::POSIX; 906 options.type = base::SharedMemoryHandle::POSIX;
908 907
909 if (!memory_buffer.Create(options)) { 908 if (!memory_buffer.Create(options)) {
910 DLOG(ERROR) << "Failed to allocate memory buffer"; 909 DLOG(ERROR) << "Failed to allocate memory buffer";
911 return false; 910 return false;
912 } 911 }
913 base::SharedMemoryHandle duped_handle = 912 base::SharedMemoryHandle duped_handle =
914 base::SharedMemory::DuplicateHandle(memory_buffer.handle()); 913 base::SharedMemory::DuplicateHandle(memory_buffer.handle());
915 base::ScopedFD memory_fd( 914 base::ScopedFD memory_fd(
916 base::SharedMemory::GetFdFromSharedMemoryHandle(duped_handle)); 915 base::SharedMemory::GetFdFromSharedMemoryHandle(duped_handle));
917 if (!memory_fd.is_valid()) { 916 if (!memory_fd.is_valid()) {
918 DLOG(ERROR) << "Failed to dup() a file descriptor"; 917 DLOG(ERROR) << "Failed to dup() a file descriptor";
919 return false; 918 return false;
920 } 919 }
921 params.mac_shm_fd = IPC::GetFileHandleForProcess( 920 params.mac_shm_fd = IPC::GetPlatformFileForTransit(
922 memory_fd.release(), data.handle, true); 921 memory_fd.release(), true);
923 #endif 922 #endif
924 923
925 #if defined(OS_POSIX) 924 #if defined(OS_POSIX)
926 if (params.enable_debug_stub) { 925 if (params.enable_debug_stub) {
927 net::SocketDescriptor server_bound_socket = GetDebugStubSocketHandle(); 926 net::SocketDescriptor server_bound_socket = GetDebugStubSocketHandle();
928 if (server_bound_socket != net::kInvalidSocket) { 927 if (server_bound_socket != net::kInvalidSocket) {
929 params.debug_stub_server_bound_socket = IPC::GetFileHandleForProcess( 928 params.debug_stub_server_bound_socket = IPC::GetPlatformFileForTransit(
930 server_bound_socket, data.handle, true); 929 server_bound_socket, true);
931 } 930 }
932 } 931 }
933 #endif 932 #endif
934 } 933 }
935 934
936 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, 935 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle,
937 &params.crash_info_shmem_handle)) { 936 &params.crash_info_shmem_handle)) {
938 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; 937 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer";
939 return false; 938 return false;
940 } 939 }
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 NaClStartDebugExceptionHandlerThread( 1337 NaClStartDebugExceptionHandlerThread(
1339 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), 1338 std::move(process), info, base::ThreadTaskRunnerHandle::Get(),
1340 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1339 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
1341 weak_factory_.GetWeakPtr())); 1340 weak_factory_.GetWeakPtr()));
1342 return true; 1341 return true;
1343 } 1342 }
1344 } 1343 }
1345 #endif 1344 #endif
1346 1345
1347 } // namespace nacl 1346 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698