Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/mojo/mojo_application_host.h" | |
| 6 | |
| 7 #include "content/common/mojo/mojo_messages.h" | |
| 8 #include "content/public/browser/browser_thread.h" | |
| 9 #include "ipc/ipc_sender.h" | |
| 10 #include "mojo/embedder/platform_channel_pair.h" | |
| 11 | |
| 12 namespace content { | |
| 13 namespace { | |
| 14 | |
| 15 base::PlatformFile PlatformFileFromScopedPlatformHandle( | |
| 16 mojo::embedder::ScopedPlatformHandle handle) { | |
| 17 #if defined(OS_POSIX) | |
| 18 return handle.release().fd; | |
| 19 #elif defined(OS_WIN) | |
| 20 return handle.release().handle; | |
| 21 #endif | |
| 22 } | |
| 23 | |
| 24 } // namespace | |
| 25 | |
| 26 MojoApplicationHost::MojoApplicationHost() { | |
| 27 } | |
| 28 | |
| 29 MojoApplicationHost::~MojoApplicationHost() { | |
| 30 } | |
| 31 | |
| 32 bool MojoApplicationHost::Init() { | |
| 33 mojo::embedder::PlatformChannelPair channel_pair; | |
| 34 | |
| 35 mojo::ScopedMessagePipeHandle message_pipe = channel_init_.Init( | |
| 36 PlatformFileFromScopedPlatformHandle(channel_pair.PassServerHandle()), | |
| 37 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
| 38 if (!message_pipe.is_valid()) | |
| 39 return false; | |
| 40 | |
| 41 // Forward this to the client once we know its process handle. | |
| 42 client_handle_ = channel_pair.PassClientHandle(); | |
| 43 | |
| 44 // TODO(darin): Provide a Shell implementation | |
| 45 shell_client_.reset( | |
| 46 mojo::ScopedShellClientHandle::From(message_pipe.Pass()), NULL); | |
| 47 | |
| 48 return true; | |
| 49 } | |
| 50 | |
| 51 bool MojoApplicationHost::Activate(IPC::Sender* sender, | |
| 52 base::ProcessHandle process_handle) { | |
| 53 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.
| |
| 54 PlatformFileFromScopedPlatformHandle(client_handle_.Pass()); | |
| 55 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
| |
| 56 IPC::GetFileHandleForProcess(client_file, process_handle, true))); | |
| 57 } | |
| 58 | |
| 59 } // namespace content | |
| OLD | NEW |