Index: components/nacl/browser/nacl_process_host.cc |
diff --git a/components/nacl/browser/nacl_process_host.cc b/components/nacl/browser/nacl_process_host.cc |
index 989de24b838bc903583c3c09e3ceacae8309c453..7ec911be79ab024ca00858eeca3413108fb93c18 100644 |
--- a/components/nacl/browser/nacl_process_host.cc |
+++ b/components/nacl/browser/nacl_process_host.cc |
@@ -12,6 +12,7 @@ |
#include "base/base_switches.h" |
#include "base/bind.h" |
+#include "base/callback_helpers.h" |
#include "base/command_line.h" |
#include "base/files/file_util.h" |
#include "base/location.h" |
@@ -35,16 +36,15 @@ |
#include "build/build_config.h" |
#include "components/nacl/browser/nacl_browser.h" |
#include "components/nacl/browser/nacl_browser_delegate.h" |
-#include "components/nacl/browser/nacl_host_message_filter.h" |
#include "components/nacl/common/nacl_cmd_line.h" |
#include "components/nacl/common/nacl_constants.h" |
-#include "components/nacl/common/nacl_host_messages.h" |
#include "components/nacl/common/nacl_messages.h" |
#include "components/nacl/common/nacl_process_type.h" |
#include "components/nacl/common/nacl_switches.h" |
#include "components/url_formatter/url_formatter.h" |
#include "content/public/browser/browser_child_process_host.h" |
#include "content/public/browser/browser_ppapi_host.h" |
+#include "content/public/browser/browser_thread.h" |
#include "content/public/browser/child_process_data.h" |
#include "content/public/browser/plugin_service.h" |
#include "content/public/browser/render_process_host.h" |
@@ -56,6 +56,7 @@ |
#include "content/public/common/sandboxed_process_launcher_delegate.h" |
#include "ipc/ipc_channel.h" |
#include "mojo/edk/embedder/embedder.h" |
+#include "mojo/public/cpp/system/platform_handle.h" |
#include "net/socket/socket_descriptor.h" |
#include "ppapi/host/host_factory.h" |
#include "ppapi/host/ppapi_host.h" |
@@ -205,6 +206,7 @@ NaClProcessHost::NaClProcessHost( |
const NaClFileToken& nexe_token, |
const std::vector<NaClResourcePrefetchResult>& prefetched_resource_files, |
ppapi::PpapiPermissions permissions, |
+ int render_process_id, |
int render_view_id, |
uint32_t permission_bits, |
bool uses_nonsfi_mode, |
@@ -219,7 +221,6 @@ NaClProcessHost::NaClProcessHost( |
#if defined(OS_WIN) |
process_launched_by_broker_(false), |
#endif |
- reply_msg_(NULL), |
#if defined(OS_WIN) |
debug_exception_handler_requested_(false), |
#endif |
@@ -229,6 +230,7 @@ NaClProcessHost::NaClProcessHost( |
off_the_record_(off_the_record), |
process_type_(process_type), |
profile_directory_(profile_directory), |
+ render_process_id_(render_process_id), |
render_view_id_(render_view_id), |
weak_factory_(this) { |
process_.reset(content::BrowserChildProcessHost::Create( |
@@ -283,11 +285,10 @@ NaClProcessHost::~NaClProcessHost() { |
FROM_HERE, base::Bind(&CloseFile, base::Passed(std::move(nexe_file_)))); |
} |
- if (reply_msg_) { |
+ if (!launch_callback_.is_null()) { |
// The process failed to launch for some reason. |
// Don't keep the renderer hanging. |
- reply_msg_->set_reply_error(); |
- nacl_host_message_filter_->Send(reply_msg_); |
+ SendMessageToRenderer(mojom::NaClLaunchResultPtr(), ""); |
} |
#if defined(OS_WIN) |
if (process_launched_by_broker_) { |
@@ -350,11 +351,9 @@ void NaClProcessHost::SetPpapiKeepAliveThrottleForTesting( |
} |
void NaClProcessHost::Launch( |
- NaClHostMessageFilter* nacl_host_message_filter, |
- IPC::Message* reply_msg, |
- const base::FilePath& manifest_path) { |
- nacl_host_message_filter_ = nacl_host_message_filter; |
- reply_msg_ = reply_msg; |
+ const base::FilePath& manifest_path, |
+ const mojom::NaClHost::LaunchNaClCallback& callback) { |
+ launch_callback_ = callback; |
manifest_path_ = manifest_path; |
// Do not launch the requested NaCl module if NaCl is marked "unstable" due |
@@ -405,7 +404,7 @@ void NaClProcessHost::Launch( |
#if defined(OS_CHROMEOS) && \ |
(defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARMEL)) |
nonsfi_mode_allowed = NaClBrowser::GetDelegate()->IsNonSfiModeAllowed( |
- nacl_host_message_filter->profile_directory(), manifest_url_); |
+ profile_directory_, manifest_url_); |
#endif |
#endif |
bool nonsfi_mode_enabled = |
@@ -635,30 +634,17 @@ void NaClProcessHost::ReplyToRenderer( |
mojo::ScopedMessagePipeHandle ppapi_channel_handle, |
mojo::ScopedMessagePipeHandle trusted_channel_handle, |
mojo::ScopedMessagePipeHandle manifest_service_channel_handle) { |
- // Hereafter, we always send an IPC message with handles created above |
- // which, on Windows, are not closable in this process. |
- std::string error_message; |
- base::SharedMemoryHandle crash_info_shmem_renderer_handle; |
- if (!crash_info_shmem_.ShareToProcess(nacl_host_message_filter_->PeerHandle(), |
- &crash_info_shmem_renderer_handle)) { |
- // On error, we do not send "IPC::ChannelHandle"s to the renderer process. |
- // Note that some other FDs/handles still get sent to the renderer, but |
- // will be closed there. |
- ppapi_channel_handle.reset(); |
- trusted_channel_handle.reset(); |
- manifest_service_channel_handle.reset(); |
- error_message = "ShareToProcess() failed"; |
- } |
- |
const ChildProcessData& data = process_->GetData(); |
SendMessageToRenderer( |
- NaClLaunchResult(ppapi_channel_handle.release(), |
- trusted_channel_handle.release(), |
- manifest_service_channel_handle.release(), |
- base::GetProcId(data.handle), |
- data.id, |
- crash_info_shmem_renderer_handle), |
- error_message); |
+ mojom::NaClLaunchResult::New( |
+ std::move(ppapi_channel_handle), |
+ mojo::MakeRequest<mojom::NaClRendererHost>( |
+ std::move(trusted_channel_handle)), |
+ std::move(manifest_service_channel_handle), |
+ base::GetProcId(data.handle), data.id, |
+ mojo::WrapSharedMemoryHandle(crash_info_shmem_.TakeHandle(), |
+ kNaClCrashInfoShmemSize, false)), |
+ ""); |
// Now that the crash information shmem handles have been shared with the |
// plugin and the renderer, the browser can close its handle. |
@@ -667,26 +653,18 @@ void NaClProcessHost::ReplyToRenderer( |
void NaClProcessHost::SendErrorToRenderer(const std::string& error_message) { |
LOG(ERROR) << "NaCl process launch failed: " << error_message; |
- SendMessageToRenderer(NaClLaunchResult(), error_message); |
+ SendMessageToRenderer(mojom::NaClLaunchResultPtr(), error_message); |
} |
-void NaClProcessHost::SendMessageToRenderer( |
- const NaClLaunchResult& result, |
- const std::string& error_message) { |
- DCHECK(nacl_host_message_filter_.get()); |
- DCHECK(reply_msg_); |
- if (nacl_host_message_filter_.get() == NULL || reply_msg_ == NULL) { |
+void NaClProcessHost::SendMessageToRenderer(mojom::NaClLaunchResultPtr result, |
+ const std::string& error_message) { |
+ DCHECK(!launch_callback_.is_null()); |
+ if (launch_callback_.is_null()) { |
// As DCHECKed above, this case should not happen in general. |
- // Though, in this case, unfortunately there is no proper way to release |
- // resources which are already created in |result|. We just give up on |
- // releasing them, and leak them. |
return; |
} |
- NaClHostMsg_LaunchNaCl::WriteReplyParams(reply_msg_, result, error_message); |
- nacl_host_message_filter_->Send(reply_msg_); |
- nacl_host_message_filter_ = NULL; |
- reply_msg_ = NULL; |
+ base::ResetAndReturn(&launch_callback_).Run(std::move(result), error_message); |
} |
void NaClProcessHost::SetDebugStubPort(int port) { |
@@ -927,17 +905,13 @@ bool NaClProcessHost::StartPPAPIProxy( |
// browser process. |
ppapi_host_.reset(content::BrowserPpapiHost::CreateExternalPluginProcess( |
ipc_proxy_channel_.get(), // sender |
- permissions_, |
- process_->GetData().handle, |
- ipc_proxy_channel_.get(), |
- nacl_host_message_filter_->render_process_id(), |
- render_view_id_, |
- profile_directory_)); |
+ permissions_, process_->GetData().handle, ipc_proxy_channel_.get(), |
+ render_process_id_, render_view_id_, profile_directory_)); |
ppapi_host_->SetOnKeepaliveCallback( |
NaClBrowser::GetDelegate()->GetOnKeepaliveCallback()); |
ppapi::PpapiNaClPluginArgs args; |
- args.off_the_record = nacl_host_message_filter_->off_the_record(); |
+ args.off_the_record = off_the_record_; |
args.permissions = permissions_; |
args.keepalive_throttle_interval_milliseconds = |
keepalive_throttle_interval_milliseconds_; |