Chromium Code Reviews| 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 45b02d53b1c0a8b132cdab79e44dad1bb5d39868..4e57424125d45bddb61c9f61756bd715ab570c93 100644 |
| --- a/components/nacl/browser/nacl_process_host.cc |
| +++ b/components/nacl/browser/nacl_process_host.cc |
| @@ -49,10 +49,12 @@ |
| #include "content/public/browser/web_contents.h" |
| #include "content/public/common/child_process_host.h" |
| #include "content/public/common/content_switches.h" |
| +#include "content/public/common/mojo_channel_switches.h" |
| #include "content/public/common/process_type.h" |
| #include "content/public/common/sandboxed_process_launcher_delegate.h" |
| #include "ipc/ipc_channel.h" |
| #include "ipc/ipc_switches.h" |
| +#include "mojo/edk/embedder/embedder.h" |
| #include "net/socket/socket_descriptor.h" |
| #include "ppapi/host/host_factory.h" |
| #include "ppapi/host/ppapi_host.h" |
| @@ -163,11 +165,7 @@ content::ZygoteHandle g_nacl_zygote; |
| class NaClSandboxedProcessLauncherDelegate |
| : public content::SandboxedProcessLauncherDelegate { |
| public: |
| - NaClSandboxedProcessLauncherDelegate(ChildProcessHost* host) |
| -#if defined(OS_POSIX) |
| - : ipc_fd_(host->TakeClientFileDescriptor()) |
| -#endif |
| - {} |
| + NaClSandboxedProcessLauncherDelegate(ChildProcessHost* host) {} |
| ~NaClSandboxedProcessLauncherDelegate() override {} |
| @@ -191,13 +189,8 @@ class NaClSandboxedProcessLauncherDelegate |
| } |
| #endif // !defined(OS_MACOSX) |
| - base::ScopedFD TakeIpcFd() override { return std::move(ipc_fd_); } |
| + base::ScopedFD TakeIpcFd() override { return base::ScopedFD(-1); } |
|
Mark Seaborn
2016/07/08 20:26:19
Nit: I think you can use base::ScopedFD() without
Anand Mistry (off Chromium)
2016/07/12 07:26:23
Although it's correct here, I've undone this chang
|
| #endif // OS_WIN |
| - |
| - private: |
| -#if defined(OS_POSIX) |
| - base::ScopedFD ipc_fd_; |
| -#endif // OS_POSIX |
| }; |
| void CloseFile(base::File file) { |
| @@ -307,9 +300,11 @@ NaClProcessHost::NaClProcessHost( |
| process_type_(process_type), |
| profile_directory_(profile_directory), |
| render_view_id_(render_view_id), |
| + mojo_child_token_(mojo::edk::GenerateRandomToken()), |
| weak_factory_(this) { |
| process_.reset(content::BrowserChildProcessHost::Create( |
| - static_cast<content::ProcessType>(PROCESS_TYPE_NACL_LOADER), this)); |
| + static_cast<content::ProcessType>(PROCESS_TYPE_NACL_LOADER), this, |
| + mojo_child_token_)); |
| // Set the display name so the user knows what plugin the process is running. |
| // We aren't on the UI thread so getting the pref locale for language |
| @@ -577,9 +572,10 @@ void NaClProcessHost::LaunchNaClGdb() { |
| } |
| bool NaClProcessHost::LaunchSelLdr() { |
| - std::string channel_id = process_->GetHost()->CreateChannel(); |
| - if (channel_id.empty()) { |
| - SendErrorToRenderer("CreateChannel() failed"); |
| + std::string mojo_channel_token = |
| + process_->GetHost()->CreateChannelMojo(mojo_child_token_); |
|
Mark Seaborn
2016/07/08 20:26:19
Since mojo_child_token_ isn't used after this, you
Anand Mistry (off Chromium)
2016/07/12 07:26:23
Done.
|
| + if (mojo_channel_token.empty()) { |
| + SendErrorToRenderer("CreateChannelMojo() failed"); |
| return false; |
| } |
| @@ -639,7 +635,7 @@ bool NaClProcessHost::LaunchSelLdr() { |
| (uses_nonsfi_mode_ ? |
| switches::kNaClLoaderNonSfiProcess : |
| switches::kNaClLoaderProcess)); |
| - cmd_line->AppendSwitchASCII(switches::kProcessChannelID, channel_id); |
| + cmd_line->AppendSwitchASCII(switches::kMojoChannelToken, mojo_channel_token); |
| if (NaClBrowser::GetDelegate()->DialogsAreSuppressed()) |
| cmd_line->AppendSwitch(switches::kNoErrorDialogs); |
| @@ -651,7 +647,7 @@ bool NaClProcessHost::LaunchSelLdr() { |
| #if defined(OS_WIN) |
| if (RunningOnWOW64()) { |
| if (!NaClBrokerService::GetInstance()->LaunchLoader( |
| - weak_factory_.GetWeakPtr(), channel_id)) { |
| + weak_factory_.GetWeakPtr(), mojo_channel_token)) { |
| SendErrorToRenderer("broker service did not launch process"); |
| return false; |
| } |