Chromium Code Reviews| Index: content/browser/mojo/mojo_application_host.cc |
| diff --git a/content/browser/mojo/mojo_application_host.cc b/content/browser/mojo/mojo_application_host.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0cc0d361564b5d177a865cab37b35225bfe9c8e1 |
| --- /dev/null |
| +++ b/content/browser/mojo/mojo_application_host.cc |
| @@ -0,0 +1,59 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/mojo/mojo_application_host.h" |
| + |
| +#include "content/common/mojo/mojo_messages.h" |
| +#include "content/public/browser/browser_thread.h" |
| +#include "ipc/ipc_sender.h" |
| +#include "mojo/embedder/platform_channel_pair.h" |
| + |
| +namespace content { |
| +namespace { |
| + |
| +base::PlatformFile PlatformFileFromScopedPlatformHandle( |
| + mojo::embedder::ScopedPlatformHandle handle) { |
| +#if defined(OS_POSIX) |
| + return handle.release().fd; |
| +#elif defined(OS_WIN) |
| + return handle.release().handle; |
| +#endif |
| +} |
| + |
| +} // namespace |
| + |
| +MojoApplicationHost::MojoApplicationHost() { |
| +} |
| + |
| +MojoApplicationHost::~MojoApplicationHost() { |
| +} |
| + |
| +bool MojoApplicationHost::Init() { |
| + mojo::embedder::PlatformChannelPair channel_pair; |
| + |
| + mojo::ScopedMessagePipeHandle message_pipe = channel_init_.Init( |
| + PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()), |
| + BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
| + if (!message_pipe.is_valid()) |
| + return false; |
| + |
| + // Forward this to the client once we know its process handle. |
| + client_handle_ = channel_pair.PassClientHandle(); |
| + |
| + // TODO(darin): Provide a Shell implementation |
| + shell_client_.reset( |
| + mojo::ScopedShellClientHandle::From(message_pipe.Pass()), NULL); |
| + |
| + return true; |
| +} |
| + |
| +bool MojoApplicationHost::Activate(IPC::Sender* sender, |
| + base::ProcessHandle process_handle) { |
| + base::PlatformFile client_file = |
|
sky
2014/04/16 17:18:10
DCHECK(client_handle_.is_valid()) ?
darin (slow to review)
2014/04/16 23:26:04
Good idea.
|
| + PlatformFileFromScopedPlatformHandle(client_handle_.Pass()); |
| + return sender->Send(new MojoMsg_Activate( |
|
sky
2014/04/16 17:18:10
Do we need to do this when running single-process?
darin (slow to review)
2014/04/16 23:26:04
Good question. I thought we would still want to es
|
| + IPC::GetFileHandleForProcess(client_file, process_handle, true))); |
| +} |
| + |
| +} // namespace content |