| Index: content/child/child_thread_impl.cc
|
| diff --git a/content/child/child_thread_impl.cc b/content/child/child_thread_impl.cc
|
| index 3d26cbdf16d307efc26885afcc71b766b8eb3e46..9f16f9157e3d8849cb1176b3b90dcda2f020581e 100644
|
| --- a/content/child/child_thread_impl.cc
|
| +++ b/content/child/child_thread_impl.cc
|
| @@ -53,6 +53,7 @@
|
| #include "content/child/websocket_message_filter.h"
|
| #include "content/common/child_process_messages.h"
|
| #include "content/common/in_process_child_thread_params.h"
|
| +#include "content/public/common/connection_filter.h"
|
| #include "content/public/common/content_switches.h"
|
| #include "content/public/common/mojo_channel_switches.h"
|
| #include "content/public/common/mojo_shell_connection.h"
|
| @@ -68,6 +69,7 @@
|
| #include "mojo/edk/embedder/named_platform_channel_pair.h"
|
| #include "mojo/edk/embedder/platform_channel_pair.h"
|
| #include "mojo/edk/embedder/scoped_ipc_support.h"
|
| +#include "services/shell/public/cpp/connection.h"
|
| #include "services/shell/public/cpp/interface_provider.h"
|
| #include "services/shell/public/cpp/interface_registry.h"
|
| #include "services/shell/runner/common/client_util.h"
|
| @@ -257,6 +259,36 @@ void InitializeMojoIPCChannel() {
|
|
|
| } // namespace
|
|
|
| +class ChildThreadImpl::ChildThreadConnectionFilter
|
| + : public ConnectionFilter,
|
| + public shell::InterfaceFactory<IPC::mojom::Bootstrap> {
|
| + public:
|
| + explicit ChildThreadConnectionFilter(ChildThreadImpl* impl)
|
| + : child_thread_impl_(impl) {}
|
| + ~ChildThreadConnectionFilter() override {}
|
| +
|
| + private:
|
| + // ConnectionFilter:
|
| + bool OnConnect(shell::Connection* connection,
|
| + shell::Connector* connector) override {
|
| + connection->GetInterfaceRegistry()->AddInterface<IPC::mojom::Bootstrap>(
|
| + this);
|
| + return true;
|
| + }
|
| +
|
| + // shell::InterfaceFactory<IPC::mojom::Bootstrap>:
|
| + void Create(shell::Connection* connection,
|
| + IPC::mojom::BootstrapRequest request) override {
|
| + // TODO: bind channel.
|
| + LOG(WARNING) << "Hello, World!";
|
| + child_thread_impl_->ConnectMojoChannel(std::move(request));
|
| + }
|
| +
|
| + ChildThreadImpl* child_thread_impl_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ChildThreadConnectionFilter);
|
| +};
|
| +
|
| ChildThread* ChildThread::Get() {
|
| return ChildThreadImpl::current();
|
| }
|
| @@ -388,6 +420,13 @@ void ChildThreadImpl::ConnectChannel(bool use_mojo_channel,
|
| channel_->Init(channel_name_, IPC::Channel::MODE_CLIENT, create_pipe_now);
|
| }
|
|
|
| +void ChildThreadImpl::ConnectMojoChannel(IPC::mojom::BootstrapRequest request) {
|
| + channel_->Init(
|
| + IPC::ChannelMojo::CreateClientFactory(
|
| + request.PassMessagePipe(), ChildProcess::current()->io_task_runner()),
|
| + true);
|
| +}
|
| +
|
| void ChildThreadImpl::Init(const Options& options) {
|
| channel_name_ = options.channel_name;
|
|
|
| @@ -431,6 +470,8 @@ void ChildThreadImpl::Init(const Options& options) {
|
| mojo_shell_connection_ = MojoShellConnection::Create(
|
| mojo::MakeRequest<shell::mojom::Service>(std::move(handle)),
|
| GetIOTaskRunner());
|
| + mojo_shell_connection_->AddConnectionFilter(
|
| + base::WrapUnique(new ChildThreadConnectionFilter(this)));
|
|
|
| // TODO(rockot): Remove this once all child-to-browser interface connections
|
| // are made via a Connector rather than directly through an
|
|
|