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

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

Issue 231793003: Add IPC Channel for new ManifestService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 if (!nacl_browser->IsReady()) { 662 if (!nacl_browser->IsReady()) {
663 SendErrorToRenderer("could not acquire shared resources needed by NaCl"); 663 SendErrorToRenderer("could not acquire shared resources needed by NaCl");
664 delete this; 664 delete this;
665 } else if (!StartNaClExecution()) { 665 } else if (!StartNaClExecution()) {
666 delete this; 666 delete this;
667 } 667 }
668 } 668 }
669 669
670 bool NaClProcessHost::ReplyToRenderer( 670 bool NaClProcessHost::ReplyToRenderer(
671 const IPC::ChannelHandle& ppapi_channel_handle, 671 const IPC::ChannelHandle& ppapi_channel_handle,
672 const IPC::ChannelHandle& trusted_channel_handle) { 672 const IPC::ChannelHandle& trusted_channel_handle,
673 const IPC::ChannelHandle& manifest_service_channel_handle) {
673 #if defined(OS_WIN) 674 #if defined(OS_WIN)
674 // If we are on 64-bit Windows, the NaCl process's sandbox is 675 // If we are on 64-bit Windows, the NaCl process's sandbox is
675 // managed by a different process from the renderer's sandbox. We 676 // managed by a different process from the renderer's sandbox. We
676 // need to inform the renderer's sandbox about the NaCl process so 677 // need to inform the renderer's sandbox about the NaCl process so
677 // that the renderer can send handles to the NaCl process using 678 // that the renderer can send handles to the NaCl process using
678 // BrokerDuplicateHandle(). 679 // BrokerDuplicateHandle().
679 if (RunningOnWOW64()) { 680 if (RunningOnWOW64()) {
680 if (!content::BrokerAddTargetPeer(process_->GetData().handle)) { 681 if (!content::BrokerAddTargetPeer(process_->GetData().handle)) {
681 SendErrorToRenderer("BrokerAddTargetPeer() failed"); 682 SendErrorToRenderer("BrokerAddTargetPeer() failed");
682 return false; 683 return false;
(...skipping 25 matching lines...) Expand all
708 imc_handle.fd = internal_->socket_for_renderer; 709 imc_handle.fd = internal_->socket_for_renderer;
709 imc_handle.auto_close = true; 710 imc_handle.auto_close = true;
710 imc_handle_for_renderer = imc_handle; 711 imc_handle_for_renderer = imc_handle;
711 #endif 712 #endif
712 713
713 const ChildProcessData& data = process_->GetData(); 714 const ChildProcessData& data = process_->GetData();
714 SendMessageToRenderer( 715 SendMessageToRenderer(
715 NaClLaunchResult(imc_handle_for_renderer, 716 NaClLaunchResult(imc_handle_for_renderer,
716 ppapi_channel_handle, 717 ppapi_channel_handle,
717 trusted_channel_handle, 718 trusted_channel_handle,
719 manifest_service_channel_handle,
718 base::GetProcId(data.handle), 720 base::GetProcId(data.handle),
719 data.id), 721 data.id),
720 std::string() /* error_message */); 722 std::string() /* error_message */);
721 internal_->socket_for_renderer = NACL_INVALID_HANDLE; 723 internal_->socket_for_renderer = NACL_INVALID_HANDLE;
722 return true; 724 return true;
723 } 725 }
724 726
725 void NaClProcessHost::SendErrorToRenderer(const std::string& error_message) { 727 void NaClProcessHost::SendErrorToRenderer(const std::string& error_message) {
726 LOG(ERROR) << "NaCl process launch failed: " << error_message; 728 LOG(ERROR) << "NaCl process launch failed: " << error_message;
727 SendMessageToRenderer(NaClLaunchResult(), error_message); 729 SendMessageToRenderer(NaClLaunchResult(), error_message);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 849
848 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE; 850 internal_->socket_for_sel_ldr = NACL_INVALID_HANDLE;
849 return true; 851 return true;
850 } 852 }
851 853
852 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is 854 // This method is called when NaClProcessHostMsg_PpapiChannelCreated is
853 // received. 855 // received.
854 void NaClProcessHost::OnPpapiChannelsCreated( 856 void NaClProcessHost::OnPpapiChannelsCreated(
855 const IPC::ChannelHandle& browser_channel_handle, 857 const IPC::ChannelHandle& browser_channel_handle,
856 const IPC::ChannelHandle& ppapi_renderer_channel_handle, 858 const IPC::ChannelHandle& ppapi_renderer_channel_handle,
857 const IPC::ChannelHandle& trusted_renderer_channel_handle) { 859 const IPC::ChannelHandle& trusted_renderer_channel_handle,
860 const IPC::ChannelHandle& manifest_service_channel_handle) {
858 if (!enable_ppapi_proxy()) { 861 if (!enable_ppapi_proxy()) {
859 ReplyToRenderer(IPC::ChannelHandle(), trusted_renderer_channel_handle); 862 ReplyToRenderer(IPC::ChannelHandle(),
863 trusted_renderer_channel_handle,
864 manifest_service_channel_handle);
860 return; 865 return;
861 } 866 }
862 867
863 if (!ipc_proxy_channel_.get()) { 868 if (!ipc_proxy_channel_.get()) {
864 DCHECK_EQ(PROCESS_TYPE_NACL_LOADER, process_->GetData().process_type); 869 DCHECK_EQ(PROCESS_TYPE_NACL_LOADER, process_->GetData().process_type);
865 870
866 ipc_proxy_channel_.reset( 871 ipc_proxy_channel_.reset(
867 new IPC::ChannelProxy(browser_channel_handle, 872 new IPC::ChannelProxy(browser_channel_handle,
868 IPC::Channel::MODE_CLIENT, 873 IPC::Channel::MODE_CLIENT,
869 NULL, 874 NULL,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 ppapi_host_->GetPpapiHost()->AddHostFactoryFilter( 908 ppapi_host_->GetPpapiHost()->AddHostFactoryFilter(
904 scoped_ptr<ppapi::host::HostFactory>( 909 scoped_ptr<ppapi::host::HostFactory>(
905 NaClBrowser::GetDelegate()->CreatePpapiHostFactory( 910 NaClBrowser::GetDelegate()->CreatePpapiHostFactory(
906 ppapi_host_.get()))); 911 ppapi_host_.get())));
907 912
908 // Send a message to initialize the IPC dispatchers in the NaCl plugin. 913 // Send a message to initialize the IPC dispatchers in the NaCl plugin.
909 ipc_proxy_channel_->Send(new PpapiMsg_InitializeNaClDispatcher(args)); 914 ipc_proxy_channel_->Send(new PpapiMsg_InitializeNaClDispatcher(args));
910 915
911 // Let the renderer know that the IPC channels are established. 916 // Let the renderer know that the IPC channels are established.
912 ReplyToRenderer(ppapi_renderer_channel_handle, 917 ReplyToRenderer(ppapi_renderer_channel_handle,
913 trusted_renderer_channel_handle); 918 trusted_renderer_channel_handle,
919 manifest_service_channel_handle);
914 } else { 920 } else {
915 // Attempt to open more than 1 browser channel is not supported. 921 // Attempt to open more than 1 browser channel is not supported.
916 // Shut down the NaCl process. 922 // Shut down the NaCl process.
917 process_->GetHost()->ForceShutdown(); 923 process_->GetHost()->ForceShutdown();
918 } 924 }
919 } 925 }
920 926
921 bool NaClProcessHost::StartWithLaunchedProcess() { 927 bool NaClProcessHost::StartWithLaunchedProcess() {
922 NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); 928 NaClBrowser* nacl_browser = NaClBrowser::GetInstance();
923 929
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 process_handle.Take(), info, 1090 process_handle.Take(), info,
1085 base::MessageLoopProxy::current(), 1091 base::MessageLoopProxy::current(),
1086 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker, 1092 base::Bind(&NaClProcessHost::OnDebugExceptionHandlerLaunchedByBroker,
1087 weak_factory_.GetWeakPtr())); 1093 weak_factory_.GetWeakPtr()));
1088 return true; 1094 return true;
1089 } 1095 }
1090 } 1096 }
1091 #endif 1097 #endif
1092 1098
1093 } // namespace nacl 1099 } // namespace nacl
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_process_host.h ('k') | components/nacl/common/nacl_host_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698