Index: content/child/mojo/mojo_application.cc |
diff --git a/content/child/mojo/mojo_application.cc b/content/child/mojo/mojo_application.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..1d61c0b15b2faa6605eabaf8ef5ff2af4cf85e91 |
--- /dev/null |
+++ b/content/child/mojo/mojo_application.cc |
@@ -0,0 +1,45 @@ |
+// 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/child/mojo/mojo_application.h" |
+ |
+#include "content/child/child_process.h" |
+#include "content/common/mojo/mojo_messages.h" |
+#include "ipc/ipc_message.h" |
+ |
+namespace content { |
+ |
+MojoApplication::MojoApplication(mojo::ShellClient* shell_client) |
+ : shell_client_(shell_client) { |
+} |
+ |
+MojoApplication::~MojoApplication() { |
+} |
+ |
+bool MojoApplication::OnMessageReceived(const IPC::Message& msg) { |
+ bool handled = true; |
+ IPC_BEGIN_MESSAGE_MAP(MojoApplication, msg) |
+ IPC_MESSAGE_HANDLER(MojoMsg_Activate, OnActivate) |
+ IPC_MESSAGE_UNHANDLED(handled = false) |
+ IPC_END_MESSAGE_MAP() |
+ return handled; |
+} |
+ |
+void MojoApplication::OnActivate( |
+ const IPC::PlatformFileForTransit& file) { |
+#if defined(OS_POSIX) |
+ base::PlatformFile handle = file.fd; |
+#elif defined(OS_WIN) |
+ base::PlatformFile handle = file; |
+#endif |
+ mojo::ScopedMessagePipeHandle message_pipe = |
+ channel_init_.Init(handle, |
+ ChildProcess::current()->io_message_loop_proxy()); |
+ DCHECK(message_pipe.is_valid()); |
+ |
+ shell_.reset( |
+ mojo::ScopedShellHandle::From(message_pipe.Pass()), shell_client_); |
+} |
+ |
+} // namespace content |