OLD | NEW |
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 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 } | 611 } |
612 } | 612 } |
613 | 613 |
614 void NaClProcessHost::ReplyToRenderer( | 614 void NaClProcessHost::ReplyToRenderer( |
615 mojo::ScopedMessagePipeHandle ppapi_channel_handle, | 615 mojo::ScopedMessagePipeHandle ppapi_channel_handle, |
616 mojo::ScopedMessagePipeHandle trusted_channel_handle, | 616 mojo::ScopedMessagePipeHandle trusted_channel_handle, |
617 mojo::ScopedMessagePipeHandle manifest_service_channel_handle) { | 617 mojo::ScopedMessagePipeHandle manifest_service_channel_handle) { |
618 // Hereafter, we always send an IPC message with handles created above | 618 // Hereafter, we always send an IPC message with handles created above |
619 // which, on Windows, are not closable in this process. | 619 // which, on Windows, are not closable in this process. |
620 std::string error_message; | 620 std::string error_message; |
621 base::SharedMemoryHandle crash_info_shmem_renderer_handle; | 621 base::SharedMemoryHandle crash_info_shmem_renderer_handle = |
622 if (!crash_info_shmem_.ShareToProcess(nacl_host_message_filter_->PeerHandle(), | 622 crash_info_shmem_.handle().Duplicate(); |
623 &crash_info_shmem_renderer_handle)) { | 623 if (!crash_info_shmem_renderer_handle.IsValid()) { |
624 // On error, we do not send "IPC::ChannelHandle"s to the renderer process. | 624 // On error, we do not send "IPC::ChannelHandle"s to the renderer process. |
625 // Note that some other FDs/handles still get sent to the renderer, but | 625 // Note that some other FDs/handles still get sent to the renderer, but |
626 // will be closed there. | 626 // will be closed there. |
627 ppapi_channel_handle.reset(); | 627 ppapi_channel_handle.reset(); |
628 trusted_channel_handle.reset(); | 628 trusted_channel_handle.reset(); |
629 manifest_service_channel_handle.reset(); | 629 manifest_service_channel_handle.reset(); |
630 error_message = "ShareToProcess() failed"; | 630 error_message = "handle duplication failed"; |
631 } | 631 } |
632 | 632 |
633 const ChildProcessData& data = process_->GetData(); | 633 const ChildProcessData& data = process_->GetData(); |
634 SendMessageToRenderer( | 634 SendMessageToRenderer( |
635 NaClLaunchResult(ppapi_channel_handle.release(), | 635 NaClLaunchResult(ppapi_channel_handle.release(), |
636 trusted_channel_handle.release(), | 636 trusted_channel_handle.release(), |
637 manifest_service_channel_handle.release(), | 637 manifest_service_channel_handle.release(), |
638 base::GetProcId(data.handle), | 638 base::GetProcId(data.handle), |
639 data.id, | 639 data.id, |
640 crash_info_shmem_renderer_handle), | 640 crash_info_shmem_renderer_handle), |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 if (params.enable_debug_stub) { | 778 if (params.enable_debug_stub) { |
779 net::SocketDescriptor server_bound_socket = GetDebugStubSocketHandle(); | 779 net::SocketDescriptor server_bound_socket = GetDebugStubSocketHandle(); |
780 if (server_bound_socket != net::kInvalidSocket) { | 780 if (server_bound_socket != net::kInvalidSocket) { |
781 params.debug_stub_server_bound_socket = IPC::GetPlatformFileForTransit( | 781 params.debug_stub_server_bound_socket = IPC::GetPlatformFileForTransit( |
782 server_bound_socket, true); | 782 server_bound_socket, true); |
783 } | 783 } |
784 } | 784 } |
785 #endif | 785 #endif |
786 } | 786 } |
787 | 787 |
788 if (!crash_info_shmem_.ShareToProcess(process_->GetData().handle, | 788 params.crash_info_shmem_handle = crash_info_shmem_.handle().Duplicate(); |
789 ¶ms.crash_info_shmem_handle)) { | 789 if (!params.crash_info_shmem_handle.IsValid()) { |
790 DLOG(ERROR) << "Failed to ShareToProcess() a shared memory buffer"; | 790 DLOG(ERROR) << "Failed to duplicate a shared memory buffer"; |
791 return false; | 791 return false; |
792 } | 792 } |
793 | 793 |
794 // Pass the pre-opened resource files to the loader. We do not have to reopen | 794 // Pass the pre-opened resource files to the loader. We do not have to reopen |
795 // resource files here even for SFI mode because the descriptors are not from | 795 // resource files here even for SFI mode because the descriptors are not from |
796 // a renderer. | 796 // a renderer. |
797 for (size_t i = 0; i < prefetched_resource_files_.size(); ++i) { | 797 for (size_t i = 0; i < prefetched_resource_files_.size(); ++i) { |
798 process_->Send(new NaClProcessMsg_AddPrefetchedResource( | 798 process_->Send(new NaClProcessMsg_AddPrefetchedResource( |
799 NaClResourcePrefetchResult( | 799 NaClResourcePrefetchResult( |
800 prefetched_resource_files_[i].file, | 800 prefetched_resource_files_[i].file, |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 NaClStartDebugExceptionHandlerThread( | 1129 NaClStartDebugExceptionHandlerThread( |
1130 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), | 1130 std::move(process), info, base::ThreadTaskRunnerHandle::Get(), |
1131 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, | 1131 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, |
1132 weak_factory_.GetWeakPtr())); | 1132 weak_factory_.GetWeakPtr())); |
1133 return true; | 1133 return true; |
1134 } | 1134 } |
1135 } | 1135 } |
1136 #endif | 1136 #endif |
1137 | 1137 |
1138 } // namespace nacl | 1138 } // namespace nacl |
OLD | NEW |