| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/child/mojo/mojo_application.h" | 5 #include "content/child/mojo/mojo_application.h" |
| 6 | 6 |
| 7 #include "content/child/child_process.h" | 7 #include "content/child/child_process.h" |
| 8 #include "content/common/mojo/mojo_messages.h" | 8 #include "content/common/mojo/mojo_messages.h" |
| 9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
| 10 | 10 |
| 11 namespace content { | 11 namespace content { |
| 12 | 12 |
| 13 MojoApplication::MojoApplication(mojo::ServiceProvider* service_provider) | 13 MojoApplication::MojoApplication() { |
| 14 : service_provider_(service_provider) { | |
| 15 } | 14 } |
| 16 | 15 |
| 17 MojoApplication::~MojoApplication() { | 16 MojoApplication::~MojoApplication() { |
| 18 } | 17 } |
| 19 | 18 |
| 20 bool MojoApplication::OnMessageReceived(const IPC::Message& msg) { | 19 bool MojoApplication::OnMessageReceived(const IPC::Message& msg) { |
| 21 bool handled = true; | 20 bool handled = true; |
| 22 IPC_BEGIN_MESSAGE_MAP(MojoApplication, msg) | 21 IPC_BEGIN_MESSAGE_MAP(MojoApplication, msg) |
| 23 IPC_MESSAGE_HANDLER(MojoMsg_Activate, OnActivate) | 22 IPC_MESSAGE_HANDLER(MojoMsg_Activate, OnActivate) |
| 24 IPC_MESSAGE_UNHANDLED(handled = false) | 23 IPC_MESSAGE_UNHANDLED(handled = false) |
| 25 IPC_END_MESSAGE_MAP() | 24 IPC_END_MESSAGE_MAP() |
| 26 return handled; | 25 return handled; |
| 27 } | 26 } |
| 28 | 27 |
| 29 void MojoApplication::OnActivate( | 28 void MojoApplication::OnActivate( |
| 30 const IPC::PlatformFileForTransit& file) { | 29 const IPC::PlatformFileForTransit& file) { |
| 31 #if defined(OS_POSIX) | 30 #if defined(OS_POSIX) |
| 32 base::PlatformFile handle = file.fd; | 31 base::PlatformFile handle = file.fd; |
| 33 #elif defined(OS_WIN) | 32 #elif defined(OS_WIN) |
| 34 base::PlatformFile handle = file; | 33 base::PlatformFile handle = file; |
| 35 #endif | 34 #endif |
| 36 mojo::ScopedMessagePipeHandle message_pipe = | 35 mojo::ScopedMessagePipeHandle message_pipe = |
| 37 channel_init_.Init(handle, | 36 channel_init_.Init(handle, |
| 38 ChildProcess::current()->io_message_loop_proxy()); | 37 ChildProcess::current()->io_message_loop_proxy()); |
| 39 DCHECK(message_pipe.is_valid()); | 38 DCHECK(message_pipe.is_valid()); |
| 40 | 39 service_registry_.Bind(message_pipe.Pass()); |
| 41 host_service_provider_.Bind(message_pipe.Pass()); | |
| 42 host_service_provider_.set_client(service_provider_); | |
| 43 } | 40 } |
| 44 | 41 |
| 45 } // namespace content | 42 } // namespace content |
| OLD | NEW |